From 5a9b8e2bc40098186cbad4a763b0aeffe2ddc1f9 Mon Sep 17 00:00:00 2001 From: Philipp Thiel Date: Wed, 25 Oct 2023 11:16:57 +0200 Subject: [PATCH] views: Add can_activate parameter to AddOverlayView --- include/capi/views/cef_window_capi.h | 10 ++++++---- include/cef_api_hash.h | 8 ++++---- include/views/cef_window.h | 8 +++++--- libcef/browser/views/overlay_view_host.cc | 8 ++++++-- libcef/browser/views/overlay_view_host.h | 2 +- libcef/browser/views/window_impl.cc | 5 +++-- libcef/browser/views/window_impl.h | 3 ++- libcef/browser/views/window_view.cc | 5 +++-- libcef/browser/views/window_view.h | 3 ++- libcef_dll/cpptoc/views/window_cpptoc.cc | 8 +++++--- libcef_dll/ctocpp/views/window_ctocpp.cc | 7 ++++--- libcef_dll/ctocpp/views/window_ctocpp.h | 5 +++-- tests/cefclient/browser/views_overlay_controls.cc | 10 ++++++---- 13 files changed, 50 insertions(+), 32 deletions(-) diff --git a/include/capi/views/cef_window_capi.h b/include/capi/views/cef_window_capi.h index 8d0f1bbb5..358111a04 100644 --- a/include/capi/views/cef_window_capi.h +++ b/include/capi/views/cef_window_capi.h @@ -33,7 +33,7 @@ // by hand. See the translator.README.txt file in the tools directory for // more information. // -// $hash=6078993477d8e0570528593193ec06efbfd0843c$ +// $hash=dbe89dfdd14eb114e3f2d16fbfc55624bb91e7ce$ // #ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_CAPI_H_ @@ -220,8 +220,9 @@ typedef struct _cef_window_t { /// /// Add a View that will be overlayed on the Window contents with absolute /// positioning and high z-order. Positioning is controlled by |docking_mode| - /// as described below. The returned cef_overlay_controller_t object is used - /// to control the overlay. Overlays are hidden by default. + /// as described below. Setting |can_activate| to true (1) will allow the + /// overlay view to receive input focus. The returned cef_overlay_controller_t + /// object is used to control the overlay. Overlays are hidden by default. /// /// With CEF_DOCKING_MODE_CUSTOM: /// 1. The overlay is initially hidden, sized to |view|'s preferred size, @@ -249,7 +250,8 @@ typedef struct _cef_window_t { struct _cef_overlay_controller_t*(CEF_CALLBACK* add_overlay_view)( struct _cef_window_t* self, struct _cef_view_t* view, - cef_docking_mode_t docking_mode); + cef_docking_mode_t docking_mode, + int can_activate); /// /// Show a menu with contents |menu_model|. |screen_point| specifies the menu diff --git a/include/cef_api_hash.h b/include/cef_api_hash.h index cb5369828..880bcab14 100644 --- a/include/cef_api_hash.h +++ b/include/cef_api_hash.h @@ -42,13 +42,13 @@ // way that may cause binary incompatibility with other builds. The universal // hash value will change if any platform is affected whereas the platform hash // values will change only if that particular platform is affected. -#define CEF_API_HASH_UNIVERSAL "69a7afd400063d0f991bf5cb849d09f78d9d46a2" +#define CEF_API_HASH_UNIVERSAL "d14f0a1044fad3677f4e3541ad4becc55e3e1a21" #if defined(OS_WIN) -#define CEF_API_HASH_PLATFORM "d78cbef49838e5693b0a975f66524c2081fafd1d" +#define CEF_API_HASH_PLATFORM "74ea462bd443de49ae328d73dcbd1e4fde5d6cc5" #elif defined(OS_MAC) -#define CEF_API_HASH_PLATFORM "aa42d428bf206f59341c995d51c67e2de0e0b1c2" +#define CEF_API_HASH_PLATFORM "8716cddadbd9316af1313f3cb8f8a42acdad369c" #elif defined(OS_LINUX) -#define CEF_API_HASH_PLATFORM "1f039256db5c820543540263202520b667825d6a" +#define CEF_API_HASH_PLATFORM "12843112055d55c94bb2ea66f62b4935962d5c7e" #endif #ifdef __cplusplus diff --git a/include/views/cef_window.h b/include/views/cef_window.h index 80a522e52..6d979b1bf 100644 --- a/include/views/cef_window.h +++ b/include/views/cef_window.h @@ -233,8 +233,9 @@ class CefWindow : public CefPanel { /// /// Add a View that will be overlayed on the Window contents with absolute /// positioning and high z-order. Positioning is controlled by |docking_mode| - /// as described below. The returned CefOverlayController object is used to - /// control the overlay. Overlays are hidden by default. + /// as described below. Setting |can_activate| to true will allow the overlay + /// view to receive input focus. The returned CefOverlayController object is + /// used to control the overlay. Overlays are hidden by default. /// /// With CEF_DOCKING_MODE_CUSTOM: /// 1. The overlay is initially hidden, sized to |view|'s preferred size, @@ -262,7 +263,8 @@ class CefWindow : public CefPanel { /*--cef()--*/ virtual CefRefPtr AddOverlayView( CefRefPtr view, - cef_docking_mode_t docking_mode) = 0; + cef_docking_mode_t docking_mode, + bool can_activate) = 0; /// /// Show a menu with contents |menu_model|. |screen_point| specifies the menu diff --git a/libcef/browser/views/overlay_view_host.cc b/libcef/browser/views/overlay_view_host.cc index 43ca479f7..8dd687e4c 100644 --- a/libcef/browser/views/overlay_view_host.cc +++ b/libcef/browser/views/overlay_view_host.cc @@ -167,7 +167,9 @@ CefOverlayViewHost::CefOverlayViewHost(CefWindowView* window_view, cef_docking_mode_t docking_mode) : window_view_(window_view), docking_mode_(docking_mode) {} -void CefOverlayViewHost::Init(views::View* host_view, CefRefPtr view) { +void CefOverlayViewHost::Init(views::View* host_view, + CefRefPtr view, + bool can_activate) { DCHECK(view); // Match the logic in CEF_PANEL_IMPL_D::AddChildView(). @@ -186,7 +188,9 @@ void CefOverlayViewHost::Init(views::View* host_view, CefRefPtr view) { params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; params.parent = window_view_->GetWidget()->GetNativeView(); params.opacity = views::Widget::InitParams::WindowOpacity::kTranslucent; - params.activatable = views::Widget::InitParams::Activatable::kNo; + params.activatable = can_activate + ? views::Widget::InitParams::Activatable::kYes + : views::Widget::InitParams::Activatable::kNo; widget_->Init(std::move(params)); view_ = widget_->GetContentsView()->AddChildView(std::move(controls_view)); diff --git a/libcef/browser/views/overlay_view_host.h b/libcef/browser/views/overlay_view_host.h index e761d6cfa..2b80aae48 100644 --- a/libcef/browser/views/overlay_view_host.h +++ b/libcef/browser/views/overlay_view_host.h @@ -32,7 +32,7 @@ class CefOverlayViewHost : public views::WidgetDelegate, // paints into. On Aura platforms, |host_view| is the view whose position in // the |window_view_| view hierarchy determines the z-order of the widget // relative to views with layers and views with associated NativeViews. - void Init(views::View* host_view, CefRefPtr view); + void Init(views::View* host_view, CefRefPtr view, bool can_activate); void Destroy(); diff --git a/libcef/browser/views/window_impl.cc b/libcef/browser/views/window_impl.cc index da73c8ad4..b98d27bf3 100644 --- a/libcef/browser/views/window_impl.cc +++ b/libcef/browser/views/window_impl.cc @@ -349,10 +349,11 @@ CefRefPtr CefWindowImpl::GetWindowAppIcon() { CefRefPtr CefWindowImpl::AddOverlayView( CefRefPtr view, - cef_docking_mode_t docking_mode) { + cef_docking_mode_t docking_mode, + bool can_activate) { CEF_REQUIRE_VALID_RETURN(nullptr); if (root_view()) { - return root_view()->AddOverlayView(view, docking_mode); + return root_view()->AddOverlayView(view, docking_mode, can_activate); } return nullptr; } diff --git a/libcef/browser/views/window_impl.h b/libcef/browser/views/window_impl.h index 6b137d1a8..a207bdf42 100644 --- a/libcef/browser/views/window_impl.h +++ b/libcef/browser/views/window_impl.h @@ -67,7 +67,8 @@ class CefWindowImpl CefRefPtr GetWindowAppIcon() override; CefRefPtr AddOverlayView( CefRefPtr view, - cef_docking_mode_t docking_mode) override; + cef_docking_mode_t docking_mode, + bool can_activate) override; void ShowMenu(CefRefPtr menu_model, const CefPoint& screen_point, cef_menu_anchor_position_t anchor_position) override; diff --git a/libcef/browser/views/window_view.cc b/libcef/browser/views/window_view.cc index 2d12d1964..a94622bca 100644 --- a/libcef/browser/views/window_view.cc +++ b/libcef/browser/views/window_view.cc @@ -795,7 +795,8 @@ void CefWindowView::SetWindowAppIcon(CefRefPtr window_app_icon) { CefRefPtr CefWindowView::AddOverlayView( CefRefPtr view, - cef_docking_mode_t docking_mode) { + cef_docking_mode_t docking_mode, + bool can_activate) { DCHECK(view.get()); DCHECK(view->IsValid()); if (!view.get() || !view->IsValid()) { @@ -811,7 +812,7 @@ CefRefPtr CefWindowView::AddOverlayView( std::make_unique(this, docking_mode)); auto& overlay_host = overlay_hosts_.back(); - overlay_host->Init(overlay_host_view, view); + overlay_host->Init(overlay_host_view, view, can_activate); return overlay_host->controller(); } diff --git a/libcef/browser/views/window_view.h b/libcef/browser/views/window_view.h index b065f3700..882acd569 100644 --- a/libcef/browser/views/window_view.h +++ b/libcef/browser/views/window_view.h @@ -105,7 +105,8 @@ class CefWindowView CefRefPtr AddOverlayView( CefRefPtr view, - cef_docking_mode_t docking_mode); + cef_docking_mode_t docking_mode, + bool can_activate); // Set/get the draggable regions. void SetDraggableRegions(const std::vector& regions); diff --git a/libcef_dll/cpptoc/views/window_cpptoc.cc b/libcef_dll/cpptoc/views/window_cpptoc.cc index 5f9637cdd..d920d1675 100644 --- a/libcef_dll/cpptoc/views/window_cpptoc.cc +++ b/libcef_dll/cpptoc/views/window_cpptoc.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=9c7fea32f82cc202af9aac038b78000ed45aac2e$ +// $hash=a5f9a7de12728e82f8dee6d8dde3b9275a3e4ee4$ // #include "libcef_dll/cpptoc/views/window_cpptoc.h" @@ -467,7 +467,8 @@ window_get_window_app_icon(struct _cef_window_t* self) { cef_overlay_controller_t* CEF_CALLBACK window_add_overlay_view(struct _cef_window_t* self, cef_view_t* view, - cef_docking_mode_t docking_mode) { + cef_docking_mode_t docking_mode, + int can_activate) { shutdown_checker::AssertNotShutdown(); // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -485,7 +486,8 @@ window_add_overlay_view(struct _cef_window_t* self, // Execute CefRefPtr _retval = CefWindowCppToC::Get(self)->AddOverlayView(CefViewCppToC::Unwrap(view), - docking_mode); + docking_mode, + can_activate ? true : false); // Return type: refptr_same return CefOverlayControllerCppToC::Wrap(_retval); diff --git a/libcef_dll/ctocpp/views/window_ctocpp.cc b/libcef_dll/ctocpp/views/window_ctocpp.cc index 303aa281b..c02123f88 100644 --- a/libcef_dll/ctocpp/views/window_ctocpp.cc +++ b/libcef_dll/ctocpp/views/window_ctocpp.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=a4d3216f156716d777fe549428568b38391fd06d$ +// $hash=a49624e0b20c4a50ff719c492d7101099646000f$ // #include "libcef_dll/ctocpp/views/window_ctocpp.h" @@ -461,7 +461,8 @@ CefRefPtr CefWindowCToCpp::GetWindowAppIcon() { NO_SANITIZE("cfi-icall") CefRefPtr CefWindowCToCpp::AddOverlayView( CefRefPtr view, - cef_docking_mode_t docking_mode) { + cef_docking_mode_t docking_mode, + bool can_activate) { shutdown_checker::AssertNotShutdown(); cef_window_t* _struct = GetStruct(); @@ -479,7 +480,7 @@ CefRefPtr CefWindowCToCpp::AddOverlayView( // Execute cef_overlay_controller_t* _retval = _struct->add_overlay_view( - _struct, CefViewCToCpp::Unwrap(view), docking_mode); + _struct, CefViewCToCpp::Unwrap(view), docking_mode, can_activate); // Return type: refptr_same return CefOverlayControllerCToCpp::Wrap(_retval); diff --git a/libcef_dll/ctocpp/views/window_ctocpp.h b/libcef_dll/ctocpp/views/window_ctocpp.h index bf3f03add..cc346a219 100644 --- a/libcef_dll/ctocpp/views/window_ctocpp.h +++ b/libcef_dll/ctocpp/views/window_ctocpp.h @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=35ef2ba61ce63ffcc269a326874d135090b0937a$ +// $hash=5b562d0924fd4a825f43ae7735c1fc98c474de6a$ // #ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_WINDOW_CTOCPP_H_ @@ -64,7 +64,8 @@ class CefWindowCToCpp CefRefPtr GetWindowAppIcon() override; CefRefPtr AddOverlayView( CefRefPtr view, - cef_docking_mode_t docking_mode) override; + cef_docking_mode_t docking_mode, + bool can_activate) override; void ShowMenu(CefRefPtr menu_model, const CefPoint& screen_point, cef_menu_anchor_position_t anchor_position) override; diff --git a/tests/cefclient/browser/views_overlay_controls.cc b/tests/cefclient/browser/views_overlay_controls.cc index 582f0e12a..7fa294bcc 100644 --- a/tests/cefclient/browser/views_overlay_controls.cc +++ b/tests/cefclient/browser/views_overlay_controls.cc @@ -108,7 +108,8 @@ void ViewsOverlayControls::Initialize(CefRefPtr window, panel_->AddChildView(CreateButton(button)); } panel_controller_ = window->AddOverlayView( - panel_, GetPanelDockingMode(use_bottom_controls_)); + panel_, GetPanelDockingMode(use_bottom_controls_), + /*can_activate=*/false); panel_controller_->SetInsets(insets); panel_controller_->SetVisible(true); } @@ -116,7 +117,8 @@ void ViewsOverlayControls::Initialize(CefRefPtr window, // Menu button. menu_button->SetBackgroundColor(kBackgroundColor); menu_controller_ = window_->AddOverlayView( - menu_button, GetMenuDockingMode(use_bottom_controls_)); + menu_button, GetMenuDockingMode(use_bottom_controls_), + /*can_activate=*/false); menu_controller_->SetInsets(insets); menu_controller_->SetVisible(true); @@ -125,8 +127,8 @@ void ViewsOverlayControls::Initialize(CefRefPtr window, is_chrome_toolbar_ = is_chrome_toolbar; // Use a 100% transparent background for the Chrome toolbar. location_bar_->SetBackgroundColor(is_chrome_toolbar_ ? 0 : kBackgroundColor); - location_controller_ = - window_->AddOverlayView(location_bar_, CEF_DOCKING_MODE_CUSTOM); + location_controller_ = window_->AddOverlayView( + location_bar_, CEF_DOCKING_MODE_CUSTOM, /*can_activate=*/false); } void ViewsOverlayControls::Destroy() {