From 5a8d9996ee7b3ce77f7b3fd3c7839806a034ea16 Mon Sep 17 00:00:00 2001 From: Roger Zanoni Date: Tue, 4 Jul 2023 12:10:41 +0200 Subject: [PATCH 08/10] Allow passing the app_id on widget creation --- include/views/cef_window.h | 6 ++++++ libcef/browser/views/window_impl.cc | 13 +++++++++---- libcef/browser/views/window_impl.h | 6 ++++-- libcef/browser/views/window_view.cc | 3 ++- libcef/browser/views/window_view.h | 2 +- 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/include/views/cef_window.h b/include/views/cef_window.h index 9f196a1e7..16c854b09 100644 --- a/include/views/cef_window.h +++ b/include/views/cef_window.h @@ -65,6 +65,12 @@ class CefWindow : public CefPanel { CefRefPtr delegate); /// + /// Create a new Window with the provided ID + /// + /*--cef()--*/ + static CefRefPtr CreateTopLevelWindowWithId( + CefRefPtr delegate, const CefString& app_id); + /// /// Show the Window. /// /*--cef()--*/ diff --git a/libcef/browser/views/window_impl.cc b/libcef/browser/views/window_impl.cc index 12858364e..f0fe9dfb2 100644 --- a/libcef/browser/views/window_impl.cc +++ b/libcef/browser/views/window_impl.cc @@ -110,14 +110,19 @@ CefRefPtr CefWindow::CreateTopLevelWindow( return CefWindowImpl::Create(delegate, gfx::kNullAcceleratedWidget); } +CefRefPtr CefWindow::CreateTopLevelWindowWithId( + CefRefPtr delegate, const CefString& app_id) { + return CefWindowImpl::Create(delegate, gfx::kNullAcceleratedWidget, app_id); +} + // static CefRefPtr CefWindowImpl::Create( CefRefPtr delegate, - gfx::AcceleratedWidget parent_widget) { + gfx::AcceleratedWidget parent_widget, const CefString& app_id) { CEF_REQUIRE_UIT_RETURN(nullptr); CefRefPtr window = new CefWindowImpl(delegate); window->Initialize(); - window->CreateWidget(parent_widget); + window->CreateWidget(parent_widget, app_id); return window; } @@ -745,10 +750,10 @@ void CefWindowImpl::InitializeRootView() { static_cast(root_view())->Initialize(); } -void CefWindowImpl::CreateWidget(gfx::AcceleratedWidget parent_widget) { +void CefWindowImpl::CreateWidget(gfx::AcceleratedWidget parent_widget, const CefString& app_id) { DCHECK(!widget_); - root_view()->CreateWidget(parent_widget); + root_view()->CreateWidget(parent_widget, app_id); widget_ = root_view()->GetWidget(); DCHECK(widget_); diff --git a/libcef/browser/views/window_impl.h b/libcef/browser/views/window_impl.h index aaca3c281..1c5be736f 100644 --- a/libcef/browser/views/window_impl.h +++ b/libcef/browser/views/window_impl.h @@ -36,7 +36,8 @@ class CefWindowImpl // Create a new CefWindow instance. |delegate| may be nullptr. |parent_widget| // will be used when creating a Chrome child window. static CefRefPtr Create(CefRefPtr delegate, - gfx::AcceleratedWidget parent_widget); + gfx::AcceleratedWidget parent_widget, + const CefString& app_id = ""); // CefWindow methods: void Show() override; @@ -157,7 +158,8 @@ class CefWindowImpl void InitializeRootView() override; // Initialize the Widget. - void CreateWidget(gfx::AcceleratedWidget parent_widget); + void CreateWidget(gfx::AcceleratedWidget parent_widget, + const CefString& app_id = ""); views::Widget* widget_ = nullptr; diff --git a/libcef/browser/views/window_view.cc b/libcef/browser/views/window_view.cc index 2331caaea..5e4cb6b53 100644 --- a/libcef/browser/views/window_view.cc +++ b/libcef/browser/views/window_view.cc @@ -371,7 +371,7 @@ CefWindowView::CefWindowView(CefWindowDelegate* cef_delegate, DCHECK(window_delegate_); } -void CefWindowView::CreateWidget(gfx::AcceleratedWidget parent_widget) { +void CefWindowView::CreateWidget(gfx::AcceleratedWidget parent_widget, const CefString& app_id) { DCHECK(!GetWidget()); // |widget| is owned by the NativeWidget and will be destroyed in response to @@ -381,6 +381,7 @@ void CefWindowView::CreateWidget(gfx::AcceleratedWidget parent_widget) { views::Widget::InitParams params; params.delegate = this; + params.wayland_app_id = app_id; views::Widget* host_widget = nullptr; diff --git a/libcef/browser/views/window_view.h b/libcef/browser/views/window_view.h index b065f3700..c15e75d65 100644 --- a/libcef/browser/views/window_view.h +++ b/libcef/browser/views/window_view.h @@ -52,7 +52,7 @@ class CefWindowView CefWindowView& operator=(const CefWindowView&) = delete; // Create the Widget. - void CreateWidget(gfx::AcceleratedWidget parent_widget); + void CreateWidget(gfx::AcceleratedWidget parent_widget, const CefString& app_id); // Returns the CefWindow associated with this view. See comments on // CefViewView::GetCefView. -- 2.42.1