aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-03-22 10:36:19 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2024-03-22 10:36:19 +0400
commita0c8c39b06e672c633e09f3751d46fa8fed4f3a4 (patch)
tree3aab3194216623e64dd0feac99f967aecd6723da /src
parent977f1487c22b5d30051939b9572b99a31a9775ff (diff)
downloadniri-a0c8c39b06e672c633e09f3751d46fa8fed4f3a4.tar.gz
niri-a0c8c39b06e672c633e09f3751d46fa8fed4f3a4.tar.bz2
niri-a0c8c39b06e672c633e09f3751d46fa8fed4f3a4.zip
Make binds accept wheel names
Diffstat (limited to 'src')
-rw-r--r--src/input.rs16
-rw-r--r--src/ui/hotkey_overlay.rs12
2 files changed, 18 insertions, 10 deletions
diff --git a/src/input.rs b/src/input.rs
index 80000efe..e6598719 100644
--- a/src/input.rs
+++ b/src/input.rs
@@ -3,7 +3,7 @@ use std::collections::HashSet;
use std::time::Duration;
use input::event::gesture::GestureEventCoordinates as _;
-use niri_config::{Action, Binds, Modifiers};
+use niri_config::{Action, Binds, Modifiers, Trigger};
use niri_ipc::LayoutSwitchTarget;
use smithay::backend::input::{
AbsolutePositionEvent, Axis, AxisSource, ButtonState, Device, DeviceCapability, Event,
@@ -1731,7 +1731,7 @@ fn bound_action(
let raw = raw?;
for bind in &bindings.0 {
- if bind.key.keysym != raw {
+ if bind.key.trigger != Trigger::Keysym(raw) {
continue;
}
@@ -1911,7 +1911,7 @@ mod tests {
let close_keysym = Keysym::q;
let bindings = Binds(vec![Bind {
key: Key {
- keysym: close_keysym,
+ trigger: Trigger::Keysym(close_keysym),
modifiers: Modifiers::COMPOSITOR | Modifiers::CTRL,
},
action: Action::CloseWindow,
@@ -2033,35 +2033,35 @@ mod tests {
let bindings = Binds(vec![
Bind {
key: Key {
- keysym: Keysym::q,
+ trigger: Trigger::Keysym(Keysym::q),
modifiers: Modifiers::COMPOSITOR,
},
action: Action::CloseWindow,
},
Bind {
key: Key {
- keysym: Keysym::h,
+ trigger: Trigger::Keysym(Keysym::h),
modifiers: Modifiers::SUPER,
},
action: Action::FocusColumnLeft,
},
Bind {
key: Key {
- keysym: Keysym::j,
+ trigger: Trigger::Keysym(Keysym::j),
modifiers: Modifiers::empty(),
},
action: Action::FocusWindowDown,
},
Bind {
key: Key {
- keysym: Keysym::k,
+ trigger: Trigger::Keysym(Keysym::k),
modifiers: Modifiers::COMPOSITOR | Modifiers::SUPER,
},
action: Action::FocusWindowUp,
},
Bind {
key: Key {
- keysym: Keysym::l,
+ trigger: Trigger::Keysym(Keysym::l),
modifiers: Modifiers::SUPER | Modifiers::ALT,
},
action: Action::FocusColumnRight,
diff --git a/src/ui/hotkey_overlay.rs b/src/ui/hotkey_overlay.rs
index 5fc3cedb..f054b3cf 100644
--- a/src/ui/hotkey_overlay.rs
+++ b/src/ui/hotkey_overlay.rs
@@ -4,7 +4,7 @@ use std::collections::HashMap;
use std::iter::zip;
use std::rc::Rc;
-use niri_config::{Action, Config, Key, Modifiers};
+use niri_config::{Action, Config, Key, Modifiers, Trigger};
use pangocairo::cairo::{self, ImageSurface};
use pangocairo::pango::{AttrColor, AttrInt, AttrList, AttrString, FontDescription, Weight};
use smithay::backend::renderer::element::memory::{
@@ -414,7 +414,15 @@ fn key_name(comp_mod: CompositorMod, key: &Key) -> String {
if key.modifiers.contains(Modifiers::CTRL) {
name.push_str("Ctrl + ");
}
- name.push_str(&prettify_keysym_name(&keysym_get_name(key.keysym)));
+
+ let pretty = match key.trigger {
+ Trigger::Keysym(keysym) => prettify_keysym_name(&keysym_get_name(keysym)),
+ Trigger::WheelDown => String::from("Wheel Down"),
+ Trigger::WheelUp => String::from("Wheel Up"),
+ Trigger::WheelLeft => String::from("Wheel Left"),
+ Trigger::WheelRight => String::from("Wheel Right"),
+ };
+ name.push_str(&pretty);
name
}