linebender / linebender/druid

set_cursor followup

Open
#112 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

architecture discussion
Dominant language
Rust
Stars
9.7k
Forks
565
PR merge metrics
No merged PRs in 30d

Description

This is a followup to concerns raised in #87.

> There might be a second issue here (my mac is in the shop because the butterfly keyboard got a crumb in it, so I can't test), which is whether NSCursor::set leaks globally into other app windows. If so, we should probably change it so there's a single rect that covers the entire window (or, to be more precise, the area of the NSView that serves as the root of the druid widget hiearchy, when thinking about VST guest use cases). I think that change can be made at the shell level without affecting event flow or API, if needed.

@cmyr observed that NSCursor.set can clobber the global cursor.

The [Apple docs](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/EventOverview/TrackingAreaObjects/TrackingAreaObjects.html) are confusing. If you set up these tracking areas, and it drills down to Cocoa calling your view's `cursorUpdate` method, of which their suggested impl (see [Listing 6-4](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/EventOverview/TrackingAreaObjects/TrackingAreaObjects.html#//apple_ref/doc/uid/10000060i-CH8-SW5)) is to just call `NSCursor::set`. So it's unclear if this is really what's causing the clobbering of the global cursor, or whether it might be something else such as a grab that's not being let go.

There's also the performance issue of if we should call the set_cursor every time, or only when the cursor has actually changed. This is subtle, because of the need to track when the mouse has left the window on Windows. See discussion in #87 for details.

Investigate the clobbering of the global cursor on mac, and consider the performance improvement.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the concerns and discussion in #87, then examine the macOS NSCursor::set and cursorUpdate behavior described in the Apple tracking-area documentation. Determine whether cursor updates clobber the global cursor or involve an unreleased grab, and assess whether avoiding repeated set_cursor calls is safe while preserving Windows mouse-leave handling. Done means the cause and an appropriate shell-level change are established.

Written by the indexing model from the issue text.

Assessment

Tech stack
macos, rust
Domain
desktop, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.