From 856da84f08e2ba8e044707060a01342e20cfcc66 Mon Sep 17 00:00:00 2001 From: iamcheyan Date: Sat, 13 Jun 2026 08:25:22 +0900 Subject: [PATCH] cursor: add scroll wheel support for window cycle When cycle mode is active (Alt+Tab held), scrolling the mouse wheel cycles through windows. Scroll down advances to the next window, scroll up goes to the previous window. This uses the same LAB_CYCLE_DIR_FORWARD/BACKWARD constants as the keyboard handler, ensuring consistent navigation behavior. No configuration needed - always active during cycle mode. --- docs/scroll-cycle.md | 29 +++++++++++++++++++++++++++++ src/input/cursor.c | 11 +++++++++++ 2 files changed, 40 insertions(+) create mode 100644 docs/scroll-cycle.md diff --git a/docs/scroll-cycle.md b/docs/scroll-cycle.md new file mode 100644 index 00000000..9f1bb148 --- /dev/null +++ b/docs/scroll-cycle.md @@ -0,0 +1,29 @@ +# Scroll Wheel Support for Window Cycle (Alt+Tab) + +## Summary + +Add mouse scroll wheel support to the Alt+Tab window switcher. When cycle mode is active (Alt+Tab held), scrolling the mouse wheel cycles through windows — scroll down for next, scroll up for previous. + +## Usage + +1. Press and hold **Alt+Tab** to enter cycle mode +2. **Scroll wheel down** → cycle to the next window +3. **Scroll wheel up** → cycle to the previous window +4. Release **Alt** to focus the selected window + +No configuration needed — this behavior is always active during cycle mode. + +## Technical Details + +The patch intercepts `WL_POINTER_AXIS_VERTICAL_SCROLL` events in `handle_axis()` when `server.input_mode == LAB_INPUT_STATE_CYCLE`. It maps: + +- Negative delta (scroll up) → `LAB_CYCLE_DIR_BACKWARD` +- Positive delta (scroll down) → `LAB_CYCLE_DIR_FORWARD` + +These are the same direction constants used by the keyboard handler (`handle_cycle_view_key()` in `keyboard.c`), ensuring consistent behavior between keyboard and mouse navigation. + +The event is consumed (not forwarded to clients or processed as mouse bindings) when cycle mode is active. + +## Files Changed + +- `src/input/cursor.c` — Added scroll wheel interception in `handle_axis()` diff --git a/src/input/cursor.c b/src/input/cursor.c index e8ac7d96..7f656eba 100644 --- a/src/input/cursor.c +++ b/src/input/cursor.c @@ -1441,6 +1441,17 @@ handle_axis(struct wl_listener *listener, void *data) idle_manager_notify_activity(seat->wlr_seat); cursor_set_visible(seat, /* visible */ true); + /* Cycle mode: scroll wheel cycles through windows */ + if (server.input_mode == LAB_INPUT_STATE_CYCLE) { + if (event->orientation == WL_POINTER_AXIS_VERTICAL_SCROLL + && event->delta != 0) { + cycle_step(event->delta < 0 + ? LAB_CYCLE_DIR_FORWARD + : LAB_CYCLE_DIR_BACKWARD); + } + return; + } + /* input->scroll_factor is set for pointer/touch devices */ assert(event->pointer->base.type == WLR_INPUT_DEVICE_POINTER || event->pointer->base.type == WLR_INPUT_DEVICE_TOUCH);