aboutsummaryrefslogtreecommitdiff
path: root/niri-config/src
diff options
context:
space:
mode:
authorsodiboo <37938646+sodiboo@users.noreply.github.com>2025-01-18 15:26:42 +0100
committerGitHub <noreply@github.com>2025-01-18 17:26:42 +0300
commit0584dd2f1e82417bdabcc0d8cb20fddc2e8cc5e7 (patch)
tree503168062d4b15245bdb1fdc940a7b3d748afa07 /niri-config/src
parentbd559a26602874f4104e342e2ce02317ae1ae605 (diff)
downloadniri-0584dd2f1e82417bdabcc0d8cb20fddc2e8cc5e7.tar.gz
niri-0584dd2f1e82417bdabcc0d8cb20fddc2e8cc5e7.tar.bz2
niri-0584dd2f1e82417bdabcc0d8cb20fddc2e8cc5e7.zip
implement `keyboard-shortcuts-inhibit` and `wlr-virtual-pointer` (#630)
* stub keyboard-shortcuts-inhibit and virtual-pointer impls * implement keyboard-shortcuts-inhibit * implement virtual-pointer * deal with supressed key release edge-case; add allow-inhibiting property * add toggle-keyboard-shortcuts-inhibit bind * add InputBackend extensions; use Device::output() for absolute pos events * add a `State` parameter to the backend exts and better document future intent * Add some tests for is_inhibiting_shortcuts --------- Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
Diffstat (limited to 'niri-config/src')
-rw-r--r--niri-config/src/lib.rs49
1 files changed, 48 insertions, 1 deletions
diff --git a/niri-config/src/lib.rs b/niri-config/src/lib.rs
index 167ef6ac..fae5129e 100644
--- a/niri-config/src/lib.rs
+++ b/niri-config/src/lib.rs
@@ -1191,6 +1191,7 @@ pub struct Bind {
pub repeat: bool,
pub cooldown: Option<Duration>,
pub allow_when_locked: bool,
+ pub allow_inhibiting: bool,
}
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
@@ -1278,6 +1279,7 @@ pub enum Action {
id: u64,
write_to_disk: bool,
},
+ ToggleKeyboardShortcutsInhibit,
CloseWindow,
#[knuffel(skip)]
CloseWindowById(u64),
@@ -3015,6 +3017,7 @@ where
let mut cooldown = None;
let mut allow_when_locked = false;
let mut allow_when_locked_node = None;
+ let mut allow_inhibiting = true;
for (name, val) in &node.properties {
match &***name {
"repeat" => {
@@ -3029,6 +3032,9 @@ where
allow_when_locked = knuffel::traits::DecodeScalar::decode(val, ctx)?;
allow_when_locked_node = Some(name);
}
+ "allow-inhibiting" => {
+ allow_inhibiting = knuffel::traits::DecodeScalar::decode(val, ctx)?;
+ }
name_str => {
ctx.emit_error(DecodeError::unexpected(
name,
@@ -3050,6 +3056,7 @@ where
repeat: true,
cooldown: None,
allow_when_locked: false,
+ allow_inhibiting: true,
};
if let Some(child) = children.next() {
@@ -3072,12 +3079,19 @@ where
}
}
+ // The toggle-inhibit action must always be uninhibitable.
+ // Otherwise, it would be impossible to trigger it.
+ if matches!(action, Action::ToggleKeyboardShortcutsInhibit) {
+ allow_inhibiting = false;
+ }
+
Ok(Self {
key,
action,
repeat,
cooldown,
allow_when_locked,
+ allow_inhibiting,
})
}
Err(e) => {
@@ -3463,6 +3477,8 @@ mod tests {
}
binds {
+ Mod+Escape { toggle-keyboard-shortcuts-inhibit; }
+ Mod+Shift+Escape allow-inhibiting=true { toggle-keyboard-shortcuts-inhibit; }
Mod+T allow-when-locked=true { spawn "alacritty"; }
Mod+Q { close-window; }
Mod+Shift+H { focus-monitor-left; }
@@ -3470,7 +3486,7 @@ mod tests {
Mod+Comma { consume-window-into-column; }
Mod+1 { focus-workspace 1; }
Mod+Shift+1 { focus-workspace "workspace-1"; }
- Mod+Shift+E { quit skip-confirmation=true; }
+ Mod+Shift+E allow-inhibiting=false { quit skip-confirmation=true; }
Mod+WheelScrollDown cooldown-ms=150 { focus-workspace-down; }
}
@@ -3781,6 +3797,28 @@ mod tests {
binds: Binds(vec![
Bind {
key: Key {
+ trigger: Trigger::Keysym(Keysym::Escape),
+ modifiers: Modifiers::COMPOSITOR,
+ },
+ action: Action::ToggleKeyboardShortcutsInhibit,
+ repeat: true,
+ cooldown: None,
+ allow_when_locked: false,
+ allow_inhibiting: false,
+ },
+ Bind {
+ key: Key {
+ trigger: Trigger::Keysym(Keysym::Escape),
+ modifiers: Modifiers::COMPOSITOR | Modifiers::SHIFT,
+ },
+ action: Action::ToggleKeyboardShortcutsInhibit,
+ repeat: true,
+ cooldown: None,
+ allow_when_locked: false,
+ allow_inhibiting: false,
+ },
+ Bind {
+ key: Key {
trigger: Trigger::Keysym(Keysym::t),
modifiers: Modifiers::COMPOSITOR,
},
@@ -3788,6 +3826,7 @@ mod tests {
repeat: true,
cooldown: None,
allow_when_locked: true,
+ allow_inhibiting: true,
},
Bind {
key: Key {
@@ -3798,6 +3837,7 @@ mod tests {
repeat: true,
cooldown: None,
allow_when_locked: false,
+ allow_inhibiting: true,
},
Bind {
key: Key {
@@ -3808,6 +3848,7 @@ mod tests {
repeat: true,
cooldown: None,
allow_when_locked: false,
+ allow_inhibiting: true,
},
Bind {
key: Key {
@@ -3818,6 +3859,7 @@ mod tests {
repeat: true,
cooldown: None,
allow_when_locked: false,
+ allow_inhibiting: true,
},
Bind {
key: Key {
@@ -3828,6 +3870,7 @@ mod tests {
repeat: true,
cooldown: None,
allow_when_locked: false,
+ allow_inhibiting: true,
},
Bind {
key: Key {
@@ -3838,6 +3881,7 @@ mod tests {
repeat: true,
cooldown: None,
allow_when_locked: false,
+ allow_inhibiting: true,
},
Bind {
key: Key {
@@ -3850,6 +3894,7 @@ mod tests {
repeat: true,
cooldown: None,
allow_when_locked: false,
+ allow_inhibiting: true,
},
Bind {
key: Key {
@@ -3860,6 +3905,7 @@ mod tests {
repeat: true,
cooldown: None,
allow_when_locked: false,
+ allow_inhibiting: false,
},
Bind {
key: Key {
@@ -3870,6 +3916,7 @@ mod tests {
repeat: true,
cooldown: Some(Duration::from_millis(150)),
allow_when_locked: false,
+ allow_inhibiting: true,
},
]),
switch_events: SwitchBinds {