Repository navigation
fix(macos): follow pointer events in background windows - #611
Conversation
2f64df8 to
1350603
Compare
macOS shows a background window with the active app's cursor, so the surface's background moves no longer call -[NSCursor set], which costs milliseconds with a customized pointer and shows nothing. The cursor-update area still sets the cursor as the app becomes active under a resting mouse. Correct the interaction architecture, which said background moves set cursors.
1350603 to
6547ea9
Compare
|
Reviewed. Head 6547ea9, already on current main (a4bc57f). Code: views' tracking areas now use Tests:
Real pointer check on a macOS 27 Mac, with system-level
|
Summary
macOS stopped receiving hover enter/move/leave events while another application was active, so a window the user had not focused showed no hover and fired no
OnMouseEnter/OnMouseMove/OnMouseLeave. Track the pointer withNSTrackingActiveAlwayson views and on the surface, whose moves pick hovers over views with no mouse handlers. The surface's moves area subscribes to moves only, not to its own enters and exits. A separate active-app-only area keepscursorUpdate:, which AppKit does not deliver to anActiveAlwaysarea.macOS shows a background app's window with the active app's cursor, so the surface sets cursors only while the app is active: a background move no longer calls
-[NSCursor set], which costs milliseconds with a customized pointer and shows nothing. The cursor-update area sets the cursor as the app becomes active under a resting mouse.Closes #606.
Targets
Windows, Linux and web already follow pointer events without an activation gate; reviewed their hover and cursor paths. Document the shared background-window behavior, and macOS's active-app-only cursor, in the interaction architecture.
Screenshots
None. This changes native event delivery; no visual style changes.
Verification
go tool nsgo test ./internal/platform/macoson macOS: 61 passed, 0 failed, 4 skipped.TestPointerTrackingContinuesInBackgroundfails against main (surface moves0x246, view areas0x241/0x243) and passes with the fix. It checks every mouse-listener kind, the surface's moves area (always active, no enter/exit) and the separate cursor-update area.go build ./...andgo tool nsgo check -target all(desktop, Android and web), plus-target macos_arm64,macos_x64,ios,ios_simulatoron macOS.go tool nsgo test -run 'Layer|Skills|Doc' .: 35 passed.OnMouseEnter/OnMouseMove/OnMouseLeaveand aHoverstyle, and a view with an I-beamStyle.Cursor, while a second app is active). With the fix, moving inside, off and back onto the view in the background window reports moves, leave and enter, and the hover tint follows; covering the view with the other app's window reports a leave and uncovering it an enter. Against main, the same moves report nothing. The cursor stays the arrow over the background window on both, and becomes the I-beam as the app is activated with the pointer resting over the I-beam view.Checklist