mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
mac: cefclient: Use RootWindowManager to track key window status (fixes issue #3307)
This change provides a generic solution for active (key) window tracking that works with both Views-hosted and native windows on MacOS. With this new approach we can now successfully route top menu actions to the currently active window. Prior to this change CEF's Views API was using focus notifications as a proxy for window activation notifications. That doesn't work on MacOS where NSWindow activation (key status) is independent of NSView focus (first responder) status, and changes in activation don't necessarily generate focus notifications (see NativeWidgetMac::OnWindowKeyStatusChanged). To make this work reliably on all platforms we now expose a CefWindowDelegate::OnWindowActivationChanged callback. This change also fixes an uninitialized variable (RootWindowMacImpl::with_extension_) that was causing flaky behavior in RootWindowManager::OnRootWindowActivated. To test: 1. Run `cefclient [--use-views]` 2. Select Popup Window from the Tests menu. Do not explicitly activate the popup window (e.g. don't click on it). 3. Verify that further Tests menu actions go to the popup window. 4. Change activation to a first window by clicking on it. Verify that Test menu actions go to that window. 5. Close the currently active window. Do not explicitly activate the remaining window (e.g. don't click on it). 6. Verify that Test menu actions go to the only remaining window.
This commit is contained in:
@ -9,7 +9,7 @@
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
// $hash=6639552a1a56f42d7f73ffec99d28fb98173dbd1$
|
||||
// $hash=60fce570867addbf622a0f74422d225f23942e4d$
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/views/window_delegate_cpptoc.h"
|
||||
@ -62,6 +62,27 @@ window_delegate_on_window_destroyed(struct _cef_window_delegate_t* self,
|
||||
CefWindowCToCpp::Wrap(window));
|
||||
}
|
||||
|
||||
void CEF_CALLBACK window_delegate_on_window_activation_changed(
|
||||
struct _cef_window_delegate_t* self,
|
||||
cef_window_t* window,
|
||||
int active) {
|
||||
shutdown_checker::AssertNotShutdown();
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return;
|
||||
// Verify param: window; type: refptr_diff
|
||||
DCHECK(window);
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
// Execute
|
||||
CefWindowDelegateCppToC::Get(self)->OnWindowActivationChanged(
|
||||
CefWindowCToCpp::Wrap(window), active ? true : false);
|
||||
}
|
||||
|
||||
cef_window_t* CEF_CALLBACK
|
||||
window_delegate_get_parent_window(struct _cef_window_delegate_t* self,
|
||||
cef_window_t* window,
|
||||
@ -575,6 +596,8 @@ void CEF_CALLBACK window_delegate_on_blur(struct _cef_view_delegate_t* self,
|
||||
CefWindowDelegateCppToC::CefWindowDelegateCppToC() {
|
||||
GetStruct()->on_window_created = window_delegate_on_window_created;
|
||||
GetStruct()->on_window_destroyed = window_delegate_on_window_destroyed;
|
||||
GetStruct()->on_window_activation_changed =
|
||||
window_delegate_on_window_activation_changed;
|
||||
GetStruct()->get_parent_window = window_delegate_get_parent_window;
|
||||
GetStruct()->get_initial_bounds = window_delegate_get_initial_bounds;
|
||||
GetStruct()->get_initial_show_state = window_delegate_get_initial_show_state;
|
||||
|
Reference in New Issue
Block a user