1 From d50bcc010ca2856979f58b2ffbd0015514c4231f Mon Sep 17 00:00:00 2001
2 From: Roger Zanoni <rzanoni@igalia.com>
3 Date: Wed, 17 May 2023 21:25:53 +0200
4 Subject: [PATCH 02/33] [agl] Add waylandwindow/window tree host essential
7 This is a backport of the work we did on top of chromium webosose to be
8 able to communicate with the agl compositor.
10 Signed-off-by: Roger Zanoni <rzanoni@igalia.com>
12 ui/aura/BUILD.gn | 7 ++
13 ui/aura/agl/window_tree_host_agl.h | 42 +++++++++
14 ui/aura/agl/window_tree_host_platform_agl.cc | 50 +++++++++++
15 ui/aura/agl/window_tree_host_platform_agl.h | 51 +++++++++++
16 ui/aura/window_tree_host.h | 5 +-
17 ui/aura/window_tree_host_platform.cc | 4 +-
18 ui/aura/window_tree_host_platform.h | 4 +-
19 ui/ozone/platform/wayland/BUILD.gn | 1 -
20 .../platform/wayland/extensions/agl/BUILD.gn | 2 +
21 .../agl/host/wayland_extensions_agl.h | 10 ++-
22 .../agl/host/wayland_extensions_agl_impl.cc | 11 ++-
23 .../agl/host/wayland_extensions_agl_impl.h | 9 ++
24 .../extensions/agl/host/wayland_window_agl.cc | 86 +++++++++++++++++++
25 .../extensions/agl/host/wayland_window_agl.h | 49 +++++++++++
26 .../wayland/gpu/gl_surface_wayland.cc | 9 +-
27 .../host/gtk_primary_selection_device.cc | 2 +-
28 .../gtk_primary_selection_device_manager.cc | 4 +-
29 .../wayland/host/proxy/wayland_proxy_impl.cc | 2 +-
30 .../wayland/host/wayland_connection.cc | 19 +++-
31 .../wayland/host/wayland_connection.h | 9 +-
32 .../platform/wayland/host/wayland_cursor.cc | 4 +-
33 .../wayland/host/wayland_data_device.cc | 10 +--
34 .../wayland/host/wayland_data_device_base.cc | 2 +-
35 .../host/wayland_data_drag_controller.cc | 2 +-
36 .../wayland/host/wayland_data_source.cc | 6 +-
37 ui/ozone/platform/wayland/host/wayland_drm.cc | 6 +-
38 .../wayland/host/wayland_extensions.h | 6 ++
39 .../platform/wayland/host/wayland_keyboard.cc | 4 +-
40 .../platform/wayland/host/wayland_popup.cc | 8 +-
41 .../platform/wayland/host/wayland_seat.cc | 2 +-
42 ui/ozone/platform/wayland/host/wayland_shm.cc | 2 +-
43 .../platform/wayland/host/wayland_surface.cc | 2 +-
44 .../wayland/host/wayland_toplevel_window.cc | 18 ++--
45 .../platform/wayland/host/wayland_window.cc | 6 +-
46 .../platform/wayland/host/wayland_window.h | 2 +
47 .../host/wayland_window_drag_controller.cc | 2 +-
48 .../wayland/host/wayland_window_factory.cc | 14 +++
49 .../wayland/host/wayland_zwp_linux_dmabuf.cc | 4 +-
50 .../wayland/host/xdg_foreign_wrapper.cc | 4 +-
51 .../wayland/host/xdg_popup_wrapper_impl.cc | 2 +-
52 .../wayland/host/xdg_surface_wrapper_impl.cc | 2 +-
53 .../wayland/host/xdg_toplevel_wrapper_impl.cc | 2 +-
54 .../host/zwp_primary_selection_device.cc | 2 +-
55 .../zwp_primary_selection_device_manager.cc | 4 +-
56 ui/platform_window/agl/platform_window_agl.h | 36 ++++++++
57 ui/platform_window/platform_window.h | 4 +-
58 46 files changed, 469 insertions(+), 63 deletions(-)
59 create mode 100644 ui/aura/agl/window_tree_host_agl.h
60 create mode 100644 ui/aura/agl/window_tree_host_platform_agl.cc
61 create mode 100644 ui/aura/agl/window_tree_host_platform_agl.h
62 create mode 100644 ui/ozone/platform/wayland/extensions/agl/host/wayland_window_agl.cc
63 create mode 100644 ui/ozone/platform/wayland/extensions/agl/host/wayland_window_agl.h
64 create mode 100644 ui/platform_window/agl/platform_window_agl.h
66 diff --git a/ui/aura/BUILD.gn b/ui/aura/BUILD.gn
67 index 50ca856b9da18..8fa04492f69f7 100644
68 --- a/ui/aura/BUILD.gn
69 +++ b/ui/aura/BUILD.gn
70 @@ -99,6 +99,13 @@ component("aura") {
71 "window_tree_host_platform.cc",
75 + "agl/window_tree_host_agl.h",
76 + "agl/window_tree_host_platform_agl.h"
79 + sources += [ "agl/window_tree_host_platform_agl.cc" ]
83 defines = [ "AURA_IMPLEMENTATION" ]
84 diff --git a/ui/aura/agl/window_tree_host_agl.h b/ui/aura/agl/window_tree_host_agl.h
86 index 0000000000000..858a078d939d0
88 +++ b/ui/aura/agl/window_tree_host_agl.h
90 +// Copyright 2021 LG Electronics, Inc.
92 +// Licensed under the Apache License, Version 2.0 (the "License");
93 +// you may not use this file except in compliance with the License.
94 +// You may obtain a copy of the License at
96 +// http://www.apache.org/licenses/LICENSE-2.0
98 +// Unless required by applicable law or agreed to in writing, software
99 +// distributed under the License is distributed on an "AS IS" BASIS,
100 +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
101 +// See the License for the specific language governing permissions and
102 +// limitations under the License.
104 +// SPDX-License-Identifier: Apache-2.0
106 +#ifndef UI_AURA_AGL_WINDOW_TREE_HOST_AGL_H_
107 +#define UI_AURA_AGL_WINDOW_TREE_HOST_AGL_H_
111 +#include "ui/aura/aura_export.h"
115 +class AURA_EXPORT WindowTreeHostAgl {
117 + WindowTreeHostAgl() = default;
118 + WindowTreeHostAgl(const WindowTreeHostAgl&) = delete;
119 + WindowTreeHostAgl& operator=(const WindowTreeHostAgl&) = delete;
120 + ~WindowTreeHostAgl() = default;
122 + virtual void SetAglActivateApp(const std::string& app) {}
123 + virtual void SetAglAppId(const std::string& title) {}
124 + virtual void SetAglReady() {}
125 + virtual void SetAglBackground() {}
126 + virtual void SetAglPanel(uint32_t edge) {}
131 +#endif // UI_AURA_AGL_WINDOW_TREE_HOST_AGL_H_
132 diff --git a/ui/aura/agl/window_tree_host_platform_agl.cc b/ui/aura/agl/window_tree_host_platform_agl.cc
134 index 0000000000000..e34595fe0ed9c
136 +++ b/ui/aura/agl/window_tree_host_platform_agl.cc
138 +// Copyright 2021 LG Electronics, Inc.
140 +// Licensed under the Apache License, Version 2.0 (the "License");
141 +// you may not use this file except in compliance with the License.
142 +// You may obtain a copy of the License at
144 +// http://www.apache.org/licenses/LICENSE-2.0
146 +// Unless required by applicable law or agreed to in writing, software
147 +// distributed under the License is distributed on an "AS IS" BASIS,
148 +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
149 +// See the License for the specific language governing permissions and
150 +// limitations under the License.
152 +// SPDX-License-Identifier: Apache-2.0
154 +#include "ui/aura/agl/window_tree_host_platform_agl.h"
156 +#include "ui/aura/window_tree_host_platform.h"
157 +#include "ui/platform_window/platform_window.h"
161 +WindowTreeHostPlatformAgl::WindowTreeHostPlatformAgl(
162 + std::unique_ptr<Window> window,
163 + aura::WindowTreeHostPlatform* window_tree_host_platform)
164 + : aura::WindowTreeHost(std::move(window)),
165 + window_tree_host_platform_(window_tree_host_platform) {}
167 +void WindowTreeHostPlatformAgl::SetAglActivateApp(const std::string& app) {
168 + window_tree_host_platform_->platform_window()->SetAglActivateApp(app);
171 +void WindowTreeHostPlatformAgl::SetAglAppId(const std::string& title) {
172 + window_tree_host_platform_->platform_window()->SetAglAppId(title);
175 +void WindowTreeHostPlatformAgl::SetAglReady() {
176 + window_tree_host_platform_->platform_window()->SetAglReady();
179 +void WindowTreeHostPlatformAgl::SetAglBackground() {
180 + window_tree_host_platform_->platform_window()->SetAglBackground();
183 +void WindowTreeHostPlatformAgl::SetAglPanel(uint32_t edge) {
184 + window_tree_host_platform_->platform_window()->SetAglPanel(edge);
188 diff --git a/ui/aura/agl/window_tree_host_platform_agl.h b/ui/aura/agl/window_tree_host_platform_agl.h
190 index 0000000000000..181eefae346f7
192 +++ b/ui/aura/agl/window_tree_host_platform_agl.h
194 +// Copyright 2021 LG Electronics, Inc.
196 +// Licensed under the Apache License, Version 2.0 (the "License");
197 +// you may not use this file except in compliance with the License.
198 +// You may obtain a copy of the License at
200 +// http://www.apache.org/licenses/LICENSE-2.0
202 +// Unless required by applicable law or agreed to in writing, software
203 +// distributed under the License is distributed on an "AS IS" BASIS,
204 +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
205 +// See the License for the specific language governing permissions and
206 +// limitations under the License.
208 +// SPDX-License-Identifier: Apache-2.0
210 +#ifndef UI_AURA_AGL_WINDOW_TREE_HOST_PLATFORM_AGL_H_
211 +#define UI_AURA_AGL_WINDOW_TREE_HOST_PLATFORM_AGL_H_
215 +#include "ui/aura/aura_export.h"
216 +#include "ui/aura/window_tree_host.h"
221 +class WindowTreeHostPlatform;
223 +class AURA_EXPORT WindowTreeHostPlatformAgl : public aura::WindowTreeHost {
225 + explicit WindowTreeHostPlatformAgl(
226 + std::unique_ptr<Window> window,
227 + aura::WindowTreeHostPlatform* window_tree_host_platform);
228 + WindowTreeHostPlatformAgl(const WindowTreeHostPlatformAgl&) = delete;
229 + WindowTreeHostPlatformAgl& operator=(const WindowTreeHostPlatformAgl&) = delete;
230 + ~WindowTreeHostPlatformAgl() override = default;
232 + void SetAglActivateApp(const std::string& app) override;
233 + void SetAglAppId(const std::string& title) override;
234 + void SetAglReady() override;
235 + void SetAglBackground() override;
236 + void SetAglPanel(uint32_t edge) override;
239 + aura::WindowTreeHostPlatform* window_tree_host_platform_;
244 +#endif // UI_AURA_AGL_WINDOW_TREE_HOST_PLATFORM_AGL_H_
245 diff --git a/ui/aura/window_tree_host.h b/ui/aura/window_tree_host.h
246 index b4b6e7022ea34..afb37a3a3ed13 100644
247 --- a/ui/aura/window_tree_host.h
248 +++ b/ui/aura/window_tree_host.h
250 #include "ui/gfx/native_widget_types.h"
251 #include "ui/gfx/overlay_transform.h"
253 +#include "ui/aura/agl/window_tree_host_agl.h"
258 @@ -66,7 +68,8 @@ class WindowTreeHostObserver;
259 class AURA_EXPORT WindowTreeHost : public ui::ImeKeyEventDispatcher,
260 public ui::EventSource,
261 public display::DisplayObserver,
262 - public ui::CompositorObserver {
263 + public ui::CompositorObserver,
264 + public WindowTreeHostAgl {
266 // VideoCaptureLock ensures state necessary for capturing video remains in
267 // effect. For example, this may force keeping the compositor visible when
268 diff --git a/ui/aura/window_tree_host_platform.cc b/ui/aura/window_tree_host_platform.cc
269 index fd4a560f6cdd1..33b9e892c0212 100644
270 --- a/ui/aura/window_tree_host_platform.cc
271 +++ b/ui/aura/window_tree_host_platform.cc
272 @@ -52,7 +52,7 @@ std::unique_ptr<WindowTreeHost> WindowTreeHost::Create(
273 WindowTreeHostPlatform::WindowTreeHostPlatform(
274 ui::PlatformWindowInitProperties properties,
275 std::unique_ptr<Window> window)
276 - : WindowTreeHost(std::move(window)) {
277 + : WindowTreeHostPlatformAgl(std::move(window), this) {
278 size_in_pixels_ = properties.bounds.size();
279 CreateCompositor(false, false, properties.enable_compositing_based_throttling,
280 properties.compositor_memory_limit_mb);
281 @@ -60,7 +60,7 @@ WindowTreeHostPlatform::WindowTreeHostPlatform(
284 WindowTreeHostPlatform::WindowTreeHostPlatform(std::unique_ptr<Window> window)
285 - : WindowTreeHost(std::move(window)),
286 + : WindowTreeHostPlatformAgl(std::move(window), this),
287 widget_(gfx::kNullAcceleratedWidget),
288 current_cursor_(ui::mojom::CursorType::kNull) {}
290 diff --git a/ui/aura/window_tree_host_platform.h b/ui/aura/window_tree_host_platform.h
291 index 92ae0f0229e70..9c3f742c30ad3 100644
292 --- a/ui/aura/window_tree_host_platform.h
293 +++ b/ui/aura/window_tree_host_platform.h
295 #include "ui/gfx/native_widget_types.h"
296 #include "ui/platform_window/platform_window_delegate.h"
298 +#include "ui/aura/agl/window_tree_host_platform_agl.h"
302 class PlatformWindow;
303 @@ -26,7 +28,7 @@ namespace aura {
305 // The unified WindowTreeHost implementation for platforms
306 // that implement PlatformWindow.
307 -class AURA_EXPORT WindowTreeHostPlatform : public WindowTreeHost,
308 +class AURA_EXPORT WindowTreeHostPlatform : public WindowTreeHostPlatformAgl,
309 public ui::PlatformWindowDelegate {
311 explicit WindowTreeHostPlatform(ui::PlatformWindowInitProperties properties,
312 diff --git a/ui/ozone/platform/wayland/BUILD.gn b/ui/ozone/platform/wayland/BUILD.gn
313 index 8a436de0fafe3..754cb123043a9 100644
314 --- a/ui/ozone/platform/wayland/BUILD.gn
315 +++ b/ui/ozone/platform/wayland/BUILD.gn
316 @@ -400,7 +400,6 @@ source_set("wayland") {
319 "host/wayland_extensions.h",
320 - "host/wayland_extensions_stub.cc",
323 deps += [ "extensions/agl" ]
324 diff --git a/ui/ozone/platform/wayland/extensions/agl/BUILD.gn b/ui/ozone/platform/wayland/extensions/agl/BUILD.gn
325 index ce289bc5dbbca..01c590e53df58 100644
326 --- a/ui/ozone/platform/wayland/extensions/agl/BUILD.gn
327 +++ b/ui/ozone/platform/wayland/extensions/agl/BUILD.gn
328 @@ -31,6 +31,8 @@ source_set("agl") {
329 "host/wayland_extensions_agl.h",
330 "host/wayland_extensions_agl_impl.cc",
331 "host/wayland_extensions_agl_impl.h",
332 + "host/wayland_window_agl.cc",
333 + "host/wayland_window_agl.h",
337 diff --git a/ui/ozone/platform/wayland/extensions/agl/host/wayland_extensions_agl.h b/ui/ozone/platform/wayland/extensions/agl/host/wayland_extensions_agl.h
338 index df42fc00c84da..295154dfb437d 100644
339 --- a/ui/ozone/platform/wayland/extensions/agl/host/wayland_extensions_agl.h
340 +++ b/ui/ozone/platform/wayland/extensions/agl/host/wayland_extensions_agl.h
344 class AglShellWrapper;
345 +class PlatformWindowDelegate;
346 +class WaylandConnection;
347 +class WaylandWindow;
349 // AGL extensions implementation for webOS/Lite
350 class WaylandExtensionsAgl {
351 @@ -29,9 +32,14 @@ class WaylandExtensionsAgl {
352 WaylandExtensionsAgl& operator=(const WaylandExtensionsAgl&) = delete;
353 virtual ~WaylandExtensionsAgl() = default;
355 + virtual std::unique_ptr<WaylandWindow> CreateWaylandWindow(
356 + PlatformWindowDelegate* delegate,
357 + WaylandConnection* connection) = 0;
360 virtual AglShellWrapper* GetAglShell() = 0;
365 -#endif // UI_OZONE_PLATFORM_WAYLAND_EXTENSIONS_AGL_HOST_WAYLAND_EXTENSIONS_AGL_H_
366 \ No newline at end of file
367 +#endif // UI_OZONE_PLATFORM_WAYLAND_EXTENSIONS_AGL_HOST_WAYLAND_EXTENSIONS_AGL_H_
368 diff --git a/ui/ozone/platform/wayland/extensions/agl/host/wayland_extensions_agl_impl.cc b/ui/ozone/platform/wayland/extensions/agl/host/wayland_extensions_agl_impl.cc
369 index 26a5f0550c302..87376cbb8a9d3 100644
370 --- a/ui/ozone/platform/wayland/extensions/agl/host/wayland_extensions_agl_impl.cc
371 +++ b/ui/ozone/platform/wayland/extensions/agl/host/wayland_extensions_agl_impl.cc
373 #include "base/logging.h"
374 #include "ui/base/ui_base_switches.h"
375 #include "ui/ozone/platform/wayland/extensions/agl/host/agl_shell_wrapper.h"
376 +#include "ui/ozone/platform/wayland/extensions/agl/host/wayland_window_agl.h"
377 #include "ui/ozone/platform/wayland/extensions/agl/common/wayland_object_agl.h"
378 #include "ui/ozone/platform/wayland/host/wayland_connection.h"
380 @@ -68,8 +69,8 @@ bool WaylandExtensionsAglImpl::Bind(wl_registry* registry,
382 std::make_unique<AglShellWrapper>(aglshell.release(), connection_);
384 - LOG(INFO) << "Waiting until bound...";
385 - return agl_shell_->WaitUntilBoundOk();
386 + //LOG(INFO) << "Waiting until bound...";
387 + //return agl_shell_->WaitUntilBoundOk();
389 LOG(INFO) << "Cant bind.";
391 @@ -85,6 +86,12 @@ AglShellWrapper* WaylandExtensionsAglImpl::GetAglShell() {
392 return agl_shell_.get();
395 +std::unique_ptr<WaylandWindow> WaylandExtensionsAglImpl::CreateWaylandWindow(
396 + PlatformWindowDelegate* delegate,
397 + WaylandConnection* connection) {
398 + return std::make_unique<WaylandWindowAgl>(delegate, connection, this);
401 std::unique_ptr<WaylandExtensions> CreateWaylandExtensions(
402 WaylandConnection* connection) {
403 return std::make_unique<WaylandExtensionsAglImpl>(connection);
404 diff --git a/ui/ozone/platform/wayland/extensions/agl/host/wayland_extensions_agl_impl.h b/ui/ozone/platform/wayland/extensions/agl/host/wayland_extensions_agl_impl.h
405 index f6cbabe99ed0b..3218589f1a09a 100644
406 --- a/ui/ozone/platform/wayland/extensions/agl/host/wayland_extensions_agl_impl.h
407 +++ b/ui/ozone/platform/wayland/extensions/agl/host/wayland_extensions_agl_impl.h
409 #ifndef UI_OZONE_PLATFORM_WAYLAND_EXTENSIONS_AGL_HOST_WAYLAND_EXTENSIONS_AGL_IMPL_H_
410 #define UI_OZONE_PLATFORM_WAYLAND_EXTENSIONS_AGL_HOST_WAYLAND_EXTENSIONS_AGL_IMPL_H_
414 #include "ui/ozone/platform/wayland/extensions/agl/host/wayland_extensions_agl.h"
415 #include "ui/ozone/platform/wayland/host/wayland_extensions.h"
419 class AglShellWrapper;
420 +class PlatformWindowDelegate;
421 +class WaylandConnection;
422 +class WaylandWindow;
424 // AGL extension implementation for webOS/Lite
425 class WaylandExtensionsAglImpl : public WaylandExtensions,
426 @@ -44,6 +49,10 @@ class WaylandExtensionsAglImpl : public WaylandExtensions,
427 // WaylandExtensionsAgl overrides
428 AglShellWrapper* GetAglShell() override;
430 + std::unique_ptr<WaylandWindow> CreateWaylandWindow(
431 + PlatformWindowDelegate* delegate,
432 + WaylandConnection* connection) override;
435 std::unique_ptr<AglShellWrapper> agl_shell_;
436 WaylandConnection* connection_;
437 diff --git a/ui/ozone/platform/wayland/extensions/agl/host/wayland_window_agl.cc b/ui/ozone/platform/wayland/extensions/agl/host/wayland_window_agl.cc
439 index 0000000000000..97b21ae537658
441 +++ b/ui/ozone/platform/wayland/extensions/agl/host/wayland_window_agl.cc
443 +// Copyright 2021 LG Electronics, Inc.
445 +// Licensed under the Apache License, Version 2.0 (the "License");
446 +// you may not use this file except in compliance with the License.
447 +// You may obtain a copy of the License at
449 +// http://www.apache.org/licenses/LICENSE-2.0
451 +// Unless required by applicable law or agreed to in writing, software
452 +// distributed under the License is distributed on an "AS IS" BASIS,
453 +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
454 +// See the License for the specific language governing permissions and
455 +// limitations under the License.
457 +// SPDX-License-Identifier: Apache-2.0
459 +#include "ui/ozone/platform/wayland/extensions/agl/host/wayland_window_agl.h"
461 +#include "base/logging.h"
462 +#include "ui/ozone/platform/wayland/extensions/agl/host/agl_shell_wrapper.h"
463 +#include "ui/ozone/platform/wayland/extensions/agl/host/wayland_extensions_agl.h"
464 +#include "ui/ozone/platform/wayland/host/shell_surface_wrapper.h"
465 +#include "ui/ozone/platform/wayland/host/shell_toplevel_wrapper.h"
466 +#include "ui/ozone/platform/wayland/host/wayland_connection.h"
470 +WaylandWindowAgl::WaylandWindowAgl(PlatformWindowDelegate* delegate,
471 + WaylandConnection* connection,
472 + WaylandExtensionsAgl* agl_extensions)
473 + : WaylandToplevelWindow(delegate, connection),
474 + agl_extensions_(agl_extensions) {}
476 +WaylandWindowAgl::~WaylandWindowAgl() = default;
478 +void WaylandWindowAgl::SetAglActivateApp(const std::string& app) {
479 + if (!agl_extensions_->GetAglShell()) {
480 + LOG(ERROR) << "Agl shell wrapper is not created";
484 + agl_extensions_->GetAglShell()->SetAglActivateApp(app);
485 + connection()->ScheduleFlush();
488 +void WaylandWindowAgl::SetAglAppId(const std::string& title) {
489 + if (!shell_toplevel()) {
490 + LOG(ERROR) << "Shell toplevel is not created";
494 + shell_toplevel()->SetAppId(title);
495 + connection()->ScheduleFlush();
498 +void WaylandWindowAgl::SetAglReady() {
499 + if (!agl_extensions_->GetAglShell()) {
500 + LOG(ERROR) << "Agl shell wrapper is not created";
504 + agl_extensions_->GetAglShell()->SetAglReady();
505 + connection()->ScheduleFlush();
508 +void WaylandWindowAgl::SetAglBackground() {
509 + if (!agl_extensions_->GetAglShell()) {
510 + LOG(ERROR) << "Agl shell wrapper is not created";
514 + agl_extensions_->GetAglShell()->SetAglBackground(this);
515 + connection()->ScheduleFlush();
518 +void WaylandWindowAgl::SetAglPanel(uint32_t edge) {
519 + if (!agl_extensions_->GetAglShell()) {
520 + LOG(ERROR) << "Agl shell wrapper is not created";
524 + agl_extensions_->GetAglShell()->SetAglPanel(this, edge);
525 + connection()->ScheduleFlush();
529 diff --git a/ui/ozone/platform/wayland/extensions/agl/host/wayland_window_agl.h b/ui/ozone/platform/wayland/extensions/agl/host/wayland_window_agl.h
531 index 0000000000000..b2a922604c001
533 +++ b/ui/ozone/platform/wayland/extensions/agl/host/wayland_window_agl.h
535 +// Copyright 2021 LG Electronics, Inc.
537 +// Licensed under the Apache License, Version 2.0 (the "License");
538 +// you may not use this file except in compliance with the License.
539 +// You may obtain a copy of the License at
541 +// http://www.apache.org/licenses/LICENSE-2.0
543 +// Unless required by applicable law or agreed to in writing, software
544 +// distributed under the License is distributed on an "AS IS" BASIS,
545 +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
546 +// See the License for the specific language governing permissions and
547 +// limitations under the License.
549 +// SPDX-License-Identifier: Apache-2.0
552 +#ifndef UI_OZONE_PLATFORM_WAYLAND_EXTENSIONS_AGL_HOST_WAYLAND_WINDOW_AGL_H_
553 +#define UI_OZONE_PLATFORM_WAYLAND_EXTENSIONS_AGL_HOST_WAYLAND_WINDOW_AGL_H_
555 +#include "ui/ozone/platform/wayland/host/wayland_toplevel_window.h"
559 +class WaylandExtensionsAgl;
561 +class WaylandWindowAgl : public WaylandToplevelWindow {
563 + explicit WaylandWindowAgl(PlatformWindowDelegate* delegate,
564 + WaylandConnection* connection,
565 + WaylandExtensionsAgl* agl_extensions);
566 + WaylandWindowAgl(const WaylandWindowAgl&) = delete;
567 + WaylandWindowAgl& operator=(const WaylandWindowAgl&) = delete;
568 + ~WaylandWindowAgl() override;
570 + // Overrides PlatformWindowAgl
571 + void SetAglActivateApp(const std::string& app) override;
572 + void SetAglAppId(const std::string& title) override;
573 + void SetAglReady() override;
574 + void SetAglBackground() override;
575 + void SetAglPanel(uint32_t edge) override;
578 + WaylandExtensionsAgl* agl_extensions_;
583 +#endif // UI_OZONE_PLATFORM_WAYLAND_EXTENSIONS_AGL_HOST_WAYLAND_WINDOW_AGL_H_
584 diff --git a/ui/ozone/platform/wayland/gpu/gl_surface_wayland.cc b/ui/ozone/platform/wayland/gpu/gl_surface_wayland.cc
585 index 1cda8aa671ddb..220f759ff30a1 100644
586 --- a/ui/ozone/platform/wayland/gpu/gl_surface_wayland.cc
587 +++ b/ui/ozone/platform/wayland/gpu/gl_surface_wayland.cc
588 @@ -90,7 +90,14 @@ gfx::SwapResult GLSurfaceWayland::SwapBuffers(PresentationCallback callback,
589 return scoped_swap_buffers.result();
591 window_->root_surface()->set_surface_buffer_scale(scale_factor_);
592 - return gl::NativeViewGLSurfaceEGL::SwapBuffers(std::move(callback), data);
594 + gfx::SwapResult result = gl::NativeViewGLSurfaceEGL::SwapBuffers(std::move(callback), data);
597 + window_->OnSurfaceContentChanged();
603 gfx::SwapResult GLSurfaceWayland::PostSubBuffer(int x,
604 diff --git a/ui/ozone/platform/wayland/host/gtk_primary_selection_device.cc b/ui/ozone/platform/wayland/host/gtk_primary_selection_device.cc
605 index c62dd62be4fbf..2959593cfeb5b 100644
606 --- a/ui/ozone/platform/wayland/host/gtk_primary_selection_device.cc
607 +++ b/ui/ozone/platform/wayland/host/gtk_primary_selection_device.cc
608 @@ -32,7 +32,7 @@ void GtkPrimarySelectionDevice::SetSelectionSource(
609 auto* data_source = source ? source->data_source() : nullptr;
610 gtk_primary_selection_device_set_selection(data_device_.get(), data_source,
612 - connection()->Flush();
613 + connection()->ScheduleFlush();
617 diff --git a/ui/ozone/platform/wayland/host/gtk_primary_selection_device_manager.cc b/ui/ozone/platform/wayland/host/gtk_primary_selection_device_manager.cc
618 index 2c39409808128..1e07ae6009776 100644
619 --- a/ui/ozone/platform/wayland/host/gtk_primary_selection_device_manager.cc
620 +++ b/ui/ozone/platform/wayland/host/gtk_primary_selection_device_manager.cc
621 @@ -66,7 +66,7 @@ GtkPrimarySelectionDevice* GtkPrimarySelectionDeviceManager::GetDevice() {
623 gtk_primary_selection_device_manager_get_device(
624 device_manager_.get(), connection_->seat()->wl_object()));
625 - connection_->Flush();
626 + connection_->ScheduleFlush();
629 return device_.get();
630 @@ -77,7 +77,7 @@ GtkPrimarySelectionDeviceManager::CreateSource(
631 GtkPrimarySelectionSource::Delegate* delegate) {
633 gtk_primary_selection_device_manager_create_source(device_manager_.get());
634 - connection_->Flush();
635 + connection_->ScheduleFlush();
636 return std::make_unique<GtkPrimarySelectionSource>(data_source, connection_,
639 diff --git a/ui/ozone/platform/wayland/host/proxy/wayland_proxy_impl.cc b/ui/ozone/platform/wayland/host/proxy/wayland_proxy_impl.cc
640 index f2407d1c306ec..7a7868ded8a52 100644
641 --- a/ui/ozone/platform/wayland/host/proxy/wayland_proxy_impl.cc
642 +++ b/ui/ozone/platform/wayland/host/proxy/wayland_proxy_impl.cc
643 @@ -69,7 +69,7 @@ void WaylandProxyImpl::DestroyShmForWlBuffer(wl_buffer* buffer) {
646 void WaylandProxyImpl::FlushForTesting() {
647 - connection_->Flush();
648 + connection_->ScheduleFlush();
651 ui::PlatformWindowType WaylandProxyImpl::GetWindowType(
652 diff --git a/ui/ozone/platform/wayland/host/wayland_connection.cc b/ui/ozone/platform/wayland/host/wayland_connection.cc
653 index 7a47d4a636998..8d9e8eea6fd79 100644
654 --- a/ui/ozone/platform/wayland/host/wayland_connection.cc
655 +++ b/ui/ozone/platform/wayland/host/wayland_connection.cc
656 @@ -264,6 +264,20 @@ bool WaylandConnection::Initialize(bool use_threaded_polling) {
660 +void WaylandConnection::ScheduleFlush() {
661 + // When we are in tests, the message loop is set later when the
662 + // initialization of the OzonePlatform complete. Thus, just
663 + // flush directly. This doesn't happen in normal run.
664 + if (!base::CurrentUIThread::IsSet()) {
666 + } else if (!scheduled_flush_) {
667 + base::SingleThreadTaskRunner::GetCurrentDefault()->PostTask(
669 + base::BindOnce(&WaylandConnection::Flush, base::Unretained(this)));
670 + scheduled_flush_ = true;
674 void WaylandConnection::RoundTripQueue() {
675 if (roundtrip_closure_for_testing_) {
676 roundtrip_closure_for_testing_.Run();
677 @@ -333,6 +347,7 @@ void WaylandConnection::RegisterGlobalObjectFactory(
679 void WaylandConnection::Flush() {
680 wl_display_flush(display_.get());
681 + scheduled_flush_ = false;
684 void WaylandConnection::UpdateInputDevices() {
685 @@ -526,7 +541,7 @@ void WaylandConnection::OnPing(void* data,
687 auto* connection = static_cast<WaylandConnection*>(data);
688 xdg_wm_base_pong(shell, serial);
689 - connection->Flush();
690 + connection->ScheduleFlush();
694 @@ -707,7 +722,7 @@ void WaylandConnection::HandleGlobal(wl_registry* registry,
697 available_globals_.emplace_back(interface, version);
703 diff --git a/ui/ozone/platform/wayland/host/wayland_connection.h b/ui/ozone/platform/wayland/host/wayland_connection.h
704 index ba293e5bcd088..641f36f13db35 100644
705 --- a/ui/ozone/platform/wayland/host/wayland_connection.h
706 +++ b/ui/ozone/platform/wayland/host/wayland_connection.h
707 @@ -100,8 +100,8 @@ class WaylandConnection {
709 bool Initialize(bool use_threaded_polling = false);
711 - // Immediately flushes the Wayland display.
713 + // Schedules a flush of the Wayland connection.
714 + void ScheduleFlush();
716 // Calls wl_display_roundtrip_queue. Might be required during initialization
717 // of some objects that should block until they are initialized.
718 @@ -388,6 +388,9 @@ class WaylandConnection {
719 friend class ZwpIdleInhibitManager;
720 friend class ZwpPrimarySelectionDeviceManager;
722 + // Immediately flushes the Wayland display.
725 void RegisterGlobalObjectFactory(const char* interface_name,
726 wl::GlobalObjectFactory factory);
728 @@ -535,6 +538,8 @@ class WaylandConnection {
729 // This is set if delegated composition should not be used.
730 bool overlay_delegation_disabled_ = false;
732 + bool scheduled_flush_ = false;
734 wl::SerialTracker serial_tracker_;
736 // Global Wayland interfaces available in the current session, with their
737 diff --git a/ui/ozone/platform/wayland/host/wayland_cursor.cc b/ui/ozone/platform/wayland/host/wayland_cursor.cc
738 index 1b7d303291cff..a384212c84134 100644
739 --- a/ui/ozone/platform/wayland/host/wayland_cursor.cc
740 +++ b/ui/ozone/platform/wayland/host/wayland_cursor.cc
741 @@ -107,7 +107,7 @@ void WaylandCursor::HideCursor() {
742 wl_surface_attach(pointer_surface_.get(), nullptr, 0, 0);
743 wl_surface_commit(pointer_surface_.get());
745 - connection_->Flush();
746 + connection_->ScheduleFlush();
749 listener_->OnCursorBufferAttached(nullptr);
750 @@ -166,7 +166,7 @@ void WaylandCursor::AttachAndCommit(wl_buffer* buffer,
751 wl_pointer_set_cursor(pointer_->wl_object(), pointer_enter_serial->value,
752 pointer_surface_.get(), hotspot_x_dip, hotspot_y_dip);
754 - connection_->Flush();
755 + connection_->ScheduleFlush();
759 diff --git a/ui/ozone/platform/wayland/host/wayland_data_device.cc b/ui/ozone/platform/wayland/host/wayland_data_device.cc
760 index a7adfd313188b..fe16d8577fd35 100644
761 --- a/ui/ozone/platform/wayland/host/wayland_data_device.cc
762 +++ b/ui/ozone/platform/wayland/host/wayland_data_device.cc
763 @@ -51,7 +51,7 @@ void WaylandDataDevice::StartDrag(const WaylandDataSource& data_source,
764 origin_window.root_surface()->surface(),
765 icon_surface, serial);
766 drag_delegate_->DrawIcon();
767 - connection()->Flush();
768 + connection()->ScheduleFlush();
771 void WaylandDataDevice::ResetDragDelegate() {
772 @@ -92,7 +92,7 @@ void WaylandDataDevice::SetSelectionSource(WaylandDataSource* source,
774 auto* data_source = source ? source->data_source() : nullptr;
775 wl_data_device_set_selection(data_device_.get(), data_source, serial);
776 - connection()->Flush();
777 + connection()->ScheduleFlush();
780 void WaylandDataDevice::ReadDragDataFromFD(base::ScopedFD fd,
781 @@ -146,7 +146,7 @@ void WaylandDataDevice::OnEnter(void* data,
782 gfx::PointF(wl_fixed_to_double(x), wl_fixed_to_double(y)), window);
783 self->drag_delegate_->OnDragEnter(window, point, serial);
785 - self->connection()->Flush();
786 + self->connection()->ScheduleFlush();
789 void WaylandDataDevice::OnMotion(void* data,
790 @@ -167,7 +167,7 @@ void WaylandDataDevice::OnDrop(void* data, wl_data_device* data_device) {
791 auto* self = static_cast<WaylandDataDevice*>(data);
792 if (self->drag_delegate_) {
793 self->drag_delegate_->OnDragDrop();
794 - self->connection()->Flush();
795 + self->connection()->ScheduleFlush();
798 // There are buggy Exo versions, which send 'drop' event (even for
799 @@ -184,7 +184,7 @@ void WaylandDataDevice::OnLeave(void* data, wl_data_device* data_device) {
800 auto* self = static_cast<WaylandDataDevice*>(data);
801 if (self->drag_delegate_) {
802 self->drag_delegate_->OnDragLeave();
803 - self->connection()->Flush();
804 + self->connection()->ScheduleFlush();
806 self->ResetDragDelegateIfNotDragSource();
808 diff --git a/ui/ozone/platform/wayland/host/wayland_data_device_base.cc b/ui/ozone/platform/wayland/host/wayland_data_device_base.cc
809 index 203e907f92bfa..a0c72971ac567 100644
810 --- a/ui/ozone/platform/wayland/host/wayland_data_device_base.cc
811 +++ b/ui/ozone/platform/wayland/host/wayland_data_device_base.cc
812 @@ -64,7 +64,7 @@ void WaylandDataDeviceBase::RegisterDeferredReadCallback() {
813 static constexpr wl_callback_listener kSyncCallbackListener = {
814 .done = &OnSyncDone};
815 wl_callback_add_listener(sync_callback_.get(), &kSyncCallbackListener, this);
816 - connection_->Flush();
817 + connection_->ScheduleFlush();
820 void WaylandDataDeviceBase::RegisterDeferredReadClosure(
821 diff --git a/ui/ozone/platform/wayland/host/wayland_data_drag_controller.cc b/ui/ozone/platform/wayland/host/wayland_data_drag_controller.cc
822 index 705bdec41a1b7..dfa5789e8d149 100644
823 --- a/ui/ozone/platform/wayland/host/wayland_data_drag_controller.cc
824 +++ b/ui/ozone/platform/wayland/host/wayland_data_drag_controller.cc
825 @@ -256,7 +256,7 @@ void WaylandDataDragController::OnDragSurfaceFrame(void* data,
827 self->DrawIconInternal();
828 self->icon_frame_callback_.reset();
829 - self->connection_->Flush();
830 + self->connection_->ScheduleFlush();
833 SkBitmap WaylandDataDragController::GetIconBitmap() {
834 diff --git a/ui/ozone/platform/wayland/host/wayland_data_source.cc b/ui/ozone/platform/wayland/host/wayland_data_source.cc
835 index c0e95c8a22e48..c294ffb8836aa 100644
836 --- a/ui/ozone/platform/wayland/host/wayland_data_source.cc
837 +++ b/ui/ozone/platform/wayland/host/wayland_data_source.cc
838 @@ -130,7 +130,7 @@ void DataSource<wl_data_source>::Offer(
839 const std::vector<std::string>& mime_types) {
840 for (auto& mime_type : mime_types)
841 wl_data_source_offer(data_source_.get(), mime_type.c_str());
842 - connection_->Flush();
843 + connection_->ScheduleFlush();
846 template <typename T>
847 @@ -165,7 +165,7 @@ void DataSource<gtk_primary_selection_source>::Offer(
848 const std::vector<std::string>& mime_types) {
849 for (const auto& mime_type : mime_types)
850 gtk_primary_selection_source_offer(data_source_.get(), mime_type.c_str());
851 - connection_->Flush();
852 + connection_->ScheduleFlush();
856 @@ -185,7 +185,7 @@ void DataSource<zwp_primary_selection_source_v1>::Offer(
857 for (const auto& mime_type : mime_types)
858 zwp_primary_selection_source_v1_offer(data_source_.get(),
860 - connection_->Flush();
861 + connection_->ScheduleFlush();
864 template class DataSource<gtk_primary_selection_source>;
865 diff --git a/ui/ozone/platform/wayland/host/wayland_drm.cc b/ui/ozone/platform/wayland/host/wayland_drm.cc
866 index 68570a9aacb2c..2b3b16e8859cb 100644
867 --- a/ui/ozone/platform/wayland/host/wayland_drm.cc
868 +++ b/ui/ozone/platform/wayland/host/wayland_drm.cc
869 @@ -58,7 +58,7 @@ WaylandDrm::WaylandDrm(wl_drm* drm, WaylandConnection* connection)
870 .capabilities = &OnCapabilities,
872 wl_drm_add_listener(wl_drm_.get(), &kDrmListener, this);
873 - connection_->Flush();
874 + connection_->ScheduleFlush();
876 // A roundtrip after binding guarantees that the client has received all
877 // supported formats and capabilities of the device.
878 @@ -92,7 +92,7 @@ void WaylandDrm::CreateBuffer(const base::ScopedFD& fd,
879 wl::Object<wl_buffer> buffer(wl_drm_create_prime_buffer(
880 wl_drm_.get(), fd.get(), size.width(), size.height(), format, offset[0],
881 stride[0], offset[1], stride[1], offset[2], stride[2]));
882 - connection_->Flush();
883 + connection_->ScheduleFlush();
885 std::move(callback).Run(std::move(buffer));
887 @@ -146,7 +146,7 @@ void WaylandDrm::Authenticate(const char* drm_device_path) {
890 wl_drm_authenticate(wl_drm_.get(), magic);
891 - connection_->Flush();
892 + connection_->ScheduleFlush();
894 // Do the roundtrip to make sure the server processes this request and
896 diff --git a/ui/ozone/platform/wayland/host/wayland_extensions.h b/ui/ozone/platform/wayland/host/wayland_extensions.h
897 index 3bd2fd7a211ae..f6ed47507d217 100644
898 --- a/ui/ozone/platform/wayland/host/wayland_extensions.h
899 +++ b/ui/ozone/platform/wayland/host/wayland_extensions.h
900 @@ -25,7 +25,9 @@ namespace ui {
902 class ShellToplevelWrapper;
903 class ShellPopupWrapper;
904 +class PlatformWindowDelegate;
905 class WaylandConnection;
906 +class WaylandWindow;
908 // Wayland extensions abstract interface to support extending of the Wayland
909 // protocol. Inherit it to provide your own Wayland extensions implementation.
910 @@ -45,6 +47,10 @@ class WaylandExtensions {
912 // Checks whether the extensions have bound shell object(s).
913 virtual bool HasShellObject() const = 0;
915 + virtual std::unique_ptr<WaylandWindow> CreateWaylandWindow(
916 + PlatformWindowDelegate* delegate,
917 + WaylandConnection* connection) = 0;
920 // Creates Wayland extensions.
921 diff --git a/ui/ozone/platform/wayland/host/wayland_keyboard.cc b/ui/ozone/platform/wayland/host/wayland_keyboard.cc
922 index 2b7fc05d426e1..f24d6993b26ac 100644
923 --- a/ui/ozone/platform/wayland/host/wayland_keyboard.cc
924 +++ b/ui/ozone/platform/wayland/host/wayland_keyboard.cc
925 @@ -114,7 +114,7 @@ class WaylandKeyboard::ZCRExtendedKeyboard {
927 void AckKey(uint32_t serial, bool handled) {
928 zcr_extended_keyboard_v1_ack_key(obj_.get(), serial, handled);
929 - keyboard_->connection_->Flush();
930 + keyboard_->connection_->ScheduleFlush();
933 // Returns true if connected object will send zcr_extended_keyboard::peek_key.
934 @@ -373,7 +373,7 @@ void WaylandKeyboard::FlushInput(base::OnceClosure closure) {
937 wl_callback_add_listener(sync_callback_.get(), &kSyncCallbackListener, this);
938 - connection_->Flush();
939 + connection_->ScheduleFlush();
942 void WaylandKeyboard::DispatchKey(unsigned int key,
943 diff --git a/ui/ozone/platform/wayland/host/wayland_popup.cc b/ui/ozone/platform/wayland/host/wayland_popup.cc
944 index f1e886f8675fb..28903c031e6ce 100644
945 --- a/ui/ozone/platform/wayland/host/wayland_popup.cc
946 +++ b/ui/ozone/platform/wayland/host/wayland_popup.cc
947 @@ -132,7 +132,7 @@ void WaylandPopup::Show(bool inactive) {
951 - connection()->Flush();
952 + connection()->ScheduleFlush();
953 WaylandWindow::Show(inactive);
956 @@ -158,7 +158,7 @@ void WaylandPopup::Hide() {
957 decorated_via_aura_popup_ = false;
960 - connection()->Flush();
961 + connection()->ScheduleFlush();
964 bool WaylandPopup::IsVisible() const {
965 @@ -256,14 +256,14 @@ void WaylandPopup::ShowTooltip(const std::u16string& text,
967 zaura_surface->ShowTooltip(text, position, zaura_shell_trigger,
968 show_delay, hide_delay)) {
969 - connection()->Flush();
970 + connection()->ScheduleFlush();
974 void WaylandPopup::HideTooltip() {
975 auto* zaura_surface = GetZAuraSurface();
976 if (zaura_surface && zaura_surface->HideTooltip()) {
977 - connection()->Flush();
978 + connection()->ScheduleFlush();
982 diff --git a/ui/ozone/platform/wayland/host/wayland_seat.cc b/ui/ozone/platform/wayland/host/wayland_seat.cc
983 index 3b05da49eb6b8..5f70725a9a9dd 100644
984 --- a/ui/ozone/platform/wayland/host/wayland_seat.cc
985 +++ b/ui/ozone/platform/wayland/host/wayland_seat.cc
986 @@ -128,7 +128,7 @@ void WaylandSeat::HandleCapabilities(void* data,
988 connection_->UpdateInputDevices();
989 connection_->UpdateCursor();
990 - connection_->Flush();
991 + connection_->ScheduleFlush();
995 diff --git a/ui/ozone/platform/wayland/host/wayland_shm.cc b/ui/ozone/platform/wayland/host/wayland_shm.cc
996 index b264ad88962bb..95c19d9962085 100644
997 --- a/ui/ozone/platform/wayland/host/wayland_shm.cc
998 +++ b/ui/ozone/platform/wayland/host/wayland_shm.cc
999 @@ -62,7 +62,7 @@ wl::Object<wl_buffer> WaylandShm::CreateBuffer(const base::ScopedFD& fd,
1000 with_alpha_channel ? WL_SHM_FORMAT_ARGB8888 : WL_SHM_FORMAT_XRGB8888;
1001 wl::Object<wl_buffer> shm_buffer(wl_shm_pool_create_buffer(
1002 pool.get(), 0, size.width(), size.height(), size.width() * 4, format));
1003 - connection_->Flush();
1004 + connection_->ScheduleFlush();
1008 diff --git a/ui/ozone/platform/wayland/host/wayland_surface.cc b/ui/ozone/platform/wayland/host/wayland_surface.cc
1009 index 47dc846390898..2a04d28b05484 100644
1010 --- a/ui/ozone/platform/wayland/host/wayland_surface.cc
1011 +++ b/ui/ozone/platform/wayland/host/wayland_surface.cc
1012 @@ -305,7 +305,7 @@ void WaylandSurface::UpdateBufferDamageRegion(const gfx::Rect& damage_px) {
1013 void WaylandSurface::Commit(bool flush) {
1014 wl_surface_commit(surface_.get());
1016 - connection_->Flush();
1017 + connection_->ScheduleFlush();
1020 void WaylandSurface::set_surface_buffer_scale(float scale) {
1021 diff --git a/ui/ozone/platform/wayland/host/wayland_toplevel_window.cc b/ui/ozone/platform/wayland/host/wayland_toplevel_window.cc
1022 index 898113178a783..1b489b327fa29 100644
1023 --- a/ui/ozone/platform/wayland/host/wayland_toplevel_window.cc
1024 +++ b/ui/ozone/platform/wayland/host/wayland_toplevel_window.cc
1025 @@ -127,7 +127,7 @@ void WaylandToplevelWindow::DispatchHostWindowDragMovement(
1027 shell_toplevel_->SurfaceResize(connection(), hittest);
1029 - connection()->Flush();
1030 + connection()->ScheduleFlush();
1031 #if !BUILDFLAG(IS_CHROMEOS_LACROS)
1032 // TODO(crbug.com/1454893): Revisit to resolve the correct impl.
1033 connection()->event_source()->ResetPointerFlags();
1034 @@ -176,7 +176,7 @@ void WaylandToplevelWindow::Hide() {
1035 gtk_surface1_.reset();
1037 shell_toplevel_.reset();
1038 - connection()->Flush();
1039 + connection()->ScheduleFlush();
1042 bool WaylandToplevelWindow::IsVisible() const {
1043 @@ -193,7 +193,7 @@ void WaylandToplevelWindow::SetTitle(const std::u16string& title) {
1045 if (shell_toplevel_) {
1046 shell_toplevel_->SetTitle(title);
1047 - connection()->Flush();
1048 + connection()->ScheduleFlush();
1052 @@ -288,13 +288,13 @@ void WaylandToplevelWindow::Activate() {
1053 // but nothing more happens (until the user moves the mouse over a Lacros
1054 // window in which case events will start and the activation will come
1056 - connection()->Flush();
1057 + connection()->ScheduleFlush();
1060 void WaylandToplevelWindow::Deactivate() {
1061 if (shell_toplevel_ && shell_toplevel_->SupportsActivation()) {
1062 shell_toplevel_->Deactivate();
1063 - connection()->Flush();
1064 + connection()->ScheduleFlush();
1068 @@ -722,14 +722,14 @@ void WaylandToplevelWindow::ShowTooltip(
1069 if (zaura_surface &&
1070 zaura_surface->ShowTooltip(text, position, zaura_shell_trigger,
1071 show_delay, hide_delay)) {
1072 - connection()->Flush();
1073 + connection()->ScheduleFlush();
1077 void WaylandToplevelWindow::HideTooltip() {
1078 auto* zaura_surface = GetZAuraSurface();
1079 if (zaura_surface && zaura_surface->HideTooltip()) {
1080 - connection()->Flush();
1081 + connection()->ScheduleFlush();
1085 @@ -1001,7 +1001,7 @@ void WaylandToplevelWindow::TriggerStateChanges() {
1088 delegate()->OnWindowStateChanged(previous_state_, state_);
1089 - connection()->Flush();
1090 + connection()->ScheduleFlush();
1093 void WaylandToplevelWindow::SetWindowState(PlatformWindowState state) {
1094 @@ -1035,7 +1035,7 @@ void WaylandToplevelWindow::SetSizeConstraints() {
1095 shell_toplevel_->SetCanMaximize(delegate()->CanMaximize());
1096 shell_toplevel_->SetCanFullscreen(delegate()->CanFullscreen());
1098 - connection()->Flush();
1099 + connection()->ScheduleFlush();
1102 void WaylandToplevelWindow::SetOrResetRestoredBounds() {
1103 diff --git a/ui/ozone/platform/wayland/host/wayland_window.cc b/ui/ozone/platform/wayland/host/wayland_window.cc
1104 index ad4366edfe4db..9a18c567bcbcc 100644
1105 --- a/ui/ozone/platform/wayland/host/wayland_window.cc
1106 +++ b/ui/ozone/platform/wayland/host/wayland_window.cc
1107 @@ -686,6 +686,10 @@ std::string WaylandWindow::WindowStates::ToString() const {
1111 +void WaylandWindow::OnSurfaceContentChanged() {
1112 + connection_->ScheduleFlush();
1115 void WaylandWindow::HandleToplevelConfigure(int32_t widht,
1117 const WindowStates& window_states) {
1118 @@ -832,7 +836,7 @@ bool WaylandWindow::Initialize(PlatformWindowInitProperties properties) {
1119 root_surface_->EnableTrustedDamageIfPossible();
1120 root_surface_->ApplyPendingState();
1122 - connection_->Flush();
1123 + connection_->ScheduleFlush();
1127 diff --git a/ui/ozone/platform/wayland/host/wayland_window.h b/ui/ozone/platform/wayland/host/wayland_window.h
1128 index d68d4d818f28f..2c5afbb3de99c 100644
1129 --- a/ui/ozone/platform/wayland/host/wayland_window.h
1130 +++ b/ui/ozone/platform/wayland/host/wayland_window.h
1131 @@ -230,6 +230,8 @@ class WaylandWindow : public PlatformWindow,
1132 // currently bound to.
1133 virtual void HandleSurfaceConfigure(uint32_t serial);
1135 + void OnSurfaceContentChanged();
1137 struct WindowStates {
1138 bool is_maximized = false;
1139 bool is_fullscreen = false;
1140 diff --git a/ui/ozone/platform/wayland/host/wayland_window_drag_controller.cc b/ui/ozone/platform/wayland/host/wayland_window_drag_controller.cc
1141 index e38565635a583..ff201c038efb7 100644
1142 --- a/ui/ozone/platform/wayland/host/wayland_window_drag_controller.cc
1143 +++ b/ui/ozone/platform/wayland/host/wayland_window_drag_controller.cc
1144 @@ -91,7 +91,7 @@ class WaylandWindowDragController::ExtendedDragSource {
1145 auto* surface = window ? window->root_surface()->surface() : nullptr;
1146 zcr_extended_drag_source_v1_drag(source_.get(), surface, offset.x(),
1148 - connection_->Flush();
1149 + connection_->ScheduleFlush();
1153 diff --git a/ui/ozone/platform/wayland/host/wayland_window_factory.cc b/ui/ozone/platform/wayland/host/wayland_window_factory.cc
1154 index 6f66c6654819c..e2bc045e4b3fb 100644
1155 --- a/ui/ozone/platform/wayland/host/wayland_window_factory.cc
1156 +++ b/ui/ozone/platform/wayland/host/wayland_window_factory.cc
1158 #include "ui/ozone/platform/wayland/host/wayland_window.h"
1159 #include "ui/platform_window/platform_window_init_properties.h"
1161 +#include "ui/ozone/platform/wayland/host/wayland_extensions.h"
1166 @@ -29,6 +31,12 @@ std::unique_ptr<WaylandWindow> WaylandWindow::Create(
1167 // toplevel window instead.
1168 if (auto* parent = connection->window_manager()->GetWindow(
1169 properties.parent_widget)) {
1170 + if (connection->extensions()) {
1171 + window = connection->extensions()->CreateWaylandWindow(delegate,
1176 window = std::make_unique<WaylandPopup>(delegate, connection, parent);
1178 DLOG(WARNING) << "Failed to determine parent for menu/popup window.";
1179 @@ -40,6 +48,12 @@ std::unique_ptr<WaylandWindow> WaylandWindow::Create(
1180 case PlatformWindowType::kDrag:
1181 // TODO(crbug.com/1399419): Figure out what kind of surface we need to
1182 // create for kBubble and kDrag windows.
1183 + if (connection->extensions()) {
1185 + connection->extensions()->CreateWaylandWindow(delegate, connection);
1189 window = std::make_unique<WaylandToplevelWindow>(delegate, connection);
1192 diff --git a/ui/ozone/platform/wayland/host/wayland_zwp_linux_dmabuf.cc b/ui/ozone/platform/wayland/host/wayland_zwp_linux_dmabuf.cc
1193 index 33935db68eadd..15f600ed7a126 100644
1194 --- a/ui/ozone/platform/wayland/host/wayland_zwp_linux_dmabuf.cc
1195 +++ b/ui/ozone/platform/wayland/host/wayland_zwp_linux_dmabuf.cc
1196 @@ -104,7 +104,7 @@ void WaylandZwpLinuxDmabuf::CreateBuffer(const base::ScopedFD& fd,
1197 // created buffer and notify the client about it via the |callback|.
1198 pending_params_.emplace(std::move(params), std::move(callback));
1200 - connection_->Flush();
1201 + connection_->ScheduleFlush();
1204 bool WaylandZwpLinuxDmabuf::CanCreateBufferImmed() const {
1205 @@ -147,7 +147,7 @@ void WaylandZwpLinuxDmabuf::NotifyRequestCreateBufferDone(
1206 DCHECK(it != pending_params_.end());
1207 std::move(it->second).Run(wl::Object<wl_buffer>(new_buffer));
1208 pending_params_.erase(it);
1209 - connection_->Flush();
1210 + connection_->ScheduleFlush();
1214 diff --git a/ui/ozone/platform/wayland/host/xdg_foreign_wrapper.cc b/ui/ozone/platform/wayland/host/xdg_foreign_wrapper.cc
1215 index 293c09a7e35f2..d36db127ec057 100644
1216 --- a/ui/ozone/platform/wayland/host/xdg_foreign_wrapper.cc
1217 +++ b/ui/ozone/platform/wayland/host/xdg_foreign_wrapper.cc
1218 @@ -158,7 +158,7 @@ void XdgForeignWrapperImpl<zxdg_exporter_v1, zxdg_exported_v1>::
1219 &kXdgExportedListener, this);
1221 exported_surfaces_.emplace_back(std::move(exported_surface));
1222 - connection_->Flush();
1223 + connection_->ScheduleFlush();
1227 @@ -174,7 +174,7 @@ void XdgForeignWrapperImpl<zxdg_exporter_v2, zxdg_exported_v2>::
1228 &kXdgExportedListener, this);
1230 exported_surfaces_.emplace_back(std::move(exported_surface));
1231 - connection_->Flush();
1232 + connection_->ScheduleFlush();
1236 diff --git a/ui/ozone/platform/wayland/host/xdg_popup_wrapper_impl.cc b/ui/ozone/platform/wayland/host/xdg_popup_wrapper_impl.cc
1237 index 64c8f2663ae60..b0d8f27aebbf9 100644
1238 --- a/ui/ozone/platform/wayland/host/xdg_popup_wrapper_impl.cc
1239 +++ b/ui/ozone/platform/wayland/host/xdg_popup_wrapper_impl.cc
1240 @@ -239,7 +239,7 @@ bool XDGPopupWrapperImpl::SetBounds(const gfx::Rect& new_bounds) {
1241 xdg_popup_reposition(xdg_popup_.get(), positioner.get(),
1242 ++next_reposition_token_);
1244 - connection_->Flush();
1245 + connection_->ScheduleFlush();
1249 diff --git a/ui/ozone/platform/wayland/host/xdg_surface_wrapper_impl.cc b/ui/ozone/platform/wayland/host/xdg_surface_wrapper_impl.cc
1250 index c4dd8c8e78ce4..67702ecc8fa4f 100644
1251 --- a/ui/ozone/platform/wayland/host/xdg_surface_wrapper_impl.cc
1252 +++ b/ui/ozone/platform/wayland/host/xdg_surface_wrapper_impl.cc
1253 @@ -39,7 +39,7 @@ bool XDGSurfaceWrapperImpl::Initialize() {
1255 xdg_surface_add_listener(xdg_surface_.get(), &kXdgSurfaceListener, this);
1257 - connection_->Flush();
1258 + connection_->ScheduleFlush();
1262 diff --git a/ui/ozone/platform/wayland/host/xdg_toplevel_wrapper_impl.cc b/ui/ozone/platform/wayland/host/xdg_toplevel_wrapper_impl.cc
1263 index 0673c59185348..b9462c60a2eee 100644
1264 --- a/ui/ozone/platform/wayland/host/xdg_toplevel_wrapper_impl.cc
1265 +++ b/ui/ozone/platform/wayland/host/xdg_toplevel_wrapper_impl.cc
1266 @@ -720,7 +720,7 @@ void XDGToplevelWrapperImpl::ShowSnapPreview(
1268 void XDGToplevelWrapperImpl::AckRotateFocus(uint32_t serial, uint32_t handled) {
1269 zaura_toplevel_ack_rotate_focus(aura_toplevel_.get(), serial, handled);
1270 - connection_->Flush();
1271 + connection_->ScheduleFlush();
1274 XDGToplevelWrapperImpl* XDGToplevelWrapperImpl::AsXDGToplevelWrapper() {
1275 diff --git a/ui/ozone/platform/wayland/host/zwp_primary_selection_device.cc b/ui/ozone/platform/wayland/host/zwp_primary_selection_device.cc
1276 index 9057d1bea0116..97c1624e200ac 100644
1277 --- a/ui/ozone/platform/wayland/host/zwp_primary_selection_device.cc
1278 +++ b/ui/ozone/platform/wayland/host/zwp_primary_selection_device.cc
1279 @@ -32,7 +32,7 @@ void ZwpPrimarySelectionDevice::SetSelectionSource(
1280 auto* data_source = source ? source->data_source() : nullptr;
1281 zwp_primary_selection_device_v1_set_selection(data_device_.get(), data_source,
1283 - connection()->Flush();
1284 + connection()->ScheduleFlush();
1288 diff --git a/ui/ozone/platform/wayland/host/zwp_primary_selection_device_manager.cc b/ui/ozone/platform/wayland/host/zwp_primary_selection_device_manager.cc
1289 index 9d5d79635b66d..2ca82ce6031ba 100644
1290 --- a/ui/ozone/platform/wayland/host/zwp_primary_selection_device_manager.cc
1291 +++ b/ui/ozone/platform/wayland/host/zwp_primary_selection_device_manager.cc
1292 @@ -66,7 +66,7 @@ ZwpPrimarySelectionDevice* ZwpPrimarySelectionDeviceManager::GetDevice() {
1294 zwp_primary_selection_device_manager_v1_get_device(
1295 device_manager_.get(), connection_->seat()->wl_object()));
1296 - connection_->Flush();
1297 + connection_->ScheduleFlush();
1300 return device_.get();
1301 @@ -77,7 +77,7 @@ ZwpPrimarySelectionDeviceManager::CreateSource(
1302 ZwpPrimarySelectionSource::Delegate* delegate) {
1303 auto* data_source = zwp_primary_selection_device_manager_v1_create_source(
1304 device_manager_.get());
1305 - connection_->Flush();
1306 + connection_->ScheduleFlush();
1307 return std::make_unique<ZwpPrimarySelectionSource>(data_source, connection_,
1310 diff --git a/ui/platform_window/agl/platform_window_agl.h b/ui/platform_window/agl/platform_window_agl.h
1311 new file mode 100644
1312 index 0000000000000..4bc915d663e72
1314 +++ b/ui/platform_window/agl/platform_window_agl.h
1316 +// Copyright 2021 LG Electronics, Inc.
1318 +// Licensed under the Apache License, Version 2.0 (the "License");
1319 +// you may not use this file except in compliance with the License.
1320 +// You may obtain a copy of the License at
1322 +// http://www.apache.org/licenses/LICENSE-2.0
1324 +// Unless required by applicable law or agreed to in writing, software
1325 +// distributed under the License is distributed on an "AS IS" BASIS,
1326 +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1327 +// See the License for the specific language governing permissions and
1328 +// limitations under the License.
1330 +// SPDX-License-Identifier: Apache-2.0
1332 +#ifndef UI_PLATFORM_WINDOW_AGL_PLATFORM_WINDOW_AGL_H_
1333 +#define UI_PLATFORM_WINDOW_AGL_PLATFORM_WINDOW_AGL_H_
1339 +// AGL additions for platform window.
1340 +class PlatformWindowAgl {
1342 + virtual void SetAglActivateApp(const std::string& app) {}
1343 + virtual void SetAglAppId(const std::string& title) {}
1344 + virtual void SetAglReady() {}
1345 + virtual void SetAglBackground() {}
1346 + virtual void SetAglPanel(uint32_t edge) {}
1351 +#endif // UI_PLATFORM_WINDOW_AGL_PLATFORM_WINDOW_AGL_H_
1352 diff --git a/ui/platform_window/platform_window.h b/ui/platform_window/platform_window.h
1353 index 845da9467d6a4..a9b28388ec649 100644
1354 --- a/ui/platform_window/platform_window.h
1355 +++ b/ui/platform_window/platform_window.h
1360 +#include "agl/platform_window_agl.h"
1361 #include "base/component_export.h"
1362 #include "ui/base/class_property.h"
1363 #include "ui/base/ui_base_types.h"
1364 @@ -32,7 +33,8 @@ class PlatformCursor;
1366 // Generic PlatformWindow interface.
1367 class COMPONENT_EXPORT(PLATFORM_WINDOW) PlatformWindow
1368 - : public PropertyHandler {
1369 + : public PropertyHandler,
1370 + public PlatformWindowAgl {
1373 ~PlatformWindow() override;