1 From d2d09d3e13a3874961971d343553106a1f3d5ac7 Mon Sep 17 00:00:00 2001
2 From: Roger Zanoni <rzanoni@igalia.com>
3 Date: Thu, 3 Jun 2021 10:53:40 +0200
4 Subject: [PATCH] Add a delay to agl ready event
6 Delay ready() to ensure that all the window and surfaces setup
7 is done before notifying the compositor
9 .../ozone/platform/wayland/host/wayland_window.cc | 14 +++++++++++++-
10 .../ozone/platform/wayland/host/wayland_window.h | 5 +++++
11 2 files changed, 18 insertions(+), 1 deletion(-)
13 diff --git a/src/ui/ozone/platform/wayland/host/wayland_window.cc b/src/ui/ozone/platform/wayland/host/wayland_window.cc
14 index d2a9b0dae5..27749fd70d 100644
15 --- a/src/ui/ozone/platform/wayland/host/wayland_window.cc
16 +++ b/src/ui/ozone/platform/wayland/host/wayland_window.cc
17 @@ -299,7 +299,19 @@ WaylandWindow::SetAglReady(void)
18 if (!connection_->agl_shell_manager) {
21 - connection_->agl_shell_manager->ready();
23 + // Delay activation to ensure that all the setup is done
24 + // TODO(rzanoni): find a more deterministic way of doing this
25 + set_ready_timer_.Start(FROM_HERE,
26 + base::TimeDelta::FromMilliseconds(500),
28 + &WaylandWindow::SetReadyCallback);
32 +void WaylandWindow::SetReadyCallback() {
33 + connection_->agl_shell_manager->ready();
34 + connection_->ScheduleFlush();
37 bool WaylandWindow::CanDispatchEvent(const PlatformEvent& event) {
38 diff --git a/src/ui/ozone/platform/wayland/host/wayland_window.h b/src/ui/ozone/platform/wayland/host/wayland_window.h
39 index 2acac98ae9..c10db38d21 100644
40 --- a/src/ui/ozone/platform/wayland/host/wayland_window.h
41 +++ b/src/ui/ozone/platform/wayland/host/wayland_window.h
43 #include "base/containers/flat_set.h"
44 #include "base/gtest_prod_util.h"
45 #include "base/memory/ref_counted.h"
46 +#include "base/timer/timer.h"
47 #include "ui/events/platform/platform_event_dispatcher.h"
48 #include "ui/gfx/geometry/rect.h"
49 #include "ui/gfx/native_widget_types.h"
50 @@ -232,6 +233,8 @@ class WaylandWindow : public PlatformWindow, public PlatformEventDispatcher {
51 // Returns a root parent window.
52 WaylandWindow* GetRootParentWindow();
54 + void SetReadyCallback();
56 // Install a surface listener and start getting wl_output enter/leave events.
57 void AddSurfaceListener();
59 @@ -311,6 +314,8 @@ class WaylandWindow : public PlatformWindow, public PlatformEventDispatcher {
60 // The type of the current WaylandWindow object.
61 ui::PlatformWindowType type_ = ui::PlatformWindowType::kWindow;
63 + base::OneShotTimer set_ready_timer_;
65 DISALLOW_COPY_AND_ASSIGN(WaylandWindow);