diff --git a/src/input/mod.rs b/src/input/mod.rs index 68def8a2..a4be54b7 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -814,6 +814,12 @@ impl State { .drain() .map(|(_, bind)| bind), ); + binds.extend( + self.niri + .pending_tablet_release_binds + .drain() + .map(|(_, bind)| bind), + ); // Forget the rest of the input state: the releases will never arrive. self.niri.clear_input_state(); @@ -4034,6 +4040,15 @@ impl State { _ => None, }; + // Handle release binds. + if button_state == ButtonState::Released { + if let Some(bind) = self.niri.pending_tablet_release_binds.remove(&button) { + self.niri.suppressed_buttons.remove(&button); + self.handle_bind(bind, false); + return; + } + } + if self.niri.suppressed_buttons.remove(&button) { return; } @@ -4051,6 +4066,15 @@ impl State { if self.niri.mods_with_tablet_stylus_binds.contains(&modifiers) { if let Some(bind) = self.find_pointer_bind(mod_key, trigger, mods) { self.niri.suppressed_buttons.insert(button); + if should_record_release_bind( + &bind, + self.niri.is_locked(), + &self.niri.bind_cooldown_timers, + ) { + self.niri + .pending_tablet_release_binds + .insert(button, bind.clone()); + } if bind.has_press() { self.handle_bind(bind.clone(), true); } @@ -4666,6 +4690,7 @@ impl Niri { fn cancel_interrupted_release_binds(&mut self) { retain_press_binds(&mut self.pending_release_binds); retain_press_binds(&mut self.pending_mouse_release_binds); + retain_press_binds(&mut self.pending_tablet_release_binds); } } diff --git a/src/niri.rs b/src/niri.rs index b36bd499..e5d7ba9a 100644 --- a/src/niri.rs +++ b/src/niri.rs @@ -363,6 +363,8 @@ pub struct Niri { pub pending_release_binds: HashMap, /// Same as `pending_release_binds`, but for mouse buttons, keyed by the button code. pub pending_mouse_release_binds: HashMap, + /// Same as `pending_release_binds`, but for tablet tool buttons, keyed by the button code. + pub pending_tablet_release_binds: HashMap, pub bind_cooldown_timers: HashMap, pub bind_repeat_timer: Option, pub keyboard_focus: KeyboardFocus, @@ -2843,6 +2845,7 @@ impl Niri { suppressed_buttons: HashSet::new(), pending_release_binds: HashMap::new(), pending_mouse_release_binds: HashMap::new(), + pending_tablet_release_binds: HashMap::new(), bind_cooldown_timers: HashMap::new(), bind_repeat_timer: Option::default(), presentation_state, @@ -6601,6 +6604,7 @@ impl Niri { self.suppressed_buttons.clear(); self.pending_release_binds.clear(); self.pending_mouse_release_binds.clear(); + self.pending_tablet_release_binds.clear(); // Stop ongoing key repeat if any. if let Some(token) = self.bind_repeat_timer.take() {