From 0d048b1a8e65a48692027e619c52efc56894e568 Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Mon, 9 Sep 2024 20:12:10 +0200 Subject: [PATCH] input: Fix focus_follows_cursor across outputs --- src/input/mod.rs | 6 +++--- src/shell/mod.rs | 17 ++++++++--------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/input/mod.rs b/src/input/mod.rs index a804857b..449cf743 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -604,9 +604,9 @@ impl State { } else if self.common.config.cosmic_conf.focus_follows_cursor { let shell = self.common.shell.read().unwrap(); let old_keyboard_target = - shell.keyboard_target_from_position(original_position, &seat); + shell.keyboard_target_from_position(original_position, ¤t_output); let new_keyboard_target = - shell.keyboard_target_from_position(position, &seat); + shell.keyboard_target_from_position(position, &output); if old_keyboard_target != new_keyboard_target && new_keyboard_target.is_some() @@ -904,7 +904,7 @@ impl State { let global_position = seat.get_pointer().unwrap().current_location().as_global(); let shell = self.common.shell.write().unwrap(); - let under = shell.keyboard_target_from_position(global_position, &seat); + let under = shell.keyboard_target_from_position(global_position, &output); // Don't check override redirect windows, because we don't set keyboard focus to them explicitly. // These cases are handled by the XwaylandKeyboardGrab. if let Some(target) = shell.element_under(global_position, &output) { diff --git a/src/shell/mod.rs b/src/shell/mod.rs index 969ae4b4..cb6b4a2e 100644 --- a/src/shell/mod.rs +++ b/src/shell/mod.rs @@ -1423,21 +1423,20 @@ impl Shell { pub fn keyboard_target_from_position( &self, global_position: Point, - seat: &Seat, + output: &Output, ) -> Option { - let output = seat.active_output(); - let relative_pos = global_position.to_local(&output); + let relative_pos = global_position.to_local(output); let mut under: Option = None; // if the lockscreen is active if let Some(session_lock) = self.session_lock.as_ref() { under = session_lock .surfaces - .get(&output) + .get(output) .map(|lock| lock.clone().into()); // if the output can receive keyboard focus - } else if let Some(window) = self.active_space(&output).get_fullscreen() { - let layers = layer_map_for_output(&output); + } else if let Some(window) = self.active_space(output).get_fullscreen() { + let layers = layer_map_for_output(output); if let Some(layer) = layers.layer_under(WlrLayer::Overlay, relative_pos.as_logical()) { let layer_loc = layers.layer_geometry(layer).unwrap().loc; if layer.can_receive_keyboard_focus() @@ -1455,7 +1454,7 @@ impl Shell { } } else { let done = { - let layers = layer_map_for_output(&output); + let layers = layer_map_for_output(output); if let Some(layer) = layers .layer_under(WlrLayer::Overlay, relative_pos.as_logical()) .or_else(|| layers.layer_under(WlrLayer::Top, relative_pos.as_logical())) @@ -1481,10 +1480,10 @@ impl Shell { if !done { // Don't check override redirect windows, because we don't set keyboard focus to them explicitly. // These cases are handled by the XwaylandKeyboardGrab. - if let Some(target) = self.element_under(global_position, &output) { + if let Some(target) = self.element_under(global_position, output) { under = Some(target); } else { - let layers = layer_map_for_output(&output); + let layers = layer_map_for_output(output); if let Some(layer) = layers .layer_under(WlrLayer::Bottom, relative_pos.as_logical()) .or_else(|| {