diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-03-18 18:17:04 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-03-18 19:32:03 +0400 |
| commit | df9d721f7462a7edaacb9de4530580a68ab6e8ab (patch) | |
| tree | 1ed2c1a905253bba7f49d433592e1ebf4be4193d /src | |
| parent | d970abead82abab8ac2596662bc4d8e41a53e003 (diff) | |
| download | niri-df9d721f7462a7edaacb9de4530580a68ab6e8ab.tar.gz niri-df9d721f7462a7edaacb9de4530580a68ab6e8ab.tar.bz2 niri-df9d721f7462a7edaacb9de4530580a68ab6e8ab.zip | |
Implement focus-follows-mouse
Diffstat (limited to 'src')
| -rw-r--r-- | src/input.rs | 5 | ||||
| -rw-r--r-- | src/niri.rs | 22 |
2 files changed, 27 insertions, 0 deletions
diff --git a/src/input.rs b/src/input.rs index c7a0e264..1d99f550 100644 --- a/src/input.rs +++ b/src/input.rs @@ -903,6 +903,8 @@ impl State { } } + self.niri.handle_focus_follows_mouse(&under); + // Activate a new confinement if necessary. self.niri.maybe_activate_pointer_constraint(new_pos, &under); @@ -967,6 +969,9 @@ impl State { } let under = self.niri.surface_under_and_global_space(pos); + + self.niri.handle_focus_follows_mouse(&under); + self.niri.maybe_activate_pointer_constraint(pos, &under); self.niri.pointer_focus.clone_from(&under); diff --git a/src/niri.rs b/src/niri.rs index ef369e35..f63f05a3 100644 --- a/src/niri.rs +++ b/src/niri.rs @@ -3305,6 +3305,28 @@ impl Niri { warn!("error spawning a thread to send MonitorsChanged: {err:?}"); } } + + pub fn handle_focus_follows_mouse(&mut self, new_focus: &PointerFocus) { + if !self.config.borrow().input.focus_follows_mouse { + return; + } + + if self.seat.get_pointer().unwrap().is_grabbed() { + return; + } + + if let Some(output) = &new_focus.output { + if self.pointer_focus.output.as_ref() != Some(output) { + self.layout.focus_output(output); + } + } + + if let Some(window) = &new_focus.window { + if self.pointer_focus.window.as_ref() != Some(window) { + self.layout.activate_window(window); + } + } + } } pub struct ClientState { |
