views: Add can_activate parameter to AddOverlayView

This commit is contained in:
Philipp Thiel 2023-10-25 11:16:57 +02:00 committed by Marshall Greenblatt
parent 2a9696c162
commit 092056ce2d
13 changed files with 50 additions and 32 deletions

View File

@ -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

View File

@ -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

View File

@ -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<CefOverlayController> AddOverlayView(
CefRefPtr<CefView> 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

View File

@ -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<CefView> view) {
void CefOverlayViewHost::Init(views::View* host_view,
CefRefPtr<CefView> 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<CefView> 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));

View File

@ -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<CefView> view);
void Init(views::View* host_view, CefRefPtr<CefView> view, bool can_activate);
void Destroy();

View File

@ -349,10 +349,11 @@ CefRefPtr<CefImage> CefWindowImpl::GetWindowAppIcon() {
CefRefPtr<CefOverlayController> CefWindowImpl::AddOverlayView(
CefRefPtr<CefView> 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;
}

View File

@ -67,7 +67,8 @@ class CefWindowImpl
CefRefPtr<CefImage> GetWindowAppIcon() override;
CefRefPtr<CefOverlayController> AddOverlayView(
CefRefPtr<CefView> view,
cef_docking_mode_t docking_mode) override;
cef_docking_mode_t docking_mode,
bool can_activate) override;
void ShowMenu(CefRefPtr<CefMenuModel> menu_model,
const CefPoint& screen_point,
cef_menu_anchor_position_t anchor_position) override;

View File

@ -795,7 +795,8 @@ void CefWindowView::SetWindowAppIcon(CefRefPtr<CefImage> window_app_icon) {
CefRefPtr<CefOverlayController> CefWindowView::AddOverlayView(
CefRefPtr<CefView> 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<CefOverlayController> CefWindowView::AddOverlayView(
std::make_unique<CefOverlayViewHost>(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();
}

View File

@ -105,7 +105,8 @@ class CefWindowView
CefRefPtr<CefOverlayController> AddOverlayView(
CefRefPtr<CefView> 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<CefDraggableRegion>& regions);

View File

@ -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<CefOverlayController> _retval =
CefWindowCppToC::Get(self)->AddOverlayView(CefViewCppToC::Unwrap(view),
docking_mode);
docking_mode,
can_activate ? true : false);
// Return type: refptr_same
return CefOverlayControllerCppToC::Wrap(_retval);

View File

@ -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<CefImage> CefWindowCToCpp::GetWindowAppIcon() {
NO_SANITIZE("cfi-icall")
CefRefPtr<CefOverlayController> CefWindowCToCpp::AddOverlayView(
CefRefPtr<CefView> 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<CefOverlayController> 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);

View File

@ -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<CefImage> GetWindowAppIcon() override;
CefRefPtr<CefOverlayController> AddOverlayView(
CefRefPtr<CefView> view,
cef_docking_mode_t docking_mode) override;
cef_docking_mode_t docking_mode,
bool can_activate) override;
void ShowMenu(CefRefPtr<CefMenuModel> menu_model,
const CefPoint& screen_point,
cef_menu_anchor_position_t anchor_position) override;

View File

@ -108,7 +108,8 @@ void ViewsOverlayControls::Initialize(CefRefPtr<CefWindow> 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<CefWindow> 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<CefWindow> 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() {