window-management: toggle for macOS-style window controls position
Adds a new toggler "Place buttons on the left (macOS style)" in *Desktop → Window Management → Window controls*, next to the existing show_maximize / show_minimize controls. When enabled, writes `WindowControlsPosition::Start` into the `CosmicTk` config (com.system76.CosmicTk); when disabled, writes `End` (default). All libcosmic-based applications rebuilt against a libcosmic that exposes `WindowControlsPosition` pick up the change live through the existing cosmic-config subscription. Includes: - new Message variant WindowControlsPositionStart(bool) + handler - `window-controls.position-start` fluent key added in en + fr locales - Cargo.toml: activate local [patch] override to libcosmic (dev only, not suitable for upstream merge) Requires: libcosmic >= 5c331935 (header_bar WindowControlsPosition). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
48eae39858
commit
52ce463a59
4 changed files with 30 additions and 6 deletions
12
Cargo.toml
12
Cargo.toml
|
|
@ -70,12 +70,12 @@ cosmic-client-toolkit = { git = "https://github.com/pop-os/cosmic-protocols//",
|
||||||
# cosmic-settings-config = { git = "https://github.com/pop-os/cosmic-settings-daemon//", branch = "input_nobuild" }
|
# cosmic-settings-config = { git = "https://github.com/pop-os/cosmic-settings-daemon//", branch = "input_nobuild" }
|
||||||
|
|
||||||
# For development and testing purposes
|
# For development and testing purposes
|
||||||
# [patch.'https://github.com/pop-os/libcosmic']
|
[patch.'https://github.com/pop-os/libcosmic']
|
||||||
# libcosmic = { path = "../libcosmic" }
|
libcosmic = { path = "../libcosmic" }
|
||||||
# cosmic-config = { path = "../libcosmic/cosmic-config" }
|
cosmic-config = { path = "../libcosmic/cosmic-config" }
|
||||||
# cosmic-theme = { path = "../libcosmic/cosmic-theme" }
|
cosmic-theme = { path = "../libcosmic/cosmic-theme" }
|
||||||
# iced_futures = { path = "../libcosmic/iced/futures" }
|
iced_futures = { path = "../libcosmic/iced/futures" }
|
||||||
# iced_winit = { path = "../libcosmic/iced/winit" }
|
iced_winit = { path = "../libcosmic/iced/winit" }
|
||||||
|
|
||||||
# libcosmic = { git = "https://github.com/pop-os/libcosmic//" }
|
# libcosmic = { git = "https://github.com/pop-os/libcosmic//" }
|
||||||
# cosmic-config = { git = "https://github.com/pop-os/libcosmic//" }
|
# cosmic-config = { git = "https://github.com/pop-os/libcosmic//" }
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ pub enum Message {
|
||||||
ShowActiveWindowHint(bool),
|
ShowActiveWindowHint(bool),
|
||||||
ShowMaximizeButton(bool),
|
ShowMaximizeButton(bool),
|
||||||
ShowMinimizeButton(bool),
|
ShowMinimizeButton(bool),
|
||||||
|
WindowControlsPositionStart(bool),
|
||||||
SetEdgeSnapThreshold(u32),
|
SetEdgeSnapThreshold(u32),
|
||||||
Surface(surface::Action),
|
Surface(surface::Action),
|
||||||
}
|
}
|
||||||
|
|
@ -177,6 +178,19 @@ impl Page {
|
||||||
.set_show_minimize(&config, value);
|
.set_show_minimize(&config, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Message::WindowControlsPositionStart(left) => {
|
||||||
|
if let Ok(config) = cosmic::config::CosmicTk::config() {
|
||||||
|
let position = if left {
|
||||||
|
cosmic::widget::WindowControlsPosition::Start
|
||||||
|
} else {
|
||||||
|
cosmic::widget::WindowControlsPosition::End
|
||||||
|
};
|
||||||
|
let _res = cosmic::config::COSMIC_TK
|
||||||
|
.write()
|
||||||
|
.unwrap()
|
||||||
|
.set_window_controls_position(&config, position);
|
||||||
|
}
|
||||||
|
}
|
||||||
Message::ShowActiveWindowHint(value) => {
|
Message::ShowActiveWindowHint(value) => {
|
||||||
self.show_active_hint = value;
|
self.show_active_hint = value;
|
||||||
if let Err(err) = self.comp_config.set("active_hint", value) {
|
if let Err(err) = self.comp_config.set("active_hint", value) {
|
||||||
|
|
@ -274,6 +288,7 @@ pub fn window_controls() -> Section<crate::pages::Message> {
|
||||||
maximize = fl!("window-controls", "maximize");
|
maximize = fl!("window-controls", "maximize");
|
||||||
minimize = fl!("window-controls", "minimize");
|
minimize = fl!("window-controls", "minimize");
|
||||||
active_window_hint = fl!("window-controls", "active-window-hint");
|
active_window_hint = fl!("window-controls", "active-window-hint");
|
||||||
|
position_start = fl!("window-controls", "position-start");
|
||||||
});
|
});
|
||||||
|
|
||||||
Section::default()
|
Section::default()
|
||||||
|
|
@ -296,6 +311,13 @@ pub fn window_controls() -> Section<crate::pages::Message> {
|
||||||
settings::item::builder(&descriptions[minimize])
|
settings::item::builder(&descriptions[minimize])
|
||||||
.toggler(cosmic::config::show_minimize(), Message::ShowMinimizeButton),
|
.toggler(cosmic::config::show_minimize(), Message::ShowMinimizeButton),
|
||||||
)
|
)
|
||||||
|
.add(settings::item::builder(&descriptions[position_start]).toggler(
|
||||||
|
matches!(
|
||||||
|
cosmic::config::window_controls_position(),
|
||||||
|
cosmic::widget::WindowControlsPosition::Start
|
||||||
|
),
|
||||||
|
Message::WindowControlsPositionStart,
|
||||||
|
))
|
||||||
.apply(Element::from)
|
.apply(Element::from)
|
||||||
.map(crate::pages::Message::WindowManagement)
|
.map(crate::pages::Message::WindowManagement)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
1
i18n/en/cosmic_settings.ftl
vendored
1
i18n/en/cosmic_settings.ftl
vendored
|
|
@ -484,6 +484,7 @@ window-controls = Window controls
|
||||||
.maximize = Show maximize button
|
.maximize = Show maximize button
|
||||||
.minimize = Show minimize button
|
.minimize = Show minimize button
|
||||||
.active-window-hint = Show active window hint
|
.active-window-hint = Show active window hint
|
||||||
|
.position-start = Place buttons on the left (macOS style)
|
||||||
|
|
||||||
focus-navigation = Focus navigation
|
focus-navigation = Focus navigation
|
||||||
.focus-follows-cursor = Focus follows cursor
|
.focus-follows-cursor = Focus follows cursor
|
||||||
|
|
|
||||||
1
i18n/fr/cosmic_settings.ftl
vendored
1
i18n/fr/cosmic_settings.ftl
vendored
|
|
@ -322,6 +322,7 @@ window-controls = Contrôles des fenêtres
|
||||||
.maximize = Afficher le bouton maximiser
|
.maximize = Afficher le bouton maximiser
|
||||||
.minimize = Afficher le bouton minimiser
|
.minimize = Afficher le bouton minimiser
|
||||||
.active-window-hint = Afficher l'indice de la fenêtre active
|
.active-window-hint = Afficher l'indice de la fenêtre active
|
||||||
|
.position-start = Placer les boutons à gauche (style macOS)
|
||||||
focus-navigation = Navigation par le focus
|
focus-navigation = Navigation par le focus
|
||||||
.focus-follows-cursor = Le focus suit le curseur
|
.focus-follows-cursor = Le focus suit le curseur
|
||||||
.focus-follows-cursor-delay = Délai de suivi du focus en ms
|
.focus-follows-cursor-delay = Délai de suivi du focus en ms
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue