Skip to content

macos: treat unfocused split modifiers as UI state#12710

Open
rockorager wants to merge 1 commit into
ghostty-org:mainfrom
rockorager:fix-macos-unfocused-mods
Open

macos: treat unfocused split modifiers as UI state#12710
rockorager wants to merge 1 commit into
ghostty-org:mainfrom
rockorager:fix-macos-unfocused-mods

Conversation

@rockorager

Copy link
Copy Markdown
Member

The terminal controller listens for flagsChanged events so all splits can keep modifier-sensitive UI state current. Forwarding those events through SurfaceView.flagsChanged() also routes them through the normal key input path, so an unfocused split can receive modifier press and release events as terminal input.

Send modifier changes for unfocused splits through a modifier-only surface entry point instead. The core surface updates mouse modifier state, link highlighting and cursor shape from that path, but does not run key binding or terminal encoding. Apply key remaps there as well so focused and unfocused modifier state stay consistent.

Factor the shared modifier and mouse-shape work into helpers so the normal key path and the modifier-only path use the same state transitions. Keep the physical-key filter in keyToMouseShape(), and expose the pure modsToMouseShape() calculation for cases where AppKit reports only a modifier state change.

To reproduce the old behavior: open two splits in Ghostty and run kitten show-key -m kitty in each. Modifier key presses appear in both splits.

AI Disclosure: This patch was prepared with the help of AI.

The terminal controller listens for flagsChanged events so all splits can
keep modifier-sensitive UI state current.  Forwarding those events through
SurfaceView.flagsChanged() also routes them through the normal key input
path, so an unfocused split can receive modifier press and release events
as terminal input.

Send modifier changes for unfocused splits through a modifier-only surface
entry point instead.  The core surface updates mouse modifier state, link
highlighting and cursor shape from that path, but does not run key binding
or terminal encoding.  Apply key remaps there as well so focused and
unfocused modifier state stay consistent.

Factor the shared modifier and mouse-shape work into helpers so the normal
key path and the modifier-only path use the same state transitions.  Keep
the physical-key filter in keyToMouseShape(), and expose the pure
modsToMouseShape() calculation for cases where AppKit reports only a
modifier state change.

To reproduce the old behavior: open two splits in Ghostty and run
`kitten show-key -m kitty` in each. Modifier key presses appear in both
splits.

AI Disclosure: This patch was prepared with the help of AI.
@rockorager rockorager requested review from a team as code owners May 16, 2026 21:50
@ghostty-bot ghostty-bot Bot added the os/macos label May 16, 2026

@bo2themax bo2themax left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Swift changes LGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants