diff options
| author | sl0p <sl0p@sl0p.foo> | 2026-08-13 23:39:20 +0200 |
|---|---|---|
| committer | sl0p <sl0p@sl0p.foo> | 2026-08-13 23:39:20 +0200 |
| commit | 80425ad3683510f016a954315902c78bb1f77379 (patch) | |
| tree | ba9e8553cecacadff960571298c44fe28b2c15be /src/pane.c | |
| parent | sl0ptty: M8 — pane sizes as weights, resize and drag-to-reorder (diff) | |
| download | slosh-80425ad3683510f016a954315902c78bb1f77379.tar.gz slosh-80425ad3683510f016a954315902c78bb1f77379.tar.xz slosh-80425ad3683510f016a954315902c78bb1f77379.zip | |
sl0ptty: focus follows the mouse, with the guards that make it liveable
Hovering a pane focuses it. The feature is three lines; the reason it is not
obnoxious is the guards, and each one is a test:
- not while the prefix is held, so a chord cannot be hijacked by a nudge of
the mouse;
- not through the finder, whose rows are on top of the hit list anyway;
- not during a drag, which owns the mouse until the button comes up;
- not onto a collapsed pane. Only 'pane:' and 'title:' targets count, never
the frame rect's 'focus:', so the pointer crossing a stack of headers does
not expand three panes on its way past.
Off with 'focus_follows_mouse false'; clicking still focuses either way.
This needed the client to ask for ?1003 (any motion) rather than ?1002 (motion
while a button is held), which fixes something that was quietly broken: a pane
requesting any-event tracking could never receive hover, because the outer
terminal was never asked to report it. It can now, and a pane that asked only
for clicks still gets none — both tested.
One real bug behind that: our decoder represents 'no button held' as
MBTN_UNKNOWN, and pane_send_mouse was passing it to the encoder as a concrete
button. lib-vt has ghostty_mouse_event_clear_button() for exactly this, and
without it bare motion encoded to nothing at all.
320 checks green.
Diffstat (limited to 'src/pane.c')
| -rw-r--r-- | src/pane.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -339,7 +339,10 @@ void pane_send_mouse(pane_t *p, const input_event_t *ev) { GhosttyMousePosition pos = {.x = (float)ev->mx, .y = (float)ev->my}; ghostty_mouse_event_set_position(p->mev, pos); - ghostty_mouse_event_set_button(p->mev, (GhosttyMouseButton)ev->button); + /* "no button held" is its own thing, not button zero: bare motion (hover) + * must be encoded as none, or a pane in any-event tracking sees nothing. */ + if (ev->button == MBTN_UNKNOWN) ghostty_mouse_event_clear_button(p->mev); + else ghostty_mouse_event_set_button(p->mev, (GhosttyMouseButton)ev->button); ghostty_mouse_event_set_action(p->mev, (GhosttyMouseAction)ev->maction); ghostty_mouse_event_set_mods(p->mev, (GhosttyMods)ev->mods); |
