mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-22 02:01:55 +07:00
Rename surface_under_and_global_space() to contents_under()
This commit is contained in:
+7
-7
@@ -1410,7 +1410,7 @@ impl State {
|
|||||||
self.niri.screenshot_ui.pointer_motion(point);
|
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.
|
// Handle confined pointer.
|
||||||
if let Some((focus_surface, region)) = pointer_confined {
|
if let Some((focus_surface, region)) = pointer_confined {
|
||||||
@@ -1509,7 +1509,7 @@ impl State {
|
|||||||
self.niri.screenshot_ui.pointer_motion(point);
|
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);
|
self.niri.handle_focus_follows_mouse(&under);
|
||||||
|
|
||||||
@@ -1929,7 +1929,7 @@ impl State {
|
|||||||
return;
|
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_seat = self.niri.seat.tablet_seat();
|
||||||
let tablet = tablet_seat.get_tablet(&TabletDescriptor::from(&event.device()));
|
let tablet = tablet_seat.get_tablet(&TabletDescriptor::from(&event.device()));
|
||||||
@@ -1981,7 +1981,7 @@ impl State {
|
|||||||
tool.tip_down(serial, event.time_msec());
|
tool.tip_down(serial, event.time_msec());
|
||||||
|
|
||||||
if let Some(pos) = self.niri.tablet_cursor_location {
|
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 {
|
if let Some(window) = under.window {
|
||||||
self.niri.layout.activate_window(&window);
|
self.niri.layout.activate_window(&window);
|
||||||
|
|
||||||
@@ -2011,7 +2011,7 @@ impl State {
|
|||||||
return;
|
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_seat = self.niri.seat.tablet_seat();
|
||||||
let display_handle = self.niri.display_handle.clone();
|
let display_handle = self.niri.display_handle.clone();
|
||||||
@@ -2340,7 +2340,7 @@ impl State {
|
|||||||
return;
|
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 !handle.is_grabbed() {
|
||||||
if let Some(window) = under.window {
|
if let Some(window) = under.window {
|
||||||
@@ -2393,7 +2393,7 @@ impl State {
|
|||||||
let Some(touch_location) = self.compute_touch_location(&evt) else {
|
let Some(touch_location) = self.compute_touch_location(&evt) else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let under = self.niri.surface_under_and_global_space(touch_location);
|
let under = self.niri.contents_under(touch_location);
|
||||||
handle.motion(
|
handle.motion(
|
||||||
self,
|
self,
|
||||||
under.surface,
|
under.surface,
|
||||||
|
|||||||
+18
-17
@@ -262,7 +262,7 @@ pub struct Niri {
|
|||||||
pub cursor_texture_cache: CursorTextureCache,
|
pub cursor_texture_cache: CursorTextureCache,
|
||||||
pub cursor_shape_manager_state: CursorShapeManagerState,
|
pub cursor_shape_manager_state: CursorShapeManagerState,
|
||||||
pub dnd_icon: Option<DndIcon>,
|
pub dnd_icon: Option<DndIcon>,
|
||||||
pub pointer_focus: PointerFocus,
|
pub pointer_focus: PointContents,
|
||||||
/// Whether the pointer is hidden, for example due to a previous touch input.
|
/// 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
|
/// 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)]
|
#[derive(Default, Clone, PartialEq)]
|
||||||
pub struct PointerFocus {
|
pub struct PointContents {
|
||||||
// Output under pointer.
|
// Output under point.
|
||||||
pub output: Option<Output>,
|
pub output: Option<Output>,
|
||||||
// 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<f64, Logical>)>,
|
pub surface: Option<(WlSurface, Point<f64, Logical>)>,
|
||||||
// If surface belongs to a window, this is that window.
|
// If surface belongs to a window, this is that window.
|
||||||
pub window: Option<Window>,
|
pub window: Option<Window>,
|
||||||
@@ -574,7 +574,7 @@ impl State {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn move_cursor(&mut self, location: Point<f64, Logical>) {
|
pub fn move_cursor(&mut self, location: Point<f64, Logical>) {
|
||||||
let under = self.niri.surface_under_and_global_space(location);
|
let under = self.niri.contents_under(location);
|
||||||
self.niri
|
self.niri
|
||||||
.maybe_activate_pointer_constraint(location, &under);
|
.maybe_activate_pointer_constraint(location, &under);
|
||||||
self.niri.pointer_focus.clone_from(&under);
|
self.niri.pointer_focus.clone_from(&under);
|
||||||
@@ -707,9 +707,9 @@ impl State {
|
|||||||
let pointer = &self.niri.seat.get_pointer().unwrap();
|
let pointer = &self.niri.seat.get_pointer().unwrap();
|
||||||
let location = pointer.current_location();
|
let location = pointer.current_location();
|
||||||
let under = if self.niri.pointer_hidden {
|
let under = if self.niri.pointer_hidden {
|
||||||
PointerFocus::default()
|
PointContents::default()
|
||||||
} else {
|
} 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
|
// 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_texture_cache: Default::default(),
|
||||||
cursor_shape_manager_state,
|
cursor_shape_manager_state,
|
||||||
dnd_icon: None,
|
dnd_icon: None,
|
||||||
pointer_focus: PointerFocus::default(),
|
pointer_focus: PointContents::default(),
|
||||||
pointer_hidden: false,
|
pointer_hidden: false,
|
||||||
pointer_inactivity_timer: None,
|
pointer_inactivity_timer: None,
|
||||||
pointer_grab_ongoing: false,
|
pointer_grab_ongoing: false,
|
||||||
@@ -2308,13 +2308,14 @@ impl Niri {
|
|||||||
self.window_under(pos)
|
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
|
/// We don't have a proper global space for all windows, so this function converts window
|
||||||
/// global space. We don't have a global space for all windows, but this function converts the
|
/// locations to global space according to where they are rendered.
|
||||||
/// window location temporarily to the current global space.
|
///
|
||||||
pub fn surface_under_and_global_space(&mut self, pos: Point<f64, Logical>) -> PointerFocus {
|
/// This function does not take pointer or touch grabs into account.
|
||||||
let mut rv = PointerFocus::default();
|
pub fn contents_under(&mut self, pos: Point<f64, Logical>) -> PointContents {
|
||||||
|
let mut rv = PointContents::default();
|
||||||
|
|
||||||
let Some((output, pos_within_output)) = self.output_under(pos) else {
|
let Some((output, pos_within_output)) = self.output_under(pos) else {
|
||||||
return rv;
|
return rv;
|
||||||
@@ -4502,7 +4503,7 @@ impl Niri {
|
|||||||
pub fn maybe_activate_pointer_constraint(
|
pub fn maybe_activate_pointer_constraint(
|
||||||
&self,
|
&self,
|
||||||
new_pos: Point<f64, Logical>,
|
new_pos: Point<f64, Logical>,
|
||||||
new_under: &PointerFocus,
|
new_under: &PointContents,
|
||||||
) {
|
) {
|
||||||
let Some((surface, surface_loc)) = &new_under.surface else {
|
let Some((surface, surface_loc)) = &new_under.surface else {
|
||||||
return;
|
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 {
|
let Some(ffm) = self.config.borrow().input.focus_follows_mouse else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
@@ -4604,7 +4605,7 @@ impl Niri {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Recompute the current pointer focus because we don't update it during animations.
|
// 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 let Some(output) = &new_focus.output {
|
||||||
if current_focus.output.as_ref() != Some(output) {
|
if current_focus.output.as_ref() != Some(output) {
|
||||||
|
|||||||
Reference in New Issue
Block a user