Rename surface_under_and_global_space() to contents_under()
Browse files at this commit69e3edb5a3a97cc77eaf4df77590166c463e4373Parent: d58bb4e2 changed files +25 -24
- src/input/mod.rs +7 -7
- src/niri.rs +18 -17
src/input/mod.rsmodified+7 -7
| @@ -1410,7 +1410,7 @@ impl State { | |||
| 1410 | self.niri.screenshot_ui.pointer_motion(point); | 1410 | self.niri.screenshot_ui.pointer_motion(point); |
| 1411 | } | 1411 | } |
| 1412 | 1412 | ||
| 1413 | - let under = self.niri.surface_under_and_global_space(new_pos); | 1413 | + let under = self.niri.contents_under(new_pos); |
| 1414 | 1414 | ||
| 1415 | // Handle confined pointer. | 1415 | // Handle confined pointer. |
| 1416 | if let Some((focus_surface, region)) = pointer_confined { | 1416 | if let Some((focus_surface, region)) = pointer_confined { |
| @@ -1509,7 +1509,7 @@ impl State { | |||
| 1509 | self.niri.screenshot_ui.pointer_motion(point); | 1509 | self.niri.screenshot_ui.pointer_motion(point); |
| 1510 | } | 1510 | } |
| 1511 | 1511 | ||
| 1512 | - let under = self.niri.surface_under_and_global_space(pos); | 1512 | + let under = self.niri.contents_under(pos); |
| 1513 | 1513 | ||
| 1514 | self.niri.handle_focus_follows_mouse(&under); | 1514 | self.niri.handle_focus_follows_mouse(&under); |
| 1515 | 1515 | ||
| @@ -1929,7 +1929,7 @@ impl State { | |||
| 1929 | return; | 1929 | return; |
| 1930 | }; | 1930 | }; |
| 1931 | 1931 | ||
| 1932 | - let under = self.niri.surface_under_and_global_space(pos); | 1932 | + let under = self.niri.contents_under(pos); |
| 1933 | 1933 | ||
| 1934 | let tablet_seat = self.niri.seat.tablet_seat(); | 1934 | let tablet_seat = self.niri.seat.tablet_seat(); |
| 1935 | let tablet = tablet_seat.get_tablet(&TabletDescriptor::from(&event.device())); | 1935 | let tablet = tablet_seat.get_tablet(&TabletDescriptor::from(&event.device())); |
| @@ -1981,7 +1981,7 @@ impl State { | |||
| 1981 | tool.tip_down(serial, event.time_msec()); | 1981 | tool.tip_down(serial, event.time_msec()); |
| 1982 | 1982 | ||
| 1983 | if let Some(pos) = self.niri.tablet_cursor_location { | 1983 | if let Some(pos) = self.niri.tablet_cursor_location { |
| 1984 | - let under = self.niri.surface_under_and_global_space(pos); | 1984 | + let under = self.niri.contents_under(pos); |
| 1985 | if let Some(window) = under.window { | 1985 | if let Some(window) = under.window { |
| 1986 | self.niri.layout.activate_window(&window); | 1986 | self.niri.layout.activate_window(&window); |
| 1987 | 1987 | ||
| @@ -2011,7 +2011,7 @@ impl State { | |||
| 2011 | return; | 2011 | return; |
| 2012 | }; | 2012 | }; |
| 2013 | 2013 | ||
| 2014 | - let under = self.niri.surface_under_and_global_space(pos); | 2014 | + let under = self.niri.contents_under(pos); |
| 2015 | 2015 | ||
| 2016 | let tablet_seat = self.niri.seat.tablet_seat(); | 2016 | let tablet_seat = self.niri.seat.tablet_seat(); |
| 2017 | let display_handle = self.niri.display_handle.clone(); | 2017 | let display_handle = self.niri.display_handle.clone(); |
| @@ -2340,7 +2340,7 @@ impl State { | |||
| 2340 | return; | 2340 | return; |
| 2341 | }; | 2341 | }; |
| 2342 | 2342 | ||
| 2343 | - let under = self.niri.surface_under_and_global_space(touch_location); | 2343 | + let under = self.niri.contents_under(touch_location); |
| 2344 | 2344 | ||
| 2345 | if !handle.is_grabbed() { | 2345 | if !handle.is_grabbed() { |
| 2346 | if let Some(window) = under.window { | 2346 | if let Some(window) = under.window { |
| @@ -2393,7 +2393,7 @@ impl State { | |||
| 2393 | let Some(touch_location) = self.compute_touch_location(&evt) else { | 2393 | let Some(touch_location) = self.compute_touch_location(&evt) else { |
| 2394 | return; | 2394 | return; |
| 2395 | }; | 2395 | }; |
| 2396 | - let under = self.niri.surface_under_and_global_space(touch_location); | 2396 | + let under = self.niri.contents_under(touch_location); |
| 2397 | handle.motion( | 2397 | handle.motion( |
| 2398 | self, | 2398 | self, |
| 2399 | under.surface, | 2399 | under.surface, |
src/niri.rsmodified+18 -17
| @@ -262,7 +262,7 @@ pub struct Niri { | |||
| 262 | pub cursor_texture_cache: CursorTextureCache, | 262 | pub cursor_texture_cache: CursorTextureCache, |
| 263 | pub cursor_shape_manager_state: CursorShapeManagerState, | 263 | pub cursor_shape_manager_state: CursorShapeManagerState, |
| 264 | pub dnd_icon: Option<DndIcon>, | 264 | pub dnd_icon: Option<DndIcon>, |
| 265 | - pub pointer_focus: PointerFocus, | 265 | + pub pointer_focus: PointContents, |
| 266 | /// Whether the pointer is hidden, for example due to a previous touch input. | 266 | /// Whether the pointer is hidden, for example due to a previous touch input. |
| 267 | /// | 267 | /// |
| 268 | /// When this happens, the pointer also loses any focus. This is so that touch can prevent | 268 | /// When this happens, the pointer also loses any focus. This is so that touch can prevent |
| @@ -386,10 +386,10 @@ pub enum KeyboardFocus { | |||
| 386 | } | 386 | } |
| 387 | 387 | ||
| 388 | #[derive(Default, Clone, PartialEq)] | 388 | #[derive(Default, Clone, PartialEq)] |
| 389 | -pub struct PointerFocus { | 389 | +pub struct PointContents { |
| 390 | - // Output under pointer. | 390 | + // Output under point. |
| 391 | pub output: Option<Output>, | 391 | pub output: Option<Output>, |
| 392 | - // Surface under pointer and its location in global coordinate space. | 392 | + // Surface under point and its location in the global coordinate space. |
| 393 | pub surface: Option<(WlSurface, Point<f64, Logical>)>, | 393 | pub surface: Option<(WlSurface, Point<f64, Logical>)>, |
| 394 | // If surface belongs to a window, this is that window. | 394 | // If surface belongs to a window, this is that window. |
| 395 | pub window: Option<Window>, | 395 | pub window: Option<Window>, |
| @@ -574,7 +574,7 @@ impl State { | |||
| 574 | } | 574 | } |
| 575 | 575 | ||
| 576 | pub fn move_cursor(&mut self, location: Point<f64, Logical>) { | 576 | pub fn move_cursor(&mut self, location: Point<f64, Logical>) { |
| 577 | - let under = self.niri.surface_under_and_global_space(location); | 577 | + let under = self.niri.contents_under(location); |
| 578 | self.niri | 578 | self.niri |
| 579 | .maybe_activate_pointer_constraint(location, &under); | 579 | .maybe_activate_pointer_constraint(location, &under); |
| 580 | self.niri.pointer_focus.clone_from(&under); | 580 | self.niri.pointer_focus.clone_from(&under); |
| @@ -707,9 +707,9 @@ impl State { | |||
| 707 | let pointer = &self.niri.seat.get_pointer().unwrap(); | 707 | let pointer = &self.niri.seat.get_pointer().unwrap(); |
| 708 | let location = pointer.current_location(); | 708 | let location = pointer.current_location(); |
| 709 | let under = if self.niri.pointer_hidden { | 709 | let under = if self.niri.pointer_hidden { |
| 710 | - PointerFocus::default() | 710 | + PointContents::default() |
| 711 | } else { | 711 | } else { |
| 712 | - self.niri.surface_under_and_global_space(location) | 712 | + self.niri.contents_under(location) |
| 713 | }; | 713 | }; |
| 714 | 714 | ||
| 715 | // We're not changing the global cursor location here, so if the focus did not change, then | 715 | // We're not changing the global cursor location here, so if the focus did not change, then |
| @@ -1858,7 +1858,7 @@ impl Niri { | |||
| 1858 | cursor_texture_cache: Default::default(), | 1858 | cursor_texture_cache: Default::default(), |
| 1859 | cursor_shape_manager_state, | 1859 | cursor_shape_manager_state, |
| 1860 | dnd_icon: None, | 1860 | dnd_icon: None, |
| 1861 | - pointer_focus: PointerFocus::default(), | 1861 | + pointer_focus: PointContents::default(), |
| 1862 | pointer_hidden: false, | 1862 | pointer_hidden: false, |
| 1863 | pointer_inactivity_timer: None, | 1863 | pointer_inactivity_timer: None, |
| 1864 | pointer_grab_ongoing: false, | 1864 | pointer_grab_ongoing: false, |
| @@ -2308,13 +2308,14 @@ impl Niri { | |||
| 2308 | self.window_under(pos) | 2308 | self.window_under(pos) |
| 2309 | } | 2309 | } |
| 2310 | 2310 | ||
| 2311 | - /// Returns the surface under cursor and its position in the global space. | 2311 | + /// Returns contents under the given point. |
| 2312 | /// | 2312 | /// |
| 2313 | - /// Pointer needs location in global space, and focused window location compatible with that | 2313 | + /// We don't have a proper global space for all windows, so this function converts window |
| 2314 | - /// global space. We don't have a global space for all windows, but this function converts the | 2314 | + /// locations to global space according to where they are rendered. |
| 2315 | - /// window location temporarily to the current global space. | 2315 | + /// |
| 2316 | - pub fn surface_under_and_global_space(&mut self, pos: Point<f64, Logical>) -> PointerFocus { | 2316 | + /// This function does not take pointer or touch grabs into account. |
| 2317 | - let mut rv = PointerFocus::default(); | 2317 | + pub fn contents_under(&mut self, pos: Point<f64, Logical>) -> PointContents { |
| 2318 | + let mut rv = PointContents::default(); | ||
| 2318 | 2319 | ||
| 2319 | let Some((output, pos_within_output)) = self.output_under(pos) else { | 2320 | let Some((output, pos_within_output)) = self.output_under(pos) else { |
| 2320 | return rv; | 2321 | return rv; |
| @@ -4502,7 +4503,7 @@ impl Niri { | |||
| 4502 | pub fn maybe_activate_pointer_constraint( | 4503 | pub fn maybe_activate_pointer_constraint( |
| 4503 | &self, | 4504 | &self, |
| 4504 | new_pos: Point<f64, Logical>, | 4505 | new_pos: Point<f64, Logical>, |
| 4505 | - new_under: &PointerFocus, | 4506 | + new_under: &PointContents, |
| 4506 | ) { | 4507 | ) { |
| 4507 | let Some((surface, surface_loc)) = &new_under.surface else { | 4508 | let Some((surface, surface_loc)) = &new_under.surface else { |
| 4508 | return; | 4509 | return; |
| @@ -4593,7 +4594,7 @@ impl Niri { | |||
| 4593 | } | 4594 | } |
| 4594 | } | 4595 | } |
| 4595 | 4596 | ||
| 4596 | - pub fn handle_focus_follows_mouse(&mut self, new_focus: &PointerFocus) { | 4597 | + pub fn handle_focus_follows_mouse(&mut self, new_focus: &PointContents) { |
| 4597 | let Some(ffm) = self.config.borrow().input.focus_follows_mouse else { | 4598 | let Some(ffm) = self.config.borrow().input.focus_follows_mouse else { |
| 4598 | return; | 4599 | return; |
| 4599 | }; | 4600 | }; |
| @@ -4604,7 +4605,7 @@ impl Niri { | |||
| 4604 | } | 4605 | } |
| 4605 | 4606 | ||
| 4606 | // Recompute the current pointer focus because we don't update it during animations. | 4607 | // Recompute the current pointer focus because we don't update it during animations. |
| 4607 | - let current_focus = self.surface_under_and_global_space(pointer.current_location()); | 4608 | + let current_focus = self.contents_under(pointer.current_location()); |
| 4608 | 4609 | ||
| 4609 | if let Some(output) = &new_focus.output { | 4610 | if let Some(output) = &new_focus.output { |
| 4610 | if current_focus.output.as_ref() != Some(output) { | 4611 | if current_focus.output.as_ref() != Some(output) { |