aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-04-02 08:44:29 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2024-04-06 10:57:12 -0700
commit83aec41df31100df0b0ab553ac9220d03bd01bba (patch)
tree99ffbe3853d7852e2cdea67c938ca6a6b223a979
parent8be938197486acb2af4ba91aae0fac57619a46c8 (diff)
downloadniri-83aec41df31100df0b0ab553ac9220d03bd01bba.tar.gz
niri-83aec41df31100df0b0ab553ac9220d03bd01bba.tar.bz2
niri-83aec41df31100df0b0ab553ac9220d03bd01bba.zip
Hide pointer on touch interaction
-rw-r--r--src/input.rs9
-rw-r--r--src/niri.rs24
2 files changed, 32 insertions, 1 deletions
diff --git a/src/input.rs b/src/input.rs
index f8b753b8..2fd03a64 100644
--- a/src/input.rs
+++ b/src/input.rs
@@ -822,6 +822,7 @@ impl State {
let mut new_pos = pos + event.delta();
// We received an event for the regular pointer, so show it now.
+ self.niri.pointer_hidden = false;
self.niri.tablet_cursor_location = None;
// Check if we have an active pointer constraint.
@@ -1035,6 +1036,9 @@ impl State {
pointer.frame(self);
+ // We moved the pointer, show it.
+ self.niri.pointer_hidden = false;
+
// We moved the regular pointer, so show it now.
self.niri.tablet_cursor_location = None;
@@ -1333,6 +1337,7 @@ impl State {
event.time_msec(),
);
+ self.niri.pointer_hidden = false;
self.niri.tablet_cursor_location = Some(pos);
}
@@ -1398,6 +1403,7 @@ impl State {
event.time_msec(),
);
}
+ self.niri.pointer_hidden = false;
self.niri.tablet_cursor_location = Some(pos);
}
ProximityState::Out => {
@@ -1735,6 +1741,9 @@ impl State {
time: evt.time_msec(),
},
);
+
+ // We're using touch, hide the pointer.
+ self.niri.pointer_hidden = true;
}
fn on_touch_up<I: InputBackend>(&mut self, evt: I::TouchUpEvent) {
let Some(handle) = self.niri.seat.get_touch() else {
diff --git a/src/niri.rs b/src/niri.rs
index 7c457a2f..036a5a83 100644
--- a/src/niri.rs
+++ b/src/niri.rs
@@ -207,6 +207,11 @@ pub struct Niri {
pub cursor_shape_manager_state: CursorShapeManagerState,
pub dnd_icon: Option<WlSurface>,
pub pointer_focus: PointerFocus,
+ /// 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
+ /// various tooltips from sticking around.
+ pub pointer_hidden: bool,
pub tablet_cursor_location: Option<Point<f64, Logical>>,
pub gesture_swipe_3f_cumulative: Option<(f64, f64)>,
pub vertical_wheel_tracker: ScrollTracker,
@@ -481,6 +486,10 @@ impl State {
},
);
pointer.frame(self);
+
+ // We moved the pointer, show it.
+ self.niri.pointer_hidden = false;
+
// FIXME: granular
self.niri.queue_redraw_all();
}
@@ -595,7 +604,11 @@ impl State {
let pointer = &self.niri.seat.get_pointer().unwrap();
let location = pointer.current_location();
- let under = self.niri.surface_under_and_global_space(location);
+ let under = if self.niri.pointer_hidden {
+ PointerFocus::default()
+ } else {
+ self.niri.surface_under_and_global_space(location)
+ };
// We're not changing the global cursor location here, so if the focus did not change, then
// nothing changed.
@@ -1371,6 +1384,7 @@ impl Niri {
cursor_shape_manager_state,
dnd_icon: None,
pointer_focus: PointerFocus::default(),
+ pointer_hidden: false,
tablet_cursor_location: None,
gesture_swipe_3f_cumulative: None,
vertical_wheel_tracker: ScrollTracker::new(120),
@@ -2023,6 +2037,10 @@ impl Niri {
renderer: &mut R,
output: &Output,
) -> Vec<OutputRenderElements<R>> {
+ if self.pointer_hidden {
+ return vec![];
+ }
+
let _span = tracy_client::span!("Niri::pointer_element");
let output_scale = output.current_scale();
let output_pos = self.global_space.output_geometry(output).unwrap().loc;
@@ -2106,6 +2124,10 @@ impl Niri {
}
pub fn refresh_pointer_outputs(&mut self) {
+ if self.pointer_hidden {
+ return;
+ }
+
let _span = tracy_client::span!("Niri::refresh_pointer_outputs");
// Check whether we need to draw the tablet cursor or the regular cursor.