Implement state synchronization for IsVisibleOnAllWorkspaces between remote window bridge and host

Commit: 12f1d11d | 2026-02-10 17:10:54

← Back to List

Implement state synchronization for IsVisibleOnAllWorkspaces between remote window bridge and host

Moderate
Commit Hash: 12f1d11dc1708d372e8a847896a03fdb3487f3c5
Commit Time: 2026-02-10 17:10:54
Impact Level: Moderate
Generated By: webview2-upstream-sentry

📋 Summary

This commit implements synchronization of the window's "visible on all workspaces" state between the Remote Cocoa window bridge (App Shim side) and the host (Browser side) on macOS. Previously NativeWidgetMac::IsVisibleOnAllWorkspaces() was a stub always returning false. Changes include: a new CheckAndNotifyAllWorkspacesStateChanged() method in NativeWidgetNSWindowBridge that detects state changes by checking whether NSWindow's collectionBehavior includes NSWindowCollectionBehaviorCanJoinAllSpaces; a new OnVisibleOnAllWorkspacesChanged Mojo callback in NativeWidgetNSWindowHost; NativeWidgetMacNSWindowHost receives the callback, updates the cached is_visible_on_all_workspaces_ state and triggers Widget::OnNativeWidgetWorkspaceChanged(); NativeWidgetMac::IsVisibleOnAllWorkspaces() now reads the real value from the host cache. State checks are triggered during window initialization, SetVisibleOnAllSpaces calls, and window geometry changes.

🎯 Impact Analysis

This change has a moderate impact on WebView2Mac. Edge downstream has a HostingNSWindowBridge class in edge_embedded_browser/client/mac/remote_cocoa/ that inherits from NativeWidgetNSWindowBridge and overrides SetVisibleOnAllSpaces. The downstream override explicitly skips modifying NSWindow's collectionBehavior when is_embedded_webview_ is true (since an embedded WebView should not change the host window's workspace behavior). The upstream CheckAndNotifyAllWorkspacesStateChanged() is called from the base class during SetVisibleOnAllSpaces, window initialization, and geometry changes. Since the downstream override of SetVisibleOnAllSpaces does not call the base implementation in embedded mode, that path won't trigger the check. However, the window initialization and geometry change paths will still trigger the base class's CheckAndNotifyAllWorkspacesStateChanged(), potentially sending workspace state change notifications for the embedded WebView's host window. The downstream does not override CheckAndNotifyAllWorkspacesStateChanged and will inherit the upstream behavior. It is recommended to verify whether workspace state notifications in the embedded WebView scenario cause any side effects.

Impacted Classes:

remote_cocoa::NativeWidgetNSWindowBridge remote_cocoa::mojom::NativeWidgetNSWindowHost views::NativeWidgetMacNSWindowHost views::NativeWidgetMac embedded_browser_webview::HostingNSWindowBridge