From 605303681b19f8778d61b08f953027ba79313bbe Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Wed, 23 Nov 2016 14:55:40 +0100 Subject: [PATCH] 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 28f52709ed..1d5baf2a26 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 268db49d99..ce09b0935b 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); } }