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
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
5
6 Delay ready() to ensure that all the window and surfaces setup
7 is done before notifying the compositor
8 ---
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(-)
12
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) {
19        return;
20    }
21 -  connection_->agl_shell_manager->ready();
22 +
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),
27 +                         this,
28 +                         &WaylandWindow::SetReadyCallback);
29 +}
30 +
31 +
32 +void WaylandWindow::SetReadyCallback() {
33 +    connection_->agl_shell_manager->ready();
34 +    connection_->ScheduleFlush();
35  }
36  
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
42 @@ -15,6 +15,7 @@
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();
53  
54 +  void SetReadyCallback();
55 +
56    // Install a surface listener and start getting wl_output enter/leave events.
57    void AddSurfaceListener();
58  
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;
62  
63 +  base::OneShotTimer set_ready_timer_;
64 +
65    DISALLOW_COPY_AND_ASSIGN(WaylandWindow);
66  };
67  
68 -- 
69 2.32.0
70