From 6bd43a70c23d407ca6c4d4a68f0e95eb3301290a Mon Sep 17 00:00:00 2001 From: Roger Zanoni Date: Tue, 4 Jul 2023 12:10:41 +0200 Subject: [PATCH 09/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 52ccb7dc5..fd3e1c1b5 100644 --- a/include/views/cef_window.h +++ b/include/views/cef_window.h @@ -63,6 +63,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 485943ec6..35df22c51 100644 --- a/libcef/browser/views/window_impl.cc +++ b/libcef/browser/views/window_impl.cc @@ -115,14 +115,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); if (delegate) delegate->OnWindowCreated(window.get()); return window; @@ -678,10 +683,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 89c136873..d3330dfd8 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; @@ -155,7 +156,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_; diff --git a/libcef/browser/views/window_view.cc b/libcef/browser/views/window_view.cc index 1e8d58a32..f4bf79ce3 100644 --- a/libcef/browser/views/window_view.cc +++ b/libcef/browser/views/window_view.cc @@ -255,7 +255,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 @@ -265,6 +265,7 @@ void CefWindowView::CreateWidget(gfx::AcceleratedWidget parent_widget) { views::Widget::InitParams params; params.delegate = this; + params.wayland_app_id = app_id; bool can_activate = true; bool can_resize = true; diff --git a/libcef/browser/views/window_view.h b/libcef/browser/views/window_view.h index 6789636b8..ca593c60a 100644 --- a/libcef/browser/views/window_view.h +++ b/libcef/browser/views/window_view.h @@ -51,7 +51,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.39.2