chromium84: Add a delay to agl ready event
[AGL/meta-agl-demo.git] / recipes-wam / chromium / files / add-a-delay-to-agl-ready-event.patch
diff --git a/recipes-wam/chromium/files/add-a-delay-to-agl-ready-event.patch b/recipes-wam/chromium/files/add-a-delay-to-agl-ready-event.patch
new file mode 100644 (file)
index 0000000..20caccb
--- /dev/null
@@ -0,0 +1,70 @@
+From d2d09d3e13a3874961971d343553106a1f3d5ac7 Mon Sep 17 00:00:00 2001
+From: Roger Zanoni <rzanoni@igalia.com>
+Date: Thu, 3 Jun 2021 10:53:40 +0200
+Subject: [PATCH] Add a delay to agl ready event
+
+Delay ready() to ensure that all the window and surfaces setup
+is done before notifying the compositor
+---
+ .../ozone/platform/wayland/host/wayland_window.cc  | 14 +++++++++++++-
+ .../ozone/platform/wayland/host/wayland_window.h   |  5 +++++
+ 2 files changed, 18 insertions(+), 1 deletion(-)
+
+diff --git a/src/ui/ozone/platform/wayland/host/wayland_window.cc b/src/ui/ozone/platform/wayland/host/wayland_window.cc
+index d2a9b0dae5..27749fd70d 100644
+--- a/src/ui/ozone/platform/wayland/host/wayland_window.cc
++++ b/src/ui/ozone/platform/wayland/host/wayland_window.cc
+@@ -299,7 +299,19 @@ WaylandWindow::SetAglReady(void)
+   if (!connection_->agl_shell_manager) {
+       return;
+   }
+-  connection_->agl_shell_manager->ready();
++
++  // Delay activation to ensure that all the setup is done
++  // TODO(rzanoni): find a more deterministic way of doing this
++  set_ready_timer_.Start(FROM_HERE,
++                         base::TimeDelta::FromMilliseconds(500),
++                         this,
++                         &WaylandWindow::SetReadyCallback);
++}
++
++
++void WaylandWindow::SetReadyCallback() {
++    connection_->agl_shell_manager->ready();
++    connection_->ScheduleFlush();
+ }
+ bool WaylandWindow::CanDispatchEvent(const PlatformEvent& event) {
+diff --git a/src/ui/ozone/platform/wayland/host/wayland_window.h b/src/ui/ozone/platform/wayland/host/wayland_window.h
+index 2acac98ae9..c10db38d21 100644
+--- a/src/ui/ozone/platform/wayland/host/wayland_window.h
++++ b/src/ui/ozone/platform/wayland/host/wayland_window.h
+@@ -15,6 +15,7 @@
+ #include "base/containers/flat_set.h"
+ #include "base/gtest_prod_util.h"
+ #include "base/memory/ref_counted.h"
++#include "base/timer/timer.h"
+ #include "ui/events/platform/platform_event_dispatcher.h"
+ #include "ui/gfx/geometry/rect.h"
+ #include "ui/gfx/native_widget_types.h"
+@@ -232,6 +233,8 @@ class WaylandWindow : public PlatformWindow, public PlatformEventDispatcher {
+   // Returns a root parent window.
+   WaylandWindow* GetRootParentWindow();
++  void SetReadyCallback();
++
+   // Install a surface listener and start getting wl_output enter/leave events.
+   void AddSurfaceListener();
+@@ -311,6 +314,8 @@ class WaylandWindow : public PlatformWindow, public PlatformEventDispatcher {
+   // The type of the current WaylandWindow object.
+   ui::PlatformWindowType type_ = ui::PlatformWindowType::kWindow;
++  base::OneShotTimer set_ready_timer_;
++
+   DISALLOW_COPY_AND_ASSIGN(WaylandWindow);
+ };
+-- 
+2.32.0
+