[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)]
pub enum Trigger {
Keysym(Keysym),
WheelDown,
WheelUp,
WheelLeft,
WheelRight,
WheelScrollDown,
WheelScrollUp,
WheelScrollLeft,
WheelScrollRight,
}
bitflags! {
@@ -1547,14 +1547,14 @@ impl FromStr for Key {
}
}
let trigger = if key.eq_ignore_ascii_case("WheelDown") {
Trigger::WheelDown
} else if key.eq_ignore_ascii_case("WheelUp") {
Trigger::WheelUp
} else if key.eq_ignore_ascii_case("WheelLeft") {
Trigger::WheelLeft
} else if key.eq_ignore_ascii_case("WheelRight") {
Trigger::WheelRight
let trigger = if key.eq_ignore_ascii_case("WheelScrollDown") {
Trigger::WheelScrollDown
} else if key.eq_ignore_ascii_case("WheelScrollUp") {
Trigger::WheelScrollUp
} else if key.eq_ignore_ascii_case("WheelScrollLeft") {
Trigger::WheelScrollLeft
} else if key.eq_ignore_ascii_case("WheelScrollRight") {
Trigger::WheelScrollRight
} else {
let keysym = keysym_from_name(key, KEYSYM_CASE_INSENSITIVE);
if keysym.raw() == KEY_NoSymbol {
@@ -1771,7 +1771,7 @@ mod tests {
Mod+Comma { consume-window-into-column; }
Mod+1 { focus-workspace 1; }
Mod+Shift+E { quit skip-confirmation=true; }
Mod+WheelDown cooldown-ms=150 { focus-workspace-down; }
Mod+WheelScrollDown cooldown-ms=150 { focus-workspace-down; }
}
debug {
@@ -2011,7 +2011,7 @@ mod tests {
},
Bind {
key: Key {
trigger: Trigger::WheelDown,
trigger: Trigger::WheelScrollDown,
modifiers: Modifiers::COMPOSITOR,
},
action: Action::FocusWorkspaceDown,
+12 -12
View File
@@ -523,22 +523,22 @@ binds {
// To avoid scrolling through workspaces really fast, you can use
// 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.
Mod+WheelDown cooldown-ms=150 { focus-workspace-down; }
Mod+WheelUp cooldown-ms=150 { focus-workspace-up; }
Mod+Ctrl+WheelDown cooldown-ms=150 { move-column-to-workspace-down; }
Mod+Ctrl+WheelUp cooldown-ms=150 { move-column-to-workspace-up; }
Mod+WheelScrollDown cooldown-ms=150 { focus-workspace-down; }
Mod+WheelScrollUp cooldown-ms=150 { focus-workspace-up; }
Mod+Ctrl+WheelScrollDown cooldown-ms=150 { move-column-to-workspace-down; }
Mod+Ctrl+WheelScrollUp cooldown-ms=150 { move-column-to-workspace-up; }
Mod+WheelRight { focus-column-right; }
Mod+WheelLeft { focus-column-left; }
Mod+Ctrl+WheelRight { move-column-right; }
Mod+Ctrl+WheelLeft { move-column-left; }
Mod+WheelScrollRight { focus-column-right; }
Mod+WheelScrollLeft { focus-column-left; }
Mod+Ctrl+WheelScrollRight { move-column-right; }
Mod+Ctrl+WheelScrollLeft { move-column-left; }
// Usually scrolling up and down with Shift in applications results in
// horizontal scrolling; these binds replicate that.
Mod+Shift+WheelDown { focus-column-right; }
Mod+Shift+WheelUp { focus-column-left; }
Mod+Ctrl+Shift+WheelDown { move-column-right; }
Mod+Ctrl+Shift+WheelUp { move-column-left; }
Mod+Shift+WheelScrollDown { focus-column-right; }
Mod+Shift+WheelScrollUp { focus-column-left; }
Mod+Ctrl+Shift+WheelScrollDown { move-column-right; }
Mod+Ctrl+Shift+WheelScrollUp { move-column-left; }
// You can refer to workspaces by index. However, keep in mind that
// 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 vertical_amount_v120 = event.amount_v120(Axis::Vertical);
// Handle wheel bindings.
// Handle wheel scroll bindings.
if source == AxisSource::Wheel {
let comp_mod = self.backend.mod_key();
let mods = self.niri.seat.get_keyboard().unwrap().modifier_state();
@@ -1124,9 +1124,10 @@ impl State {
if let Some(v120) = horizontal_amount_v120 {
let config = self.niri.config.borrow();
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 =
find_configured_bind(bindings, comp_mod, Trigger::WheelRight, mods);
find_configured_bind(bindings, comp_mod, Trigger::WheelScrollRight, mods);
drop(config);
// 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 {
let config = self.niri.config.borrow();
let bindings = &config.binds;
let bind_up = find_configured_bind(bindings, comp_mod, Trigger::WheelUp, mods);
let bind_down = find_configured_bind(bindings, comp_mod, Trigger::WheelDown, mods);
let bind_up =
find_configured_bind(bindings, comp_mod, Trigger::WheelScrollUp, mods);
let bind_down =
find_configured_bind(bindings, comp_mod, Trigger::WheelScrollDown, mods);
drop(config);
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 {
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"),
Trigger::WheelScrollDown => String::from("Wheel Scroll Down"),
Trigger::WheelScrollUp => String::from("Wheel Scroll Up"),
Trigger::WheelScrollLeft => String::from("Wheel Scroll Left"),
Trigger::WheelScrollRight => String::from("Wheel Scroll Right"),
};
name.push_str(&pretty);