[gtk+/gtk-3-22] wayland: Place subsurfaces relative to their parent



commit 605303681b19f8778d61b08f953027ba79313bbe
Author: Olivier Fourdan <ofourdan redhat com>
Date:   Wed Nov 23 14:55:40 2016 +0100

    wayland: Place subsurfaces relative to their parent
    
    Now that subsurfaces can be created as child of another GdkWindow (and
    not just the root window), they must be placed according to the location
    of their parent, i.e. the abs_x/abs_y must be updated and taken into
    account when placing and moving subsurfaces under Wayland.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=774917

 gdk/gdkwindow.c                 |    7 +++++--
 gdk/wayland/gdkwindow-wayland.c |    8 ++++++--
 2 files changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 28f5270..1d5baf2 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -973,9 +973,12 @@ recompute_visible_regions_internal (GdkWindow *private,
   old_abs_y = private->abs_y;
 
   /* Update absolute position */
-  if (gdk_window_has_impl (private))
+  if ((gdk_window_has_impl (private) &&
+       private->window_type != GDK_WINDOW_SUBSURFACE) ||
+      (gdk_window_is_toplevel (private) &&
+       private->window_type == GDK_WINDOW_SUBSURFACE))
     {
-      /* Native window starts here */
+      /* Native windows and toplevel subsurfaces start here */
       private->abs_x = 0;
       private->abs_y = 0;
     }
diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c
index 268db49..ce09b09 100644
--- a/gdk/wayland/gdkwindow-wayland.c
+++ b/gdk/wayland/gdkwindow-wayland.c
@@ -1280,7 +1280,9 @@ gdk_wayland_window_create_subsurface (GdkWindow *window)
       impl->display_server.wl_subsurface =
         wl_subcompositor_get_subsurface (display_wayland->subcompositor,
                                          impl->display_server.wl_surface, 
parent_impl->display_server.wl_surface);
-      wl_subsurface_set_position (impl->display_server.wl_subsurface, window->x, window->y);
+      wl_subsurface_set_position (impl->display_server.wl_subsurface,
+                                  window->x + window->abs_x,
+                                  window->y + window->abs_y);
 
       /* In order to synchronize the initial position with the initial frame
        * content, wait with making the subsurface desynchronized until after
@@ -2611,7 +2613,9 @@ gdk_window_wayland_move_resize (GdkWindow *window,
 
           if (impl->display_server.wl_subsurface)
             {
-              wl_subsurface_set_position (impl->display_server.wl_subsurface, x, y);
+              wl_subsurface_set_position (impl->display_server.wl_subsurface,
+                                          window->x + window->abs_x,
+                                          window->y + window->abs_y);
               gdk_window_request_transient_parent_commit (window);
             }
         }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]