Bug 1592350 [Wayland] Call wl_surface_commit() on parent surface when subsurface position is updated, r=jhorak
authorMartin Stransky <stransky@redhat.com>
Thu, 31 Oct 2019 19:00:30 +0000
changeset 500133 5aac68cd0f8b87aa860ba101795d4c02aa075423
parent 500132 597370891189fbab4559238892c2e2fa8e2213af
child 500134 9c9fffed78e5aa1ff3a945755a3c28d93c6e1373
push id99418
push userncsoregi@mozilla.com
push dateFri, 01 Nov 2019 08:54:50 +0000
treeherderautoland@5aac68cd0f8b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjhorak
bugs1592350
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1592350 [Wayland] Call wl_surface_commit() on parent surface when subsurface position is updated, r=jhorak Differential Revision: https://phabricator.services.mozilla.com/D51133
widget/gtk/mozcontainer.cpp
widget/gtk/mozcontainer.h
--- a/widget/gtk/mozcontainer.cpp
+++ b/widget/gtk/mozcontainer.cpp
@@ -150,19 +150,19 @@ static gint moz_container_get_scale(MozC
     GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(container));
     return (*sGdkWindowGetScaleFactorPtr)(window);
   }
 
   return 1;
 }
 
 void moz_container_move(MozContainer* container, int dx, int dy) {
-  if (container->subsurface) {
-    wl_subsurface_set_position(container->subsurface, dx, dy);
-  }
+  container->subsurface_dx = dx;
+  container->subsurface_dy = dy;
+  container->surface_position_update = true;
 }
 
 void moz_container_scale_update(MozContainer* container) {
   if (container->surface) {
     gint scale = moz_container_get_scale(container);
     wl_surface_set_buffer_scale(container->surface, scale);
   }
 }
@@ -210,16 +210,19 @@ void moz_container_init(MozContainer* co
   container->subsurface = nullptr;
   container->eglwindow = nullptr;
   container->frame_callback_handler = nullptr;
   container->frame_callback_handler_surface_id = -1;
   // We can draw to x11 window any time.
   container->ready_to_draw = GDK_IS_X11_DISPLAY(gdk_display_get_default());
   container->surface_needs_clear = true;
   container->inital_draw_cb = nullptr;
+  container->subsurface_dx = 0;
+  container->subsurface_dy = 0;
+  container->surface_position_update = 0;
 #endif
 
   LOG(("%s [%p]\n", __FUNCTION__, (void*)container));
 }
 
 #if defined(MOZ_WAYLAND)
 void moz_container_set_initial_draw_callback(
     MozContainer* container, std::function<void(void)> inital_draw_cb) {
@@ -592,17 +595,18 @@ struct wl_surface* moz_container_get_wl_
     }
 
     container->subsurface = wl_subcompositor_get_subsurface(
         waylandDisplay->GetSubcompositor(), container->surface, parent_surface);
 
     GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(container));
     gint x, y;
     gdk_window_get_position(window, &x, &y);
-    wl_subsurface_set_position(container->subsurface, x, y);
+    moz_container_move(container, x, y);
+
     wl_subsurface_set_desync(container->subsurface);
 
     // Route input to parent wl_surface owned by Gtk+ so we get input
     // events from Gtk+.
     wl_region* region = wl_compositor_create_region(compositor);
     wl_surface_set_input_region(container->surface, region);
     wl_region_destroy(region);
 
@@ -611,16 +615,30 @@ struct wl_surface* moz_container_get_wl_
 
     wl_surface_commit(container->surface);
     wl_display_flush(waylandDisplay->GetDisplay());
 
     LOGWAYLAND(("%s [%p] created surface %p\n", __FUNCTION__, (void*)container,
                 (void*)container->surface));
   }
 
+  // wl_subsurface_set_position is actually property of parent surface
+  // which is effective when parent surface is commited.
+  if (container->surface_position_update) {
+    wl_surface* parent_surface =
+        moz_container_get_gtk_container_surface(container);
+    if (parent_surface) {
+      wl_subsurface_set_position(container->subsurface,
+                                 container->subsurface_dx,
+                                 container->subsurface_dy);
+      wl_surface_commit(parent_surface);
+      container->surface_position_update = true;
+    }
+  }
+
   return container->surface;
 }
 
 struct wl_egl_window* moz_container_get_wl_egl_window(MozContainer* container) {
   LOGWAYLAND(("%s [%p] eglwindow %p\n", __FUNCTION__, (void*)container,
               (void*)container->eglwindow));
 
   if (!container->eglwindow) {
--- a/widget/gtk/mozcontainer.h
+++ b/widget/gtk/mozcontainer.h
@@ -70,19 +70,21 @@ struct wl_subsurface;
 
 struct _MozContainer {
   GtkContainer container;
   GList* children;
 
 #ifdef MOZ_WAYLAND
   struct wl_surface* surface;
   struct wl_subsurface* subsurface;
+  int subsurface_dx, subsurface_dy;
   struct wl_egl_window* eglwindow;
   struct wl_callback* frame_callback_handler;
   int frame_callback_handler_surface_id;
+  gboolean surface_position_update;
   gboolean surface_needs_clear;
   gboolean ready_to_draw;
   std::function<void(void)> inital_draw_cb;
 #endif
   gboolean force_default_visual;
 };
 
 struct _MozContainerClass {