[cfg-breaking] Rename Wheel* to WheelScroll* bindings

Less confusion, and clearer that they are affected by natural-scroll.
This commit is contained in:
Ivan Molodetskikh
2024-03-23 08:49:58 +04:00
parent 54e6a01284
commit b09dbb80c7
4 changed files with 38 additions and 35 deletions
+14 -14
View File
@@ -733,10 +733,10 @@ pub struct Key {
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)] #[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
pub enum Trigger { pub enum Trigger {
Keysym(Keysym), Keysym(Keysym),
WheelDown, WheelScrollDown,
WheelUp, WheelScrollUp,
WheelLeft, WheelScrollLeft,
WheelRight, WheelScrollRight,
} }
bitflags! { bitflags! {
@@ -1547,14 +1547,14 @@ impl FromStr for Key {
} }
} }
let trigger = if key.eq_ignore_ascii_case("WheelDown") { let trigger = if key.eq_ignore_ascii_case("WheelScrollDown") {
Trigger::WheelDown Trigger::WheelScrollDown
} else if key.eq_ignore_ascii_case("WheelUp") { } else if key.eq_ignore_ascii_case("WheelScrollUp") {
Trigger::WheelUp Trigger::WheelScrollUp
} else if key.eq_ignore_ascii_case("WheelLeft") { } else if key.eq_ignore_ascii_case("WheelScrollLeft") {
Trigger::WheelLeft Trigger::WheelScrollLeft
} else if key.eq_ignore_ascii_case("WheelRight") { } else if key.eq_ignore_ascii_case("WheelScrollRight") {
Trigger::WheelRight Trigger::WheelScrollRight
} else { } else {
let keysym = keysym_from_name(key, KEYSYM_CASE_INSENSITIVE); let keysym = keysym_from_name(key, KEYSYM_CASE_INSENSITIVE);
if keysym.raw() == KEY_NoSymbol { if keysym.raw() == KEY_NoSymbol {
@@ -1771,7 +1771,7 @@ mod tests {
Mod+Comma { consume-window-into-column; } Mod+Comma { consume-window-into-column; }
Mod+1 { focus-workspace 1; } Mod+1 { focus-workspace 1; }
Mod+Shift+E { quit skip-confirmation=true; } Mod+Shift+E { quit skip-confirmation=true; }
Mod+WheelDown cooldown-ms=150 { focus-workspace-down; } Mod+WheelScrollDown cooldown-ms=150 { focus-workspace-down; }
} }
debug { debug {
@@ -2011,7 +2011,7 @@ mod tests {
}, },
Bind { Bind {
key: Key { key: Key {
trigger: Trigger::WheelDown, trigger: Trigger::WheelScrollDown,
modifiers: Modifiers::COMPOSITOR, modifiers: Modifiers::COMPOSITOR,
}, },
action: Action::FocusWorkspaceDown, action: Action::FocusWorkspaceDown,
+12 -12
View File
@@ -523,22 +523,22 @@ binds {
// To avoid scrolling through workspaces really fast, you can use // To avoid scrolling through workspaces really fast, you can use
// the cooldown-ms property. The bind will be rate-limited to this value. // the cooldown-ms property. The bind will be rate-limited to this value.
// You can set a cooldown on any bind, but it's most useful for the wheel. // You can set a cooldown on any bind, but it's most useful for the wheel.
Mod+WheelDown cooldown-ms=150 { focus-workspace-down; } Mod+WheelScrollDown cooldown-ms=150 { focus-workspace-down; }
Mod+WheelUp cooldown-ms=150 { focus-workspace-up; } Mod+WheelScrollUp cooldown-ms=150 { focus-workspace-up; }
Mod+Ctrl+WheelDown cooldown-ms=150 { move-column-to-workspace-down; } Mod+Ctrl+WheelScrollDown cooldown-ms=150 { move-column-to-workspace-down; }
Mod+Ctrl+WheelUp cooldown-ms=150 { move-column-to-workspace-up; } Mod+Ctrl+WheelScrollUp cooldown-ms=150 { move-column-to-workspace-up; }
Mod+WheelRight { focus-column-right; } Mod+WheelScrollRight { focus-column-right; }
Mod+WheelLeft { focus-column-left; } Mod+WheelScrollLeft { focus-column-left; }
Mod+Ctrl+WheelRight { move-column-right; } Mod+Ctrl+WheelScrollRight { move-column-right; }
Mod+Ctrl+WheelLeft { move-column-left; } Mod+Ctrl+WheelScrollLeft { move-column-left; }
// Usually scrolling up and down with Shift in applications results in // Usually scrolling up and down with Shift in applications results in
// horizontal scrolling; these binds replicate that. // horizontal scrolling; these binds replicate that.
Mod+Shift+WheelDown { focus-column-right; } Mod+Shift+WheelScrollDown { focus-column-right; }
Mod+Shift+WheelUp { focus-column-left; } Mod+Shift+WheelScrollUp { focus-column-left; }
Mod+Ctrl+Shift+WheelDown { move-column-right; } Mod+Ctrl+Shift+WheelScrollDown { move-column-right; }
Mod+Ctrl+Shift+WheelUp { move-column-left; } Mod+Ctrl+Shift+WheelScrollUp { move-column-left; }
// You can refer to workspaces by index. However, keep in mind that // You can refer to workspaces by index. However, keep in mind that
// niri is a dynamic workspace system, so these commands are kind of // niri is a dynamic workspace system, so these commands are kind of
+8 -5
View File
@@ -1116,7 +1116,7 @@ impl State {
let horizontal_amount_v120 = event.amount_v120(Axis::Horizontal); let horizontal_amount_v120 = event.amount_v120(Axis::Horizontal);
let vertical_amount_v120 = event.amount_v120(Axis::Vertical); let vertical_amount_v120 = event.amount_v120(Axis::Vertical);
// Handle wheel bindings. // Handle wheel scroll bindings.
if source == AxisSource::Wheel { if source == AxisSource::Wheel {
let comp_mod = self.backend.mod_key(); let comp_mod = self.backend.mod_key();
let mods = self.niri.seat.get_keyboard().unwrap().modifier_state(); let mods = self.niri.seat.get_keyboard().unwrap().modifier_state();
@@ -1124,9 +1124,10 @@ impl State {
if let Some(v120) = horizontal_amount_v120 { if let Some(v120) = horizontal_amount_v120 {
let config = self.niri.config.borrow(); let config = self.niri.config.borrow();
let bindings = &config.binds; let bindings = &config.binds;
let bind_left = find_configured_bind(bindings, comp_mod, Trigger::WheelLeft, mods); let bind_left =
find_configured_bind(bindings, comp_mod, Trigger::WheelScrollLeft, mods);
let bind_right = let bind_right =
find_configured_bind(bindings, comp_mod, Trigger::WheelRight, mods); find_configured_bind(bindings, comp_mod, Trigger::WheelScrollRight, mods);
drop(config); drop(config);
// If we have a bind with current modifiers along the scroll direction, then // If we have a bind with current modifiers along the scroll direction, then
@@ -1152,8 +1153,10 @@ impl State {
if let Some(v120) = vertical_amount_v120 { if let Some(v120) = vertical_amount_v120 {
let config = self.niri.config.borrow(); let config = self.niri.config.borrow();
let bindings = &config.binds; let bindings = &config.binds;
let bind_up = find_configured_bind(bindings, comp_mod, Trigger::WheelUp, mods); let bind_up =
let bind_down = find_configured_bind(bindings, comp_mod, Trigger::WheelDown, mods); find_configured_bind(bindings, comp_mod, Trigger::WheelScrollUp, mods);
let bind_down =
find_configured_bind(bindings, comp_mod, Trigger::WheelScrollDown, mods);
drop(config); drop(config);
if bind_up.is_some() || bind_down.is_some() { if bind_up.is_some() || bind_down.is_some() {
+4 -4
View File
@@ -417,10 +417,10 @@ fn key_name(comp_mod: CompositorMod, key: &Key) -> String {
let pretty = match key.trigger { let pretty = match key.trigger {
Trigger::Keysym(keysym) => prettify_keysym_name(&keysym_get_name(keysym)), Trigger::Keysym(keysym) => prettify_keysym_name(&keysym_get_name(keysym)),
Trigger::WheelDown => String::from("Wheel Down"), Trigger::WheelScrollDown => String::from("Wheel Scroll Down"),
Trigger::WheelUp => String::from("Wheel Up"), Trigger::WheelScrollUp => String::from("Wheel Scroll Up"),
Trigger::WheelLeft => String::from("Wheel Left"), Trigger::WheelScrollLeft => String::from("Wheel Scroll Left"),
Trigger::WheelRight => String::from("Wheel Right"), Trigger::WheelScrollRight => String::from("Wheel Scroll Right"),
}; };
name.push_str(&pretty); name.push_str(&pretty);