Skip to content

macos: reset mouse state on focus loss to prevent phantom drag - #11276

Merged
mitchellh merged 1 commit into
ghostty-org:mainfrom
seruman:fix/macos-mouse-state-focus-reset
Mar 10, 2026
Merged

mitchellh merged 1 commit into
ghostty-org:mainfrom
seruman:fix/macos-mouse-state-focus-reset

Conversation

@seruman

@seruman seruman commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

Fixes #11203

The suppressNextLeftMouseUp flag from #11167 wasn't being reset on focus loss, causing stale state that led to phantom drags/selections and scrolls if you're lucky enough.

I've followed the #11167 's path and made it reset on focus loss.

As I stated in the vouch request; I'm not experienced in Swift, just following the prior PR's steps to reset the state. I've been using this patch for couple days and the change looks trivial to me tho not 100% sure if I'm missing anything.

Note

Used Claude Code -Opus 4.6- for navigating the codebase and reviewing the change.

@seruman
seruman requested review from a team as code owners March 9, 2026 19:35
@jcollie

jcollie commented Mar 9, 2026

Copy link
Copy Markdown
Member

CC @rockorager

@jcollie jcollie added this to the 1.3.1 milestone Mar 9, 2026
@mitchellh

Copy link
Copy Markdown
Contributor

I think this fixes #11319 too.

@mitchellh

Copy link
Copy Markdown
Contributor

and scrolls if you're lucky enough.

also lol.

@mitchellh
mitchellh force-pushed the fix/macos-mouse-state-focus-reset branch from 74aa089 to 970542a Compare March 10, 2026 16:49

@mitchellh mitchellh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cleaned up some of the code with comments, removed the core surface changes. I don't think the core changes were necessary for this fix. If I'm wrong about that please let me know but I couldn't reproduce the bug anymore with just the apprt changes and I'm afraid the core changes may impact legitimate mouse release events in some cases.

Fixes phantom mouse drag/selection when switching splits or apps.
The suppressNextLeftMouseUp flag and core mouse click_state were not
being reset on focus transitions, causing stale state that led to
unexpected drag behavior.

- Reset suppressNextLeftMouseUp in focusDidChange when losing focus
- Defensively reset the flag when processing normal clicks
- Reset core mouse.click_state and left_click_count on focus loss
@mitchellh
mitchellh force-pushed the fix/macos-mouse-state-focus-reset branch from 970542a to 6092c29 Compare March 10, 2026 16:54
@mitchellh
mitchellh merged commit 119ce0b into ghostty-org:main Mar 10, 2026
2 checks passed
@seruman
seruman deleted the fix/macos-mouse-state-focus-reset branch March 10, 2026 16:57
@seruman

seruman commented Mar 10, 2026

Copy link
Copy Markdown
Contributor Author

Thank you! 🎉

@QuintonC

Copy link
Copy Markdown

I thought I was going a bit crazy and accidentally clicking. Thank you @seruman and @mitchellh for acting on this so quickly 🙇

greenheadHQ added a commit to greenheadHQ/nixos-config that referenced this pull request Mar 12, 2026
포커스 전환 시 텍스트가 팬텀 드래그되며 무한 스크롤되는 1.3.0 회귀 버그.
upstream PR ghostty-org/ghostty#11276 수정이 포함된 tip 채널로 전환.
1.3.1 stable 릴리스 후 "ghostty"로 복원 예정.
@SidKwok

SidKwok commented Mar 15, 2026

Copy link
Copy Markdown

Thanks @seruman! This fixed a really annoying phantom drag issue I've been hitting. Much appreciated!

whexy added a commit to whexy/dotfiles that referenced this pull request Mar 17, 2026
Upstream located a bug ghostty-org/ghostty#11276

This commit uses stable channel again, which add a backport of the
upgrade commit in unstable channel.
bo2themax added a commit to bo2themax/ghostty that referenced this pull request Mar 19, 2026
mitchellh added a commit that referenced this pull request Mar 21, 2026
…#11665)

Also added a test case for
#11276, which will fail right
before that commit.

## AI Disclosure

Claude helped me to write some dummy texts for testing
greenheadHQ added a commit to greenheadHQ/nixos-config that referenced this pull request Jun 6, 2026
포커스 전환 시 텍스트가 팬텀 드래그되며 무한 스크롤되는 1.3.0 회귀 버그.
upstream PR ghostty-org/ghostty#11276 수정이 포함된 tip 채널로 전환.
1.3.1 stable 릴리스 후 "ghostty"로 복원 예정.
jpnurmi added a commit to jpnurmi/limux that referenced this pull request Jul 16, 2026
Cherry-picks upstream commit 0fa12f8 from manaflow-ai/ghostty which
suppresses mouse reports on focus-transfer clicks. This fixes phantom
text selection when clicking between panes.

Upstream PR: ghostty-org/ghostty#11167
Upstream fix: ghostty-org/ghostty#11276
jpnurmi added a commit to jpnurmi/limux that referenced this pull request Jul 16, 2026
Cherry-picks upstream commit 0fa12f8 from manaflow-ai/ghostty which
suppresses mouse reports on focus-transfer clicks. This fixes phantom
text selection when clicking between panes.

Upstream PR: ghostty-org/ghostty#11167
Upstream fix: ghostty-org/ghostty#11276
jpnurmi added a commit to jpnurmi/limux that referenced this pull request Jul 16, 2026
Cherry-picks upstream commit 0fa12f8 from manaflow-ai/ghostty which
suppresses mouse reports on focus-transfer clicks. This fixes phantom
text selection when clicking between panes.

Upstream PR: ghostty-org/ghostty#11167
Upstream fix: ghostty-org/ghostty#11276
christmic pushed a commit to christmic/Sylvander that referenced this pull request Aug 12, 2026
… (#11665)

Also added a test case for
ghostty-org/ghostty#11276, which will fail right
before that commit.

## AI Disclosure

Claude helped me to write some dummy texts for testing
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.

5 participants