36ae7793739e09701b8ad5bed98a426c441e235d
[AGL/meta-agl-demo.git] / recipes-wam / cef / files / cef / 0006-Add-AGL-wayland-window-related-calls.patch
1 From efba58d289ad381c6ca9fae9ded040c816946894 Mon Sep 17 00:00:00 2001
2 From: Roger Zanoni <rzanoni@igalia.com>
3 Date: Thu, 18 May 2023 10:34:08 +0200
4 Subject: [PATCH 06/10] Add AGL wayland window related calls
5
6 ---
7  include/views/cef_window.h             | 34 ++++++++++++++++
8  libcef/browser/views/view_util.h       | 10 +++++
9  libcef/browser/views/view_util_aura.cc | 54 ++++++++++++++++++++++++++
10  libcef/browser/views/window_impl.cc    | 24 ++++++++++++
11  libcef/browser/views/window_impl.h     | 10 +++++
12  5 files changed, 132 insertions(+)
13
14 diff --git a/include/views/cef_window.h b/include/views/cef_window.h
15 index e34e446bd..dfa7821bc 100644
16 --- a/include/views/cef_window.h
17 +++ b/include/views/cef_window.h
18 @@ -348,6 +348,40 @@ class CefWindow : public CefPanel {
19    ///
20    /*--cef()--*/
21    virtual void RemoveAllAccelerators() = 0;
22 +
23 +  // AGL-related calls
24 +
25 +  ///
26 +  /// Tells the agl compositor to activate the app
27 +  ///
28 +  /*--cef()--*/
29 +  virtual void AglActivateApp(const CefString& app) = 0;
30 +
31 +  ///
32 +  /// Tells the agl compositor the application id
33 +  ///
34 +  /*--cef()--*/
35 +  virtual void AglSetAppId(const CefString& app_id) = 0;
36 +
37 +  ///
38 +  /// Tells the agl compositor that everything is set-up and good to go
39 +  ///
40 +  /*--cef()--*/
41 +  virtual void AglSetAppReady() = 0;
42 +
43 +  ///
44 +  /// Tells the agl compositor that the app is the background application
45 +  ///
46 +  /*--cef()--*/
47 +  virtual void AglSetBackGroundApp() = 0;
48 +
49 +  ///
50 +  /// Tells the agl compositor that the app is a panel
51 +  ///
52 +  /*--cef()--*/
53 +  virtual void AglSetPanelApp(uint32_t edge) = 0;
54 +
55 +  // -----------------
56  };
57  
58  #endif  // CEF_INCLUDE_VIEWS_CEF_WINDOW_H_
59 diff --git a/libcef/browser/views/view_util.h b/libcef/browser/views/view_util.h
60 index 302eee464..505c66d94 100644
61 --- a/libcef/browser/views/view_util.h
62 +++ b/libcef/browser/views/view_util.h
63 @@ -141,6 +141,16 @@ CefWindowHandle GetWindowHandle(views::Widget* widget);
64  // Returns the platform window handle for |window|. May return nullptr.
65  CefWindowHandle GetWindowHandle(gfx::NativeWindow window);
66  
67 +// AGL-Related calls
68 +
69 +void AglActivateApp(views::Widget* widget, const std::string& app);
70 +void AglSetAppId(views::Widget* widget, const std::string& app_id);
71 +void AglSetAppReady(views::Widget* widget);
72 +void AglSetBackGroundApp(views::Widget* widget);
73 +void AglSetPanelApp(views::Widget* widget, uint32_t edge);
74 +
75 +// -----------------
76 +
77  }  // namespace view_util
78  
79  #endif  // CEF_LIBCEF_BROWSER_VIEWS_VIEW_UTIL_H_
80 diff --git a/libcef/browser/views/view_util_aura.cc b/libcef/browser/views/view_util_aura.cc
81 index 8a144eb33..2ad2f3dc7 100644
82 --- a/libcef/browser/views/view_util_aura.cc
83 +++ b/libcef/browser/views/view_util_aura.cc
84 @@ -39,4 +39,58 @@ CefWindowHandle GetWindowHandle(gfx::NativeWindow window) {
85    return kNullWindowHandle;
86  }
87  
88 +// AGL-Related calls
89 +
90 +void AglActivateApp(views::Widget* widget, const std::string& app) {
91 +  if (!widget) {
92 +    return;
93 +  }
94 +  aura::Window* window = widget->GetNativeWindow();
95 +  if (window && window->GetRootWindow()) {
96 +    return window->GetHost()->SetAglActivateApp(app);
97 +  }
98 +}
99 +
100 +void AglSetAppId(views::Widget* widget, const std::string& app_id) {
101 +  if (!widget) {
102 +    return;
103 +  }
104 +  aura::Window* window = widget->GetNativeWindow();
105 +  if (window && window->GetRootWindow()) {
106 +    return window->GetHost()->SetAglAppId(app_id);
107 +  }
108 +}
109 +
110 +void AglSetAppReady(views::Widget* widget) {
111 +  if (!widget) {
112 +    return;
113 +  }
114 +  aura::Window* window = widget->GetNativeWindow();
115 +  if (window && window->GetRootWindow()) {
116 +    return window->GetHost()->SetAglReady();
117 +  }
118 +}
119 +
120 +void AglSetBackGroundApp(views::Widget* widget) {
121 +  if (!widget) {
122 +    return;
123 +  }
124 +  aura::Window* window = widget->GetNativeWindow();
125 +  if (window && window->GetRootWindow()) {
126 +    return window->GetHost()->SetAglBackground();
127 +  }
128 +}
129 +
130 +void AglSetPanelApp(views::Widget* widget, uint32_t edge) {
131 +  if (!widget) {
132 +    return;
133 +  }
134 +  aura::Window* window = widget->GetNativeWindow();
135 +  if (window && window->GetRootWindow()) {
136 +    return window->GetHost()->SetAglPanel(edge);
137 +  }
138 +}
139 +
140 +// -----------------
141 +
142  }  // namespace view_util
143 diff --git a/libcef/browser/views/window_impl.cc b/libcef/browser/views/window_impl.cc
144 index 64e5c443e..22a4d39f6 100644
145 --- a/libcef/browser/views/window_impl.cc
146 +++ b/libcef/browser/views/window_impl.cc
147 @@ -522,6 +522,30 @@ CefWindowHandle CefWindowImpl::GetWindowHandle() {
148    return view_util::GetWindowHandle(widget_);
149  }
150  
151 +// AGL-Related calls
152 +
153 +void CefWindowImpl::AglActivateApp(const CefString& app) {
154 +  view_util::AglActivateApp(widget_, app);
155 +}
156 +
157 +void CefWindowImpl::AglSetAppId(const CefString& app_id) {
158 +  view_util::AglSetAppId(widget_, app_id);
159 +}
160 +
161 +void CefWindowImpl::AglSetAppReady() {
162 +  view_util::AglSetAppReady(widget_);
163 +}
164 +
165 +void CefWindowImpl::AglSetBackGroundApp() {
166 +  view_util::AglSetBackGroundApp(widget_);
167 +}
168 +
169 +void CefWindowImpl::AglSetPanelApp(uint32_t edge) {
170 +  view_util::AglSetPanelApp(widget_, edge);
171 +}
172 +
173 +// -----------------
174 +
175  void CefWindowImpl::SendKeyPress(int key_code, uint32 event_flags) {
176    CEF_REQUIRE_VALID_RETURN_VOID();
177    InitializeUITesting();
178 diff --git a/libcef/browser/views/window_impl.h b/libcef/browser/views/window_impl.h
179 index f9557d415..ad02904f9 100644
180 --- a/libcef/browser/views/window_impl.h
181 +++ b/libcef/browser/views/window_impl.h
182 @@ -132,6 +132,16 @@ class CefWindowImpl
183  
184    views::Widget* widget() const { return widget_; }
185  
186 +  // AGL-Related calls
187 +
188 +  void AglActivateApp(const CefString& app) override;
189 +  void AglSetAppId(const CefString& app_id) override;
190 +  void AglSetAppReady() override;
191 +  void AglSetBackGroundApp() override;
192 +  void AglSetPanelApp(uint32_t edge) override;
193 +
194 +  // -----------------
195 +
196   private:
197    // Create a new implementation object.
198    // Always call Initialize() after creation.
199 -- 
200 2.39.2
201