forge
Explore
Log in

Don't you dare go Hollow

input: support release actions on tablet stylus buttons

Browse files at this commit

eb9e029708f4b27f96248f334e40f1ee69703c6eJustin SpeddingParent: ab05d6d
src/input/mod.rsmodified+25 -0
@@ -814,6 +814,12 @@ impl State {
814814 .drain()
815815 .map(|(_, bind)| bind),
816816 );
817+ binds.extend(
818+ self.niri
819+ .pending_tablet_release_binds
820+ .drain()
821+ .map(|(_, bind)| bind),
822+ );
817823
818824 // Forget the rest of the input state: the releases will never arrive.
819825 self.niri.clear_input_state();
@@ -4034,6 +4040,15 @@ impl State {
40344040 _ => None,
40354041 };
40364042
4043+ // Handle release binds.
4044+ if button_state == ButtonState::Released {
4045+ if let Some(bind) = self.niri.pending_tablet_release_binds.remove(&button) {
4046+ self.niri.suppressed_buttons.remove(&button);
4047+ self.handle_bind(bind, false);
4048+ return;
4049+ }
4050+ }
4051+
40374052 if self.niri.suppressed_buttons.remove(&button) {
40384053 return;
40394054 }
@@ -4051,6 +4066,15 @@ impl State {
40514066 if self.niri.mods_with_tablet_stylus_binds.contains(&modifiers) {
40524067 if let Some(bind) = self.find_pointer_bind(mod_key, trigger, mods) {
40534068 self.niri.suppressed_buttons.insert(button);
4069+ if should_record_release_bind(
4070+ &bind,
4071+ self.niri.is_locked(),
4072+ &self.niri.bind_cooldown_timers,
4073+ ) {
4074+ self.niri
4075+ .pending_tablet_release_binds
4076+ .insert(button, bind.clone());
4077+ }
40544078 if bind.has_press() {
40554079 self.handle_bind(bind.clone(), true);
40564080 }
@@ -4666,6 +4690,7 @@ impl Niri {
46664690 fn cancel_interrupted_release_binds(&mut self) {
46674691 retain_press_binds(&mut self.pending_release_binds);
46684692 retain_press_binds(&mut self.pending_mouse_release_binds);
4693+ retain_press_binds(&mut self.pending_tablet_release_binds);
46694694 }
46704695 }
46714696
src/niri.rsmodified+4 -0
@@ -363,6 +363,8 @@ pub struct Niri {
363363 pub pending_release_binds: HashMap<Keycode, Bind>,
364364 /// Same as `pending_release_binds`, but for mouse buttons, keyed by the button code.
365365 pub pending_mouse_release_binds: HashMap<u32, Bind>,
366+ /// Same as `pending_release_binds`, but for tablet tool buttons, keyed by the button code.
367+ pub pending_tablet_release_binds: HashMap<u32, Bind>,
366368 pub bind_cooldown_timers: HashMap<Key, RegistrationToken>,
367369 pub bind_repeat_timer: Option<RegistrationToken>,
368370 pub keyboard_focus: KeyboardFocus,
@@ -2843,6 +2845,7 @@ impl Niri {
28432845 suppressed_buttons: HashSet::new(),
28442846 pending_release_binds: HashMap::new(),
28452847 pending_mouse_release_binds: HashMap::new(),
2848+ pending_tablet_release_binds: HashMap::new(),
28462849 bind_cooldown_timers: HashMap::new(),
28472850 bind_repeat_timer: Option::default(),
28482851 presentation_state,
@@ -6601,6 +6604,7 @@ impl Niri {
66016604 self.suppressed_buttons.clear();
66026605 self.pending_release_binds.clear();
66036606 self.pending_mouse_release_binds.clear();
6607+ self.pending_tablet_release_binds.clear();
66046608
66056609 // Stop ongoing key repeat if any.
66066610 if let Some(token) = self.bind_repeat_timer.take() {