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 {
814 .drain()814 .drain()
815 .map(|(_, bind)| bind),815 .map(|(_, bind)| bind),
816 );816 );
817+ binds.extend(
818+ self.niri
819+ .pending_tablet_release_binds
820+ .drain()
821+ .map(|(_, bind)| bind),
822+ );
817 823
818 // Forget the rest of the input state: the releases will never arrive.824 // Forget the rest of the input state: the releases will never arrive.
819 self.niri.clear_input_state();825 self.niri.clear_input_state();
@@ -4034,6 +4040,15 @@ impl State {
4034 _ => None,4040 _ => None,
4035 };4041 };
4036 4042
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+
4037 if self.niri.suppressed_buttons.remove(&button) {4052 if self.niri.suppressed_buttons.remove(&button) {
4038 return;4053 return;
4039 }4054 }
@@ -4051,6 +4066,15 @@ impl State {
4051 if self.niri.mods_with_tablet_stylus_binds.contains(&modifiers) {4066 if self.niri.mods_with_tablet_stylus_binds.contains(&modifiers) {
4052 if let Some(bind) = self.find_pointer_bind(mod_key, trigger, mods) {4067 if let Some(bind) = self.find_pointer_bind(mod_key, trigger, mods) {
4053 self.niri.suppressed_buttons.insert(button);4068 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+ }
4054 if bind.has_press() {4078 if bind.has_press() {
4055 self.handle_bind(bind.clone(), true);4079 self.handle_bind(bind.clone(), true);
4056 }4080 }
@@ -4666,6 +4690,7 @@ impl Niri {
4666 fn cancel_interrupted_release_binds(&mut self) {4690 fn cancel_interrupted_release_binds(&mut self) {
4667 retain_press_binds(&mut self.pending_release_binds);4691 retain_press_binds(&mut self.pending_release_binds);
4668 retain_press_binds(&mut self.pending_mouse_release_binds);4692 retain_press_binds(&mut self.pending_mouse_release_binds);
4693+ retain_press_binds(&mut self.pending_tablet_release_binds);
4669 }4694 }
4670 }4695 }
4671 4696
src/niri.rsmodified+4 -0
@@ -363,6 +363,8 @@ pub struct Niri {
363 pub pending_release_binds: HashMap<Keycode, Bind>,363 pub pending_release_binds: HashMap<Keycode, Bind>,
364 /// Same as `pending_release_binds`, but for mouse buttons, keyed by the button code.364 /// Same as `pending_release_binds`, but for mouse buttons, keyed by the button code.
365 pub pending_mouse_release_binds: HashMap<u32, Bind>,365 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>,
366 pub bind_cooldown_timers: HashMap<Key, RegistrationToken>,368 pub bind_cooldown_timers: HashMap<Key, RegistrationToken>,
367 pub bind_repeat_timer: Option<RegistrationToken>,369 pub bind_repeat_timer: Option<RegistrationToken>,
368 pub keyboard_focus: KeyboardFocus,370 pub keyboard_focus: KeyboardFocus,
@@ -2843,6 +2845,7 @@ impl Niri {
2843 suppressed_buttons: HashSet::new(),2845 suppressed_buttons: HashSet::new(),
2844 pending_release_binds: HashMap::new(),2846 pending_release_binds: HashMap::new(),
2845 pending_mouse_release_binds: HashMap::new(),2847 pending_mouse_release_binds: HashMap::new(),
2848+ pending_tablet_release_binds: HashMap::new(),
2846 bind_cooldown_timers: HashMap::new(),2849 bind_cooldown_timers: HashMap::new(),
2847 bind_repeat_timer: Option::default(),2850 bind_repeat_timer: Option::default(),
2848 presentation_state,2851 presentation_state,
@@ -6601,6 +6604,7 @@ impl Niri {
6601 self.suppressed_buttons.clear();6604 self.suppressed_buttons.clear();
6602 self.pending_release_binds.clear();6605 self.pending_release_binds.clear();
6603 self.pending_mouse_release_binds.clear();6606 self.pending_mouse_release_binds.clear();
6607+ self.pending_tablet_release_binds.clear();
6604 6608
6605 // Stop ongoing key repeat if any.6609 // Stop ongoing key repeat if any.
6606 if let Some(token) = self.bind_repeat_timer.take() {6610 if let Some(token) = self.bind_repeat_timer.take() {