From 3a4105dd425ef14577b8e51b81acecb6986eb62d Mon Sep 17 00:00:00 2001 From: kossLAN Date: Sat, 6 Jun 2026 20:05:20 -0400 Subject: [PATCH] add mouse_follows_focus --- book/src/configuration/misc.md | 13 ++++++++++++ crates/jay-config/src/input.rs | 14 ++++++++++--- .../toml-config/src/config/parsers/config.rs | 15 ++++++++++---- crates/toml-config/src/lib.rs | 5 +---- crates/toml-spec/spec/spec.generated.json | 6 +++++- crates/toml-spec/spec/spec.generated.md | 19 ++++++++++++++---- crates/toml-spec/spec/spec.yaml | 20 ++++++++++++++----- src/ifs/wl_seat.rs | 2 +- 8 files changed, 72 insertions(+), 22 deletions(-) diff --git a/book/src/configuration/misc.md b/book/src/configuration/misc.md index 33f0c8ba..75bcf0b1 100644 --- a/book/src/configuration/misc.md +++ b/book/src/configuration/misc.md @@ -145,6 +145,19 @@ focus. focus-follows-mouse = true # default ``` +## Mouse Follows Focus + +When enabled, moving focus with keyboard commands centers the pointer on the +newly focused window. + +```toml +mouse-follows-focus = true # default +``` + +Set it to `false` if you want shortcuts such as `focus-left`, `focus-right`, +`focus-prev`, `focus-next`, and workspace switching to leave the pointer where +it is. + ## Window Management Key Designates a key that, while held, enables window management mode. In this diff --git a/crates/jay-config/src/input.rs b/crates/jay-config/src/input.rs index c052bba7..70dbc025 100644 --- a/crates/jay-config/src/input.rs +++ b/crates/jay-config/src/input.rs @@ -699,12 +699,20 @@ impl Seat { /// Sets whether the cursor should automatically move to the center of a window /// when focus changes via keyboard commands (move-left, focus-right, show-workspace, etc.). /// - /// The default is `false`. - #[deprecated = "This setting is unstable and might be removed in the future"] - pub fn unstable_set_mouse_follows_focus(self, enabled: bool) { + /// The default is `true`. + pub fn set_mouse_follows_focus(self, enabled: bool) { get!().seat_set_mouse_follows_focus(self, enabled) } + /// Sets whether the cursor should automatically move to the center of a window + /// when focus changes via keyboard commands (move-left, focus-right, show-workspace, etc.). + /// + /// The default is `true`. + #[deprecated = "Use `set_mouse_follows_focus` instead"] + pub fn unstable_set_mouse_follows_focus(self, enabled: bool) { + self.set_mouse_follows_focus(enabled) + } + /// Toggles tabbed mode on the focused window's parent container. pub fn toggle_tab(self) { get!().seat_toggle_tab(self) diff --git a/crates/toml-config/src/config/parsers/config.rs b/crates/toml-config/src/config/parsers/config.rs index ed3b1e70..f5aab054 100644 --- a/crates/toml-config/src/config/parsers/config.rs +++ b/crates/toml-config/src/config/parsers/config.rs @@ -154,10 +154,10 @@ impl Parser for ConfigParser<'_> { show_titles, fallback_output_mode_val, clean_logs_older_than_val, - mouse_follows_focus, + unstable_mouse_follows_focus, animations_val, ), - (scratchpads_val, autotile), + (scratchpads_val, autotile, mouse_follows_focus), ) = ext.extract(( ( opt(val("keymap")), @@ -219,7 +219,11 @@ impl Parser for ConfigParser<'_> { recover(opt(bol("unstable-mouse-follows-focus"))), opt(val("animations")), ), - (opt(val("scratchpads")), recover(opt(bol("autotile")))), + ( + opt(val("scratchpads")), + recover(opt(bol("autotile"))), + recover(opt(bol("mouse-follows-focus"))), + ), ))?; let mut keymap = None; if let Some(value) = keymap_val { @@ -633,7 +637,10 @@ impl Parser for ConfigParser<'_> { workspace_display_order, simple_im, fallback_output_mode, - mouse_follows_focus: mouse_follows_focus.despan(), + mouse_follows_focus: mouse_follows_focus + .despan() + .or_else(|| unstable_mouse_follows_focus.despan()) + .or(Some(true)), scratchpads, autotile: autotile.despan(), }) diff --git a/crates/toml-config/src/lib.rs b/crates/toml-config/src/lib.rs index 33bc3343..42c1f04f 100644 --- a/crates/toml-config/src/lib.rs +++ b/crates/toml-config/src/lib.rs @@ -1849,10 +1849,7 @@ fn load_config(initial_load: bool, auto_reload: bool, persistent: &Rc