forge
Explore
Log in

Don't you dare go Hollow

Fix: handle axis updates in tablet tip events (#4521)

Browse files at this commit

d18b2016292e3a3065bd428168dede3e4efd164dUnverifiedDeSpecTDr and Ivan MolodetskikhParent: 24ba213
* Handle axis updates in tablet tip events

* Fix tablet focus and up/down event ordering

* Add comments

---------
src/input/mod.rsmodified+28 -4
@@ -3585,7 +3585,17 @@ impl State {
3585 where3585 where
3586 I::Device: 'static, // Needed for downcasting.3586 I::Device: 'static, // Needed for downcasting.
3587 {3587 {
3588- let Some(pos) = self.compute_tablet_position(&event) else {3588+ self.update_tablet_tool::<I>(&event, true);
3589+ }
3590+
3591+ fn update_tablet_tool<I: InputBackend>(
3592+ &mut self,
3593+ event: &(impl Event<I> + TabletToolEvent<I>),
3594+ send_frame: bool,
3595+ ) where
3596+ I::Device: 'static,
3597+ {
3598+ let Some(pos) = self.compute_tablet_position(event) else {
3589 return;3599 return;
3590 };3600 };
3591 3601
@@ -3623,7 +3633,6 @@ impl State {
3623 .wheel_has_changed()3633 .wheel_has_changed()
3624 .then(|| (event.wheel_delta(), event.wheel_delta_discrete())),3634 .then(|| (event.wheel_delta(), event.wheel_delta_discrete())),
3625 };3635 };
3626- tool.axis(self, frame);
3627 3636
3628 tool.motion(3637 tool.motion(
3629 self,3638 self,
@@ -3635,7 +3644,12 @@ impl State {
3635 },3644 },
3636 );3645 );
3637 3646
3638- tool.frame(self, time);3647+ // Set axis after motion to ensure it reaches the new focus surface.
3648+ tool.axis(self, frame);
3649+
3650+ if send_frame {
3651+ tool.frame(self, time);
3652+ }
3639 3653
3640 self.niri.pointer_visibility = PointerVisibility::Visible;3654 self.niri.pointer_visibility = PointerVisibility::Visible;
3641 self.niri.tablet_cursor_location = Some(pos);3655 self.niri.tablet_cursor_location = Some(pos);
@@ -3646,13 +3660,21 @@ impl State {
3646 self.niri.queue_redraw_all();3660 self.niri.queue_redraw_all();
3647 }3661 }
3648 3662
3649- fn on_tablet_tool_tip<I: InputBackend>(&mut self, event: I::TabletToolTipEvent) {3663+ fn on_tablet_tool_tip<I: InputBackend>(&mut self, event: I::TabletToolTipEvent)
3664+ where
3665+ I::Device: 'static,
3666+ {
3650 let tool = self.niri.seat.tablet_seat().get_tool(&event.tool());3667 let tool = self.niri.seat.tablet_seat().get_tool(&event.tool());
3651 3668
3652 let Some(tool) = tool else {3669 let Some(tool) = tool else {
3653 return;3670 return;
3654 };3671 };
3672+
3655 let tip_state = event.tip_state();3673 let tip_state = event.tip_state();
3674+ if tip_state == TabletToolTipState::Down {
3675+ // Tip events can come together with axis event data with no separate axis event.
3676+ self.update_tablet_tool::<I>(&event, false);
3677+ }
3656 3678
3657 let serial = SERIAL_COUNTER.next_serial();3679 let serial = SERIAL_COUNTER.next_serial();
3658 let time = event.time();3680 let time = event.time();
@@ -3786,6 +3808,8 @@ impl State {
3786 }3808 }
3787 3809
3788 tool.up(self, &tablet::tool::UpEvent { serial, time });3810 tool.up(self, &tablet::tool::UpEvent { serial, time });
3811+
3812+ self.update_tablet_tool::<I>(&event, false);
3789 }3813 }
3790 }3814 }
3791 3815