Skip to content

Fix macOS mouse cursor flicker#55068

Merged
JosephTLyons merged 4 commits intomainfrom
fix-macos-cursor-flicker
Apr 28, 2026
Merged

Fix macOS mouse cursor flicker#55068
JosephTLyons merged 4 commits intomainfrom
fix-macos-cursor-flicker

Conversation

@agu-z
Copy link
Copy Markdown
Contributor

@agu-z agu-z commented Apr 28, 2026

#48029 introduced set_document_path which is frequently (we are also working on a PR to make it less frequent) called as tabs and panes update. Apparently, the AppKit function it uses (NSWindow::setRepresentedFilename) can cause the current cursor style to be reset, producing flicker as the cursor would change to Arrow temporarily until the right cursor style is set again in the next frame.

This PR reworks how we set the cursor to use AppKit's resetCursorRects, giving us a chance to re-set the cursor when the OS decides to invalidate it.

Finally, it fixes a separate bug introduced in #50827 where moving the mouse while typing in an editor would cause to the cursor to flicker between None (hidden) -> Arrow -> IBeam. This was caused by incorrectly resetting the cursor to Arrow when the last input came from the keyboard.

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content is consistent with the UI/UX checklist
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Release Notes:

  • N/A

agu-z and others added 3 commits April 28, 2026 09:43
Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de>
Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de>
Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de>
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Apr 28, 2026
@zed-community-bot zed-community-bot Bot added the staff Pull requests authored by a current member of Zed staff label Apr 28, 2026
@JosephTLyons JosephTLyons added this pull request to the merge queue Apr 28, 2026
Merged via the queue into main with commit d010b06 Apr 28, 2026
31 checks passed
@JosephTLyons JosephTLyons deleted the fix-macos-cursor-flicker branch April 28, 2026 13:14
tahayvr pushed a commit to tahayvr/zed that referenced this pull request Apr 28, 2026
zed-industries#48029 introduced `set_document_path` which is frequently (we are also
working on a PR to make it less frequent) called as tabs and panes
update. Apparently, the AppKit function it uses
(`NSWindow::setRepresentedFilename`) can cause the current cursor style
to be reset, producing flicker as the cursor would change to `Arrow`
temporarily until the right cursor style is set again in the next frame.

This PR reworks how we set the cursor to use AppKit's
`resetCursorRects`, giving us a chance to re-set the cursor when the OS
decides to invalidate it.

Finally, it fixes a separate bug introduced in zed-industries#50827 where moving the
mouse while typing in an editor would cause to the cursor to flicker
between `None` (hidden) -> `Arrow` -> `IBeam`. This was caused by
incorrectly resetting the cursor to `Arrow` when the last input came
from the keyboard.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- N/A

---------

Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de>
AzureZee added a commit to AzureZee/gpuix that referenced this pull request Apr 29, 2026
AzureZee added a commit to AzureZee/gpuix that referenced this pull request Apr 29, 2026
ebaah46 pushed a commit to ebaah46/zed that referenced this pull request May 6, 2026
zed-industries#48029 introduced `set_document_path` which is frequently (we are also
working on a PR to make it less frequent) called as tabs and panes
update. Apparently, the AppKit function it uses
(`NSWindow::setRepresentedFilename`) can cause the current cursor style
to be reset, producing flicker as the cursor would change to `Arrow`
temporarily until the right cursor style is set again in the next frame.

This PR reworks how we set the cursor to use AppKit's
`resetCursorRects`, giving us a chance to re-set the cursor when the OS
decides to invalidate it.

Finally, it fixes a separate bug introduced in zed-industries#50827 where moving the
mouse while typing in an editor would cause to the cursor to flicker
between `None` (hidden) -> `Arrow` -> `IBeam`. This was caused by
incorrectly resetting the cursor to `Arrow` when the last input came
from the keyboard.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- N/A

---------

Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants