Skip to content

surface: restore application mouse shape after modifier overrides - #14128

Merged
mitchellh merged 4 commits into
ghostty-org:mainfrom
j-c-m:surface/mouse-shape-osc22
Sep 3, 2026
Merged

mitchellh merged 4 commits into
ghostty-org:mainfrom
j-c-m:surface/mouse-shape-osc22

Conversation

@j-c-m

@j-c-m j-c-m commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

This fixes a regression of 9a64697 introduced in 6e8ed4e.

With this fix the mouse pointer will be restored to the previous (which could have be set to something else via OSC22), not a hardcoded .text or .default.

It also will change the cursor to a text selection if shift is held even without mouse tracking, I think this is the expected behavior when a cursor is set via OSC22. (Kitty additionaly, once you start selecting changes to text (I-beam), this would be a follow-up if we desire to behave like kitty with OSC22 pointers).

hard-coded .default & .text overrode a previously set OSC22 pointer
shape, this was a regression introduced in 6e8ed4e.
Update the tests to expect the mouse_shape back, not the hardcoded
.default or .text
I think this is the expected behavoir when a custom OSC22 pointer is set. Once
shift is released it will return to mouse_shape (whatever the pointer
was before shit held).
@j-c-m
j-c-m requested a review from a team as a code owner September 2, 2026 21:00
@j-c-m

j-c-m commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Simple test on main, printf '\e]22;pointer\a' , will turn the mouse pointer finger, hold shift will turn I-beam, release, it should turn back to the pointer finger but doesn't, subsequent printf '\e]22;pointer\a' will also fail to set the pointer.

On this fix it will reset back to the OSC22 set pointer.

@vancluever

Copy link
Copy Markdown
Contributor

@j-c-m thanks for catching this.

I'm just going to piggyback on your commit here to just simplify some things; I think the whole "state machine" thing that I was envisioning didn't necessarily materialize, so I'm just going to update some of the code to reflect. Otherwise looks good!

keyToMouseShape was initially designed with more of a transition table
model in mind to handle key presses/overrides based on very specific
cursor states. This never materialized, so I think it's safe to just
simply the process of handling overrides and/or passing along the
current cursor state from the terminal in the event of key presses.

Also removed a test that is essentially a duplicate of one before it now
(returning current surface shape in the event of no overrides).
@vancluever
vancluever force-pushed the surface/mouse-shape-osc22 branch from 7054f73 to 0fb6d29 Compare September 3, 2026 02:03
@mitchellh
mitchellh merged commit 6000034 into ghostty-org:main Sep 3, 2026
104 checks passed
@github-actions github-actions Bot added this to the 1.4.0 milestone Sep 3, 2026
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