Fix spurious mouse cursor reset in fullscreen on Mac

Commit: 3975a5b2 | 2026-03-13 16:12:25

← Back to List

Fix spurious mouse cursor reset in fullscreen on Mac

Minor
Commit Hash: 3975a5b23cd803a6114ecc06e9fe4a4a2671d27d
Commit Time: 2026-03-13 16:12:25
Impact Level: Minor
Generated By: webview2-upstream-sentry
Upstream Review: View Upstream Review 🔗

📋 Summary

This commit fixes a spurious mouse cursor reset issue in macOS immersive fullscreen mode. When the toolbar auto-hides, the AppKit-managed NSToolbarFullScreenWindow remains positioned at the top of the screen. While this window is transparent to mouse events (events pass through to Chrome's main window), macOS incorrectly resets the system cursor to the default arrow when the mouse crosses the bottom boundary of that invisible window. The fix adds logic in RenderWidgetHostViewCocoa's mouseEvent: method to detect when [NSCursor currentSystemCursor] diverges from Chrome's _currentCursor state during mouse move or drag events, and forcefully re-applies the correct cursor.

🎯 Impact Analysis

The impact of this change on WebView2Mac is minor. Key analysis:

1. **Change is in content-layer RenderWidgetHostViewCocoa**: The modified file content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm handles mouse events at the Chromium content layer, running in the app shim process. WebView2Mac's embedded WebView also uses RenderWidgetHostViewCocoa for mouse event handling, so this change will be inherited by WebView2Mac.

2. **Fullscreen scenario has limited impact on WebView2Mac**: This fix specifically targets the cursor reset issue caused by NSToolbarFullScreenWindow in browser immersive fullscreen mode. As an embedded control, WebView2Mac typically does not enter the browser's immersive fullscreen mode (managed by ImmersiveModeController), so the trigger scenario for this bug is rare in WebView2Mac contexts.

3. **General cursor management improvement**: The added cursor correction logic (checking system cursor consistency during mouse move/drag) is a defensive check not limited to fullscreen scenarios. If WebView2Mac's runtime environment has similar situations where the system cursor is reset by external windows, this fix provides protection.

4. **No breaking risk**: The fix only forces cursor update when currentSystemCursor diverges from _currentCursor, and is guarded by shouldChangeCurrentCursor (which checks mouse position within view bounds, key window status, context menu visibility, etc.). UI elements overlaying the WebView (popups, context menus) intercept mouse events before they reach RenderWidgetHostViewCocoa, preventing cursor conflicts.

Impacted Classes:

content::RenderWidgetHostViewCocoa