header_bar: add WindowControlsPosition (macOS-style left controls)

Adds a new public enum `WindowControlsPosition { Start, End }` and a
matching field on `HeaderBar`, allowing window controls (close / minimize
/ maximize) to be packed on the start side of the headerbar (macOS
style, icon order close → minimize → maximize) instead of the default
end side (Linux / GNOME style, minimize → maximize → close).

Wiring:
- `crate::widget::WindowControlsPosition` re-exported alongside
  `HeaderBar`.
- `HeaderBar::controls_position(Option<WindowControlsPosition>)` setter;
  when left unset, falls back to `crate::config::window_controls_position()`
  (reads `CosmicTk.window_controls_position`), mirroring how `density`
  falls back to `header_size()`.
- New `CosmicTk.window_controls_position` field with default `End` for
  backwards compatibility; serde-friendly enum so existing configs keep
  working via `#[serde(default)]` semantics.

Tested with cosmic-yoterm, cosmic-settings, cosmic-edit, cosmic-files
rebuilt against this libcosmic via a local `[patch]` override. Config
changes picked up live through the existing cosmic-config subscription.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Lionel DARNIS 2026-04-22 15:08:12 +02:00
parent b7c81907ba
commit 261a211647
3 changed files with 94 additions and 24 deletions

View file

@ -225,7 +225,7 @@ pub use grid::{Grid, grid};
mod header_bar;
#[doc(inline)]
pub use header_bar::{HeaderBar, header_bar};
pub use header_bar::{HeaderBar, WindowControlsPosition, header_bar};
pub mod icon;
#[doc(inline)]