diff --git a/cosmic-settings/src/pages/desktop/window_management.rs b/cosmic-settings/src/pages/desktop/window_management.rs index fb020285..22d3a3f4 100644 --- a/cosmic-settings/src/pages/desktop/window_management.rs +++ b/cosmic-settings/src/pages/desktop/window_management.rs @@ -25,7 +25,7 @@ pub enum Message { ShowActiveWindowHint(bool), ShowMaximizeButton(bool), ShowMinimizeButton(bool), - SetWindowSnapThreshold(u32), + SetEdgeSnapThreshold(u32), } pub struct Page { @@ -37,7 +37,7 @@ pub struct Page { focus_delay_text: String, cursor_follows_focus: bool, show_active_hint: bool, - window_snap_threshold: u32, + edge_snap_threshold: u32, } impl Default for Page { @@ -101,7 +101,7 @@ impl Default for Page { focus_delay_text: format!("{focus_follows_cursor_delay}"), cursor_follows_focus, show_active_hint, - window_snap_threshold, + edge_snap_threshold: window_snap_threshold, } } } @@ -180,10 +180,10 @@ impl Page { error!(?err, "Failed to set config 'active_hint'"); } } - Message::SetWindowSnapThreshold(value) => { - self.window_snap_threshold = value; - if let Err(err) = self.comp_config.set("window_snap_threshold", value) { - error!(?err, "Failed to set config 'window_snap_threshold'"); + Message::SetEdgeSnapThreshold(value) => { + self.edge_snap_threshold = value; + if let Err(err) = self.comp_config.set("edge_snap_threshold", value) { + error!(?err, "Failed to set config 'edge_snap_threshold'"); } } } @@ -197,10 +197,9 @@ impl page::Page for Page { sections: &mut SlotMap>, ) -> Option { Some(vec![ - sections.insert(super_key_action()), + sections.insert(window_management()), sections.insert(window_controls()), sections.insert(focus_navigation()), - sections.insert(floating_layout()), ]) } @@ -216,7 +215,7 @@ impl page::Page for Page { impl page::AutoBind for Page {} -pub fn super_key_action() -> Section { +pub fn window_management() -> Section { let mut descriptions = Slab::new(); let super_key = descriptions.insert(fl!("super-key")); @@ -225,6 +224,8 @@ pub fn super_key_action() -> Section { let _applications = descriptions.insert(fl!("super-key", "applications")); let _disable = descriptions.insert(fl!("super-key", "disable")); + let edge_gravity = descriptions.insert(fl!("edge-gravity")); + Section::default() .descriptions(descriptions) .view::(move |_binder, page, section| { @@ -239,6 +240,12 @@ pub fn super_key_action() -> Section { Message::SuperKey, )), ) + .add(settings::item( + &descriptions[edge_gravity], + toggler(page.edge_snap_threshold != 0).on_toggle(|is_enabled| { + Message::SetEdgeSnapThreshold(if is_enabled { 10 } else { 0 }) + }), + )) .apply(Element::from) .map(crate::pages::Message::WindowManagement) }) @@ -315,37 +322,6 @@ pub fn focus_navigation() -> Section { }) } -pub fn floating_layout() -> Section { - let mut descriptions = Slab::new(); - - let window_snap_threshold = - descriptions.insert(fl!("floating-layout", "window-snap-threshold")); - - Section::default() - .title(fl!("floating-layout")) - .descriptions(descriptions) - .view::(move |_binder, page, section| { - let descriptions = §ion.descriptions; - - settings::section() - .title(§ion.title) - .add( - settings::item::builder(&descriptions[window_snap_threshold]).control( - widget::spin_button( - page.window_snap_threshold.to_string(), - page.window_snap_threshold, - 5, - 0, - 500, - Message::SetWindowSnapThreshold, - ), - ), - ) - .apply(Element::from) - .map(crate::pages::Message::WindowManagement) - }) -} - fn super_key_active_config() -> Option { let super_binding = Binding::new(shortcuts::Modifiers::new().logo(), None); diff --git a/i18n/en/cosmic_settings.ftl b/i18n/en/cosmic_settings.ftl index 8860f742..c90613b1 100644 --- a/i18n/en/cosmic_settings.ftl +++ b/i18n/en/cosmic_settings.ftl @@ -302,6 +302,8 @@ super-key = Super key action .applications = Open Applications .disable = Disable +edge-gravity = Floating windows gravitate to nearby edges + window-controls = Window Controls .maximize = Show maximize button .minimize = Show minimize button @@ -312,9 +314,6 @@ focus-navigation = Focus Navigation .focus-follows-cursor-delay = Focus follows cursor delay in ms .cursor-follows-focus = Cursor follows focus -floating-layout = Floating Layout - .window-snap-threshold = Window snap-to-edge threshold - ## Desktop: Workspaces workspaces = Workspaces