mirror of
https://github.com/electron/electron.git
synced 2026-01-15 02:18:18 -05:00
When using `views::WebView` on macOS `NativeWidgetMacNSWindowHost` contains a layer and compositor responsible for drawing web contents. To trigger drawing `NativeWidgetMacNSWindowHost::OnVisibilityChanged` needs to be called and `[NSWindow orderFrontRegardless]` does not trigger `[NSWindow orderWindow:relativeTo:]` which can change `NativeWidgetMacNSWindowHost` visiblity with stack: ``` views::NativeWidgetMacNSWindowHost::OnVisibilityChanged(bool) remote_cocoa::NativeWidgetNSWindowBridge::OnVisibilityChanged() -[ViewsNSWindowDelegate onWindowOrderChanged:] -[NativeWidgetMacNSWindow orderWindow:relativeTo:] ``` `views::Widget` has method for showing inactive window: `views::Widget::ShowInactive` which triggers `NativeWidgetMacNSWindowHost::OnVisibilityChanged` with stack: ``` views::NativeWidgetMacNSWindowHost::OnVisibilityChanged(bool) remote_cocoa::NativeWidgetNSWindowBridge::SetVisibilityState(remote_cocoa::mojom::WindowVisibilityState) views::NativeWidgetMacNSWindowHost::SetVisibilityState(remote_cocoa::mojom::WindowVisibilityState) views::NativeWidgetMac::Show(ui::mojom::WindowShowState, gfx::Rect const&) views::Widget::ShowInactive() + 168 ``` However this call seems to be insufficient to bring window to front, therefore `[NSWindow orderFrontRegardless]` still needs to be called. Calling `views::Widget::ShowInactive` ensures that all logic related to showing Chromium widget will be properly executed, but onfortunately it does not call `[NSWindow orderWindow:relativeTo:]` which is used to disabling headless mode by the `ElectronNSWindow`, therefore we need to trigger it manually through exposed `[ElectronNSWindow disableHeadlessMode]`. Fixes: #45415