aboutsummaryrefslogtreecommitdiff
path: root/src/input.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2023-12-05 10:24:41 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2023-12-05 10:24:41 +0400
commitcb1e5d6c192d58c33229c32e34628ecadf84c02f (patch)
treea5878bdfe02444386264d555037c242b102a87e1 /src/input.rs
parent11ae17b220dfb454c524fff800f97bc11c3a56dd (diff)
downloadniri-cb1e5d6c192d58c33229c32e34628ecadf84c02f.tar.gz
niri-cb1e5d6c192d58c33229c32e34628ecadf84c02f.tar.bz2
niri-cb1e5d6c192d58c33229c32e34628ecadf84c02f.zip
Track tablet pointer separately, don't sent wl_pointer events
Tablets are not supposed to send wl_pointer events. This unbreaks GTK 4 clients for example.
Diffstat (limited to 'src/input.rs')
-rw-r--r--src/input.rs85
1 files changed, 39 insertions, 46 deletions
diff --git a/src/input.rs b/src/input.rs
index a86045bd..cf2c59ba 100644
--- a/src/input.rs
+++ b/src/input.rs
@@ -439,6 +439,9 @@ impl State {
pointer.frame(self);
+ // We moved the regular pointer, so show it now.
+ self.niri.tablet_cursor_location = None;
+
// Redraw to update the cursor position.
// FIXME: redraw only outputs overlapping the cursor.
self.niri.queue_redraw_all();
@@ -487,6 +490,9 @@ impl State {
pointer.frame(self);
+ // We moved the regular pointer, so show it now.
+ self.niri.tablet_cursor_location = None;
+
// Redraw to update the cursor position.
// FIXME: redraw only outputs overlapping the cursor.
self.niri.queue_redraw_all();
@@ -596,25 +602,9 @@ impl State {
return;
};
- let serial = SERIAL_COUNTER.next_serial();
-
- let pointer = self.niri.seat.get_pointer().unwrap();
-
let under = self.niri.surface_under_and_global_space(pos);
- self.niri.pointer_focus = under.clone();
let under = under.map(|u| u.surface);
- pointer.motion(
- self,
- under.clone(),
- &MotionEvent {
- location: pos,
- serial,
- time: event.time_msec(),
- },
- );
- pointer.frame(self);
-
let tablet_seat = self.niri.seat.tablet_seat();
let tablet = tablet_seat.get_tablet(&TabletDescriptor::from(&event.device()));
let tool = tablet_seat.get_tool(&event.tool());
@@ -645,6 +635,8 @@ impl State {
SERIAL_COUNTER.next_serial(),
event.time_msec(),
);
+
+ self.niri.tablet_cursor_location = Some(pos);
}
// Redraw to update the cursor position.
@@ -660,15 +652,21 @@ impl State {
let serial = SERIAL_COUNTER.next_serial();
tool.tip_down(serial, event.time_msec());
- let pointer = self.niri.seat.get_pointer().unwrap();
- if !pointer.is_grabbed() {
- if let Some(window) = self.niri.window_under_cursor() {
+ if let Some(pos) = self.niri.tablet_cursor_location {
+ if let Some(window) = self.niri.window_under(pos) {
let window = window.clone();
self.niri.layout.activate_window(&window);
- } else if let Some(output) = self.niri.output_under_cursor() {
+
+ // FIXME: granular.
+ self.niri.queue_redraw_all();
+ } else if let Some((output, _)) = self.niri.output_under(pos) {
+ let output = output.clone();
self.niri.layout.activate_output(&output);
+
+ // FIXME: granular.
+ self.niri.queue_redraw_all();
}
- };
+ }
}
TabletToolTipState::Up => {
tool.tip_up(event.time_msec());
@@ -681,39 +679,34 @@ impl State {
return;
};
- let serial = SERIAL_COUNTER.next_serial();
-
- let pointer = self.niri.seat.get_pointer().unwrap();
-
let under = self.niri.surface_under_and_global_space(pos);
- self.niri.pointer_focus = under.clone();
let under = under.map(|u| u.surface);
- pointer.motion(
- self,
- under.clone(),
- &MotionEvent {
- location: pos,
- serial,
- time: event.time_msec(),
- },
- );
- pointer.frame(self);
-
let tablet_seat = self.niri.seat.tablet_seat();
let tool = tablet_seat.add_tool::<Self>(&self.niri.display_handle, &event.tool());
let tablet = tablet_seat.get_tablet(&TabletDescriptor::from(&event.device()));
- if let (Some(under), Some(tablet)) = (under, tablet) {
+ if let Some(tablet) = tablet {
match event.state() {
- ProximityState::In => tool.proximity_in(
- pos,
- under,
- &tablet,
- SERIAL_COUNTER.next_serial(),
- event.time_msec(),
- ),
- ProximityState::Out => tool.proximity_out(event.time_msec()),
+ ProximityState::In => {
+ if let Some(under) = under {
+ tool.proximity_in(
+ pos,
+ under,
+ &tablet,
+ SERIAL_COUNTER.next_serial(),
+ event.time_msec(),
+ );
+ }
+ self.niri.tablet_cursor_location = Some(pos);
+ }
+ ProximityState::Out => {
+ tool.proximity_out(event.time_msec());
+ self.niri.tablet_cursor_location = None;
+ }
}
+
+ // FIXME: granular.
+ self.niri.queue_redraw_all();
}
}
InputEvent::TabletToolButton { event, .. } => {