83 lines
3.5 KiB
Diff
83 lines
3.5 KiB
Diff
--- a/src/state.rs
|
|
+++ b/src/state.rs
|
|
@@ -724,6 +724,9 @@
|
|
// We store both the timer and the keysym used to trigger the key action.
|
|
// When we remove the keysym from suppressed keys we stop it.
|
|
pub repeated_keyaction_timer: Option<(RegistrationToken, Keysym)>,
|
|
+ // A modifier key that was pressed on its own, with no other key, button or scroll since.
|
|
+ // Keybinds on just a modifier key (e.g. `Super_L`) run when it's released in that state.
|
|
+ pub lone_modifier: Option<Keysym>,
|
|
// To focus a layer-surface with an OnDemand keyboard exclusivity mode, the user must click
|
|
// on the layer surface. Then, when we update the keyboard focus, we check against the clicked
|
|
// layer surface
|
|
@@ -962,6 +965,7 @@
|
|
clock,
|
|
suppressed_keys: HashMap::new(),
|
|
repeated_keyaction_timer: None,
|
|
+ lone_modifier: None,
|
|
seat,
|
|
devices: vec![],
|
|
seat_state,
|
|
--- a/src/input/mod.rs
|
|
+++ b/src/input/mod.rs
|
|
@@ -244,6 +244,7 @@
|
|
})
|
|
.map(|inhibitor| inhibitor.is_active())
|
|
.unwrap_or(false);
|
|
+ let mut lone_modifier_action = None;
|
|
let action = keyboard.input(
|
|
self,
|
|
keycode,
|
|
@@ -272,6 +273,20 @@
|
|
return FilterResult::Forward;
|
|
}
|
|
|
|
+ // Lone modifier taps. The key release is still forwarded to clients, and the
|
|
+ // action is run after the input is processed.
|
|
+ if let Some(raw) = raw {
|
|
+ if key_state == KeyState::Pressed {
|
|
+ state.fht.lone_modifier = raw.is_modifier_key().then_some(raw);
|
|
+ } else if state.fht.lone_modifier.take() == Some(raw) {
|
|
+ lone_modifier_action = find_keyaction(
|
|
+ &state.fht.config.keybinds,
|
|
+ &ModifiersState::default(),
|
|
+ raw,
|
|
+ );
|
|
+ }
|
|
+ }
|
|
+
|
|
// Handle repeating keybinds
|
|
// FIXME: handle this properly, this breaks if there are two repeating keybinds
|
|
if key_state == KeyState::Released {
|
|
@@ -331,6 +346,9 @@
|
|
if let Some((key_pattern, key_action)) = action {
|
|
self.process_key_action(key_action, key_pattern);
|
|
}
|
|
+ if let Some((key_pattern, key_action)) = lone_modifier_action {
|
|
+ self.process_key_action(key_action, key_pattern);
|
|
+ }
|
|
}
|
|
|
|
fn on_pointer_motion<B: InputBackend>(&mut self, event: B::PointerMotionEvent) {
|
|
@@ -505,6 +523,11 @@
|
|
let state = wl_pointer::ButtonState::from(event.state());
|
|
let pointer = self.fht.pointer.clone();
|
|
|
|
+ if state == wl_pointer::ButtonState::Pressed {
|
|
+ // e.g. Super+click shouldn't count as a lone Super tap
|
|
+ self.fht.lone_modifier = None;
|
|
+ }
|
|
+
|
|
if state == wl_pointer::ButtonState::Pressed && !pointer.is_grabbed() {
|
|
let pointer_loc = pointer.current_location();
|
|
let focus = self.fht.get_pointer_focus(pointer_loc);
|
|
@@ -555,6 +578,9 @@
|
|
}
|
|
|
|
fn on_pointer_axis<B: InputBackend>(&mut self, event: B::PointerAxisEvent) {
|
|
+ // e.g. Super+scroll shouldn't count as a lone Super tap
|
|
+ self.fht.lone_modifier = None;
|
|
+
|
|
let horizontal_amount_discrete = event.amount_v120(Axis::Horizontal);
|
|
let vertical_amount_discrete = event.amount_v120(Axis::Vertical);
|
|
let horizontal_amount = event
|