From 69e3edb5a3a97cc77eaf4df77590166c463e4373 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Sun, 3 Nov 2024 08:50:17 +0300 Subject: Rename surface_under_and_global_space() to contents_under() --- src/input/mod.rs | 14 +++++++------- src/niri.rs | 35 ++++++++++++++++++----------------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/input/mod.rs b/src/input/mod.rs index 315e5dfd..167c43cc 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -1410,7 +1410,7 @@ impl State { self.niri.screenshot_ui.pointer_motion(point); } - let under = self.niri.surface_under_and_global_space(new_pos); + let under = self.niri.contents_under(new_pos); // Handle confined pointer. if let Some((focus_surface, region)) = pointer_confined { @@ -1509,7 +1509,7 @@ impl State { self.niri.screenshot_ui.pointer_motion(point); } - let under = self.niri.surface_under_and_global_space(pos); + let under = self.niri.contents_under(pos); self.niri.handle_focus_follows_mouse(&under); @@ -1929,7 +1929,7 @@ impl State { return; }; - let under = self.niri.surface_under_and_global_space(pos); + let under = self.niri.contents_under(pos); let tablet_seat = self.niri.seat.tablet_seat(); let tablet = tablet_seat.get_tablet(&TabletDescriptor::from(&event.device())); @@ -1981,7 +1981,7 @@ impl State { tool.tip_down(serial, event.time_msec()); if let Some(pos) = self.niri.tablet_cursor_location { - let under = self.niri.surface_under_and_global_space(pos); + let under = self.niri.contents_under(pos); if let Some(window) = under.window { self.niri.layout.activate_window(&window); @@ -2011,7 +2011,7 @@ impl State { return; }; - let under = self.niri.surface_under_and_global_space(pos); + let under = self.niri.contents_under(pos); let tablet_seat = self.niri.seat.tablet_seat(); let display_handle = self.niri.display_handle.clone(); @@ -2340,7 +2340,7 @@ impl State { return; }; - let under = self.niri.surface_under_and_global_space(touch_location); + let under = self.niri.contents_under(touch_location); if !handle.is_grabbed() { if let Some(window) = under.window { @@ -2393,7 +2393,7 @@ impl State { let Some(touch_location) = self.compute_touch_location(&evt) else { return; }; - let under = self.niri.surface_under_and_global_space(touch_location); + let under = self.niri.contents_under(touch_location); handle.motion( self, under.surface, diff --git a/src/niri.rs b/src/niri.rs index b422309e..161933f7 100644 --- a/src/niri.rs +++ b/src/niri.rs @@ -262,7 +262,7 @@ pub struct Niri { pub cursor_texture_cache: CursorTextureCache, pub cursor_shape_manager_state: CursorShapeManagerState, pub dnd_icon: Option, - pub pointer_focus: PointerFocus, + pub pointer_focus: PointContents, /// Whether the pointer is hidden, for example due to a previous touch input. /// /// When this happens, the pointer also loses any focus. This is so that touch can prevent @@ -386,10 +386,10 @@ pub enum KeyboardFocus { } #[derive(Default, Clone, PartialEq)] -pub struct PointerFocus { - // Output under pointer. +pub struct PointContents { + // Output under point. pub output: Option, - // Surface under pointer and its location in global coordinate space. + // Surface under point and its location in the global coordinate space. pub surface: Option<(WlSurface, Point)>, // If surface belongs to a window, this is that window. pub window: Option, @@ -574,7 +574,7 @@ impl State { } pub fn move_cursor(&mut self, location: Point) { - let under = self.niri.surface_under_and_global_space(location); + let under = self.niri.contents_under(location); self.niri .maybe_activate_pointer_constraint(location, &under); self.niri.pointer_focus.clone_from(&under); @@ -707,9 +707,9 @@ impl State { let pointer = &self.niri.seat.get_pointer().unwrap(); let location = pointer.current_location(); let under = if self.niri.pointer_hidden { - PointerFocus::default() + PointContents::default() } else { - self.niri.surface_under_and_global_space(location) + self.niri.contents_under(location) }; // We're not changing the global cursor location here, so if the focus did not change, then @@ -1858,7 +1858,7 @@ impl Niri { cursor_texture_cache: Default::default(), cursor_shape_manager_state, dnd_icon: None, - pointer_focus: PointerFocus::default(), + pointer_focus: PointContents::default(), pointer_hidden: false, pointer_inactivity_timer: None, pointer_grab_ongoing: false, @@ -2308,13 +2308,14 @@ impl Niri { self.window_under(pos) } - /// Returns the surface under cursor and its position in the global space. + /// Returns contents under the given point. /// - /// Pointer needs location in global space, and focused window location compatible with that - /// global space. We don't have a global space for all windows, but this function converts the - /// window location temporarily to the current global space. - pub fn surface_under_and_global_space(&mut self, pos: Point) -> PointerFocus { - let mut rv = PointerFocus::default(); + /// We don't have a proper global space for all windows, so this function converts window + /// locations to global space according to where they are rendered. + /// + /// This function does not take pointer or touch grabs into account. + pub fn contents_under(&mut self, pos: Point) -> PointContents { + let mut rv = PointContents::default(); let Some((output, pos_within_output)) = self.output_under(pos) else { return rv; @@ -4502,7 +4503,7 @@ impl Niri { pub fn maybe_activate_pointer_constraint( &self, new_pos: Point, - new_under: &PointerFocus, + new_under: &PointContents, ) { let Some((surface, surface_loc)) = &new_under.surface else { return; @@ -4593,7 +4594,7 @@ impl Niri { } } - pub fn handle_focus_follows_mouse(&mut self, new_focus: &PointerFocus) { + pub fn handle_focus_follows_mouse(&mut self, new_focus: &PointContents) { let Some(ffm) = self.config.borrow().input.focus_follows_mouse else { return; }; @@ -4604,7 +4605,7 @@ impl Niri { } // Recompute the current pointer focus because we don't update it during animations. - let current_focus = self.surface_under_and_global_space(pointer.current_location()); + let current_focus = self.contents_under(pointer.current_location()); if let Some(output) = &new_focus.output { if current_focus.output.as_ref() != Some(output) { -- cgit