mac: views: Add CefWindowDelegate::OnWindowFullscreenTransition

This commit is contained in:
Nik Pavlov 2023-04-20 14:59:15 +00:00 committed by Marshall Greenblatt
parent 06a2f796b3
commit b09c4ca5f8
8 changed files with 94 additions and 10 deletions

View File

@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for // by hand. See the translator.README.txt file in the tools directory for
// more information. // more information.
// //
// $hash=9f0389a439e6787282880d53375369829adb6a3d$ // $hash=7201d268e16fc89f255b6ccd00d043f34fe77584$
// //
#ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_DELEGATE_CAPI_H_ #ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_DELEGATE_CAPI_H_
@ -139,7 +139,7 @@ typedef struct _cef_window_delegate_t {
/// ///
/// Return true (1) if |window| should be created with standard window buttons /// Return true (1) if |window| should be created with standard window buttons
/// like close, minimize and zoom. /// like close, minimize and zoom. This function is only supported on macOS.
/// ///
int(CEF_CALLBACK* with_standard_window_buttons)( int(CEF_CALLBACK* with_standard_window_buttons)(
struct _cef_window_delegate_t* self, struct _cef_window_delegate_t* self,
@ -198,6 +198,17 @@ typedef struct _cef_window_delegate_t {
int(CEF_CALLBACK* on_key_event)(struct _cef_window_delegate_t* self, int(CEF_CALLBACK* on_key_event)(struct _cef_window_delegate_t* self,
struct _cef_window_t* window, struct _cef_window_t* window,
const cef_key_event_t* event); const cef_key_event_t* event);
///
/// Called when the |window| is transitioning to or from fullscreen mode. The
/// transition occurs in two stages, with |is_competed| set to false (0) when
/// the transition starts and true (1) when the transition completes. This
/// function is only supported on macOS.
///
void(CEF_CALLBACK* on_window_fullscreen_transition)(
struct _cef_window_delegate_t* self,
struct _cef_window_t* window,
int is_completed);
} cef_window_delegate_t; } cef_window_delegate_t;
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -42,13 +42,13 @@
// way that may cause binary incompatibility with other builds. The universal // way that may cause binary incompatibility with other builds. The universal
// hash value will change if any platform is affected whereas the platform hash // hash value will change if any platform is affected whereas the platform hash
// values will change only if that particular platform is affected. // values will change only if that particular platform is affected.
#define CEF_API_HASH_UNIVERSAL "149694d7fffd78ef85e127229819c69e2189ef32" #define CEF_API_HASH_UNIVERSAL "7c7515822b869395898c705bcc350222c26e8734"
#if defined(OS_WIN) #if defined(OS_WIN)
#define CEF_API_HASH_PLATFORM "6f31babeb3f7d2723af55fbd32868284694e4015" #define CEF_API_HASH_PLATFORM "54e2eed5aee11d5dbd88808a54f3e93a7bc17b0c"
#elif defined(OS_MAC) #elif defined(OS_MAC)
#define CEF_API_HASH_PLATFORM "ff1bc603897dca8e100a1d4f9391ef4e49db02df" #define CEF_API_HASH_PLATFORM "0f491b440d7e9e318146ed06cdeca86972e801c5"
#elif defined(OS_LINUX) #elif defined(OS_LINUX)
#define CEF_API_HASH_PLATFORM "7f1ef8d0456bdcaff80c4e15a9806c603f204455" #define CEF_API_HASH_PLATFORM "b5a01a70d1d15078988ca7d694c355503d5b5ad6"
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -130,7 +130,7 @@ class CefWindowDelegate : public CefPanelDelegate {
/// ///
/// Return true if |window| should be created with standard window buttons /// Return true if |window| should be created with standard window buttons
/// like close, minimize and zoom. /// like close, minimize and zoom. This method is only supported on macOS.
/// ///
/*--cef()--*/ /*--cef()--*/
virtual bool WithStandardWindowButtons(CefRefPtr<CefWindow> window) { virtual bool WithStandardWindowButtons(CefRefPtr<CefWindow> window) {
@ -196,6 +196,16 @@ class CefWindowDelegate : public CefPanelDelegate {
const CefKeyEvent& event) { const CefKeyEvent& event) {
return false; return false;
} }
///
/// Called when the |window| is transitioning to or from fullscreen mode. The
/// transition occurs in two stages, with |is_competed| set to false when the
/// transition starts and true when the transition completes.
/// This method is only supported on macOS.
///
/*--cef()--*/
virtual void OnWindowFullscreenTransition(CefRefPtr<CefWindow> window,
bool is_completed) {}
}; };
#endif // CEF_INCLUDE_VIEWS_CEF_WINDOW_DELEGATE_H_ #endif // CEF_INCLUDE_VIEWS_CEF_WINDOW_DELEGATE_H_

View File

@ -30,6 +30,8 @@ class CefNativeWidgetMac : public views::NativeWidgetMac {
void GetWindowFrameTitlebarHeight(bool* override_titlebar_height, void GetWindowFrameTitlebarHeight(bool* override_titlebar_height,
float* titlebar_height) override; float* titlebar_height) override;
void OnWindowFullscreenTransitionStart() override;
void OnWindowFullscreenTransitionComplete() override;
private: private:
const CefRefPtr<CefWindow> window_; const CefRefPtr<CefWindow> window_;

View File

@ -52,3 +52,13 @@ void CefNativeWidgetMac::GetWindowFrameTitlebarHeight(
override_titlebar_height, titlebar_height); override_titlebar_height, titlebar_height);
} }
} }
void CefNativeWidgetMac::OnWindowFullscreenTransitionStart() {
views::NativeWidgetMac::OnWindowFullscreenTransitionStart();
window_delegate_->OnWindowFullscreenTransition(window_, false);
}
void CefNativeWidgetMac::OnWindowFullscreenTransitionComplete() {
views::NativeWidgetMac::OnWindowFullscreenTransitionComplete();
window_delegate_->OnWindowFullscreenTransition(window_, true);
}

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory // implementations. See the translator.README.txt file in the tools directory
// for more information. // for more information.
// //
// $hash=18f715de465689a4e8484bbced8ad92d9434438a$ // $hash=c7e5e137df27a4986c13e6f4e2b98eac19a48193$
// //
#include "libcef_dll/cpptoc/views/window_delegate_cpptoc.h" #include "libcef_dll/cpptoc/views/window_delegate_cpptoc.h"
@ -484,6 +484,29 @@ window_delegate_on_key_event(struct _cef_window_delegate_t* self,
return _retval; return _retval;
} }
void CEF_CALLBACK window_delegate_on_window_fullscreen_transition(
struct _cef_window_delegate_t* self,
cef_window_t* window,
int is_completed) {
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)->OnWindowFullscreenTransition(
CefWindowCToCpp::Wrap(window), is_completed ? true : false);
}
cef_size_t CEF_CALLBACK cef_size_t CEF_CALLBACK
window_delegate_get_preferred_size(struct _cef_view_delegate_t* self, window_delegate_get_preferred_size(struct _cef_view_delegate_t* self,
cef_view_t* view) { cef_view_t* view) {
@ -770,6 +793,8 @@ CefWindowDelegateCppToC::CefWindowDelegateCppToC() {
GetStruct()->can_close = window_delegate_can_close; GetStruct()->can_close = window_delegate_can_close;
GetStruct()->on_accelerator = window_delegate_on_accelerator; GetStruct()->on_accelerator = window_delegate_on_accelerator;
GetStruct()->on_key_event = window_delegate_on_key_event; GetStruct()->on_key_event = window_delegate_on_key_event;
GetStruct()->on_window_fullscreen_transition =
window_delegate_on_window_fullscreen_transition;
GetStruct()->base.base.get_preferred_size = GetStruct()->base.base.get_preferred_size =
window_delegate_get_preferred_size; window_delegate_get_preferred_size;
GetStruct()->base.base.get_minimum_size = window_delegate_get_minimum_size; GetStruct()->base.base.get_minimum_size = window_delegate_get_minimum_size;

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory // implementations. See the translator.README.txt file in the tools directory
// for more information. // for more information.
// //
// $hash=40aea12873a3c8803c9d2d6c06a0270197ead58e$ // $hash=5d3fd8439bbc051bac61497b125a7ac35859881d$
// //
#include "libcef_dll/ctocpp/views/window_delegate_ctocpp.h" #include "libcef_dll/ctocpp/views/window_delegate_ctocpp.h"
@ -462,6 +462,30 @@ bool CefWindowDelegateCToCpp::OnKeyEvent(CefRefPtr<CefWindow> window,
return _retval ? true : false; return _retval ? true : false;
} }
NO_SANITIZE("cfi-icall")
void CefWindowDelegateCToCpp::OnWindowFullscreenTransition(
CefRefPtr<CefWindow> window,
bool is_completed) {
shutdown_checker::AssertNotShutdown();
cef_window_delegate_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, on_window_fullscreen_transition)) {
return;
}
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: window; type: refptr_diff
DCHECK(window.get());
if (!window.get()) {
return;
}
// Execute
_struct->on_window_fullscreen_transition(
_struct, CefWindowCppToC::Wrap(window), is_completed);
}
NO_SANITIZE("cfi-icall") NO_SANITIZE("cfi-icall")
CefSize CefWindowDelegateCToCpp::GetPreferredSize(CefRefPtr<CefView> view) { CefSize CefWindowDelegateCToCpp::GetPreferredSize(CefRefPtr<CefView> view) {
shutdown_checker::AssertNotShutdown(); shutdown_checker::AssertNotShutdown();

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory // implementations. See the translator.README.txt file in the tools directory
// for more information. // for more information.
// //
// $hash=d100d8866a7eab2a163d4ddb3cacd00141f65757$ // $hash=bf87c473a5bafd3f8c30bd06c033b0182f65a7b7$
// //
#ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_WINDOW_DELEGATE_CTOCPP_H_ #ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_WINDOW_DELEGATE_CTOCPP_H_
@ -60,6 +60,8 @@ class CefWindowDelegateCToCpp
bool OnAccelerator(CefRefPtr<CefWindow> window, int command_id) override; bool OnAccelerator(CefRefPtr<CefWindow> window, int command_id) override;
bool OnKeyEvent(CefRefPtr<CefWindow> window, bool OnKeyEvent(CefRefPtr<CefWindow> window,
const CefKeyEvent& event) override; const CefKeyEvent& event) override;
void OnWindowFullscreenTransition(CefRefPtr<CefWindow> window,
bool is_completed) override;
// CefPanelDelegate methods. // CefPanelDelegate methods.