mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-16 12:10:41 +01:00
mac: views: Always initialize CommandDispatcher (see #3188)
ChromeCommandDispatcherDelegate forwards accelerator events to the FocusManager through NativeWidgetMacNSWindowHost:: HandleAccelerator. Always initialize it so that accelerators also work in a CefWindow without a BrowserView.
This commit is contained in:
parent
a231b7ead7
commit
29ef97d6b5
@ -52,6 +52,7 @@ class CefNativeWidgetMac : public views::NativeWidgetMac {
|
|||||||
bool IsCefWindowInitialized() const;
|
bool IsCefWindowInitialized() const;
|
||||||
|
|
||||||
raw_ptr<BrowserView, AcrossTasksDanglingUntriaged> browser_view_ = nullptr;
|
raw_ptr<BrowserView, AcrossTasksDanglingUntriaged> browser_view_ = nullptr;
|
||||||
|
bool initialized_ = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CEF_LIBCEF_BROWSER_VIEWS_NATIVE_WIDGET_MAC_H_
|
#endif // CEF_LIBCEF_BROWSER_VIEWS_NATIVE_WIDGET_MAC_H_
|
||||||
|
@ -138,7 +138,12 @@ void CefNativeWidgetMac::OnWindowFullscreenTransitionComplete() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CefNativeWidgetMac::OnWindowInitialized() {
|
void CefNativeWidgetMac::OnWindowInitialized() {
|
||||||
if (!browser_view_) {
|
// This connects the native widget with the command dispatcher so accelerators
|
||||||
|
// work even if a browser_view_ is not created later.
|
||||||
|
// The initialized_ check is necessary because the method can be called twice:
|
||||||
|
// 1. From NativeWidgetMac::InitNativeWidget
|
||||||
|
// 2. From ChromeBrowserFrame::Init
|
||||||
|
if (initialized_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,10 +151,12 @@ void CefNativeWidgetMac::OnWindowInitialized() {
|
|||||||
if (auto* bridge = GetInProcessNSWindowBridge()) {
|
if (auto* bridge = GetInProcessNSWindowBridge()) {
|
||||||
bridge->SetCommandDispatcher([[ChromeCommandDispatcherDelegate alloc] init],
|
bridge->SetCommandDispatcher([[ChromeCommandDispatcherDelegate alloc] init],
|
||||||
[[BrowserWindowCommandHandler alloc] init]);
|
[[BrowserWindowCommandHandler alloc] init]);
|
||||||
} else {
|
initialized_ = true;
|
||||||
|
} else if (browser_view_) {
|
||||||
if (auto* host = GetHostForBrowser(browser_view_->browser())) {
|
if (auto* host = GetHostForBrowser(browser_view_->browser())) {
|
||||||
host->GetAppShim()->CreateCommandDispatcherForWidget(
|
host->GetAppShim()->CreateCommandDispatcherForWidget(
|
||||||
GetNSWindowHost()->bridged_native_widget_id());
|
GetNSWindowHost()->bridged_native_widget_id());
|
||||||
|
initialized_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user