Skip to content

fix: report mouse drags in button-motion (1002) tracking mode#85

Merged
Harzu merged 1 commit into
Harzu:masterfrom
Patrick-Kappen:fix/mouse-drag-reporting
Jul 18, 2026
Merged

fix: report mouse drags in button-motion (1002) tracking mode#85
Harzu merged 1 commit into
Harzu:masterfrom
Patrick-Kappen:fix/mouse-drag-reporting

Conversation

@Patrick-Kappen

Copy link
Copy Markdown
Contributor

Problem

handle_cursor_moved only reports drag motion to the backend when the terminal is in MOUSE_MOTION (1003) mode. Applications that request button-motion tracking (1002) — most notably tmux with set -g mouse on — get the press and release reports but never the drag in between, while the widget simultaneously runs its own SelectUpdate selection.

The result with tmux: tmux sees click+release with no motion (so no copy-mode drag selection), while the widget paints its own selection overlay on top — two selection systems fighting over the same drag.

Fix

Check MOUSE_DRAG | MOUSE_MOTION when deciding whether to report a drag, matching how press/release already use the umbrella MOUSE_MODE (which includes all three tracking modes). Widget-side selection still applies when neither motion mode is active (plain 1000 click-only tracking).

Includes a regression test (reports_drag_when_dragged_in_mouse_drag_mode).

Repro

  1. run an app embedding the widget and attach to tmux -L test with set -g mouse on
  2. drag-select some text in a pane
  3. before: widget-local selection appears and tmux never enters copy-mode; double-click flashes tmux word-select while the widget selects independently
  4. after: drags are reported and tmux handles selection natively, as in other terminals

handle_cursor_moved only reported drags under MOUSE_MOTION (1003).
Apps requesting button-motion tracking (1002) — e.g. tmux with
`mouse on` — saw press and release but never the drag, while the
widget simultaneously drew its own selection over theirs: two
selection systems fighting. Check MOUSE_DRAG | MOUSE_MOTION, matching
how press/release use MOUSE_MODE.
@Harzu
Harzu merged commit 1911942 into Harzu:master Jul 18, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants