Skip to content

Commit

Permalink
Add support for wheel left and right clicks
Browse files Browse the repository at this point in the history
Fixes: #2103
  • Loading branch information
bim9262 committed Jan 6, 2025
1 parent 254d017 commit cc32bb2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
//!
//! Key | Description | Default
//! ----|-------------|----------
//! `button` | `left`, `middle`, `right`, `up`, `down`, `forward`, `back` or [`double_left`](MouseButton). | -
//! `button` | `left`, `middle`, `right`, `up`/`wheel_up`, `down`/`wheel_down`, `wheel_left`, `wheel_right`, `forward`, `back` or [`double_left`](MouseButton). | -
//! `widget` | To which part of the block this entry applies (accepts regex) | `"block"`
//! `cmd` | Command to run when the mouse button event is detected. | None
//! `action` | Which block action to trigger | None
Expand Down
12 changes: 9 additions & 3 deletions src/click.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::protocol::i3bar_event::I3BarEvent;
use crate::subprocess::{spawn_shell, spawn_shell_sync};
use crate::wrappers::SerdeRegex;

/// Can be one of `left`, `middle`, `right`, `up`, `down`, `forward`, `back` or `double_left`.
/// Can be one of `left`, `middle`, `right`, `up`/`wheel_up`, `down`/`wheel_down`, `wheel_left`, `wheel_right`, `forward`, `back` or `double_left`.
///
/// Note that in order for double clicks to be registered, you have to set `double_click_delay` to a
/// non-zero value. `200` might be a good choice. Note that enabling this functionality will
Expand All @@ -20,6 +20,8 @@ pub enum MouseButton {
Right,
WheelUp,
WheelDown,
WheelLeft,
WheelRight,
Forward,
Back,
DoubleLeft,
Expand Down Expand Up @@ -112,8 +114,10 @@ impl<'de> Deserialize<'de> for MouseButton {
"left" => Left,
"middle" => Middle,
"right" => Right,
"up" => WheelUp,
"down" => WheelDown,
"up" | "wheel_up" => WheelUp,
"down" | "wheel_down" => WheelDown,
"wheel_left" => WheelLeft,
"wheel_right" => WheelRight,
"forward" => Forward,
"back" => Back,
// Experimental
Expand All @@ -136,6 +140,8 @@ impl<'de> Deserialize<'de> for MouseButton {
3 => Right,
4 => WheelUp,
5 => WheelDown,
6 => WheelLeft,
7 => WheelRight,
8 => Back,
9 => Forward,
other => return Err(E::custom(format!("unknown button '{other}'"))),
Expand Down

0 comments on commit cc32bb2

Please sign in to comment.