From 123e921871c8491427ac859dec5b87c24d4934bb Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Tue, 11 Jul 2023 08:18:35 -0500 Subject: [PATCH] xwayland: Fix assert with some parented windows Having use_geometry set is not the only time we have a parent window, apparently. Clicking on the 'Line diff' drop down in gitk would cause an assert() because of this. Fixes #769 Signed-off-by: Derek Foreman --- libweston/desktop/surface.c | 42 ++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/libweston/desktop/surface.c b/libweston/desktop/surface.c index 08a14c7d..1597544e 100644 --- a/libweston/desktop/surface.c +++ b/libweston/desktop/surface.c @@ -81,35 +81,39 @@ static void weston_desktop_surface_update_view_position(struct weston_desktop_surface *surface) { struct weston_desktop_view *view; + struct weston_desktop_surface *parent = + weston_desktop_surface_get_parent(surface); + int32_t x = surface->position.x; + int32_t y = surface->position.y; + + if (!parent) { + struct weston_coord_global pos; + + pos.c = weston_coord(x, y); + wl_list_for_each(view, &surface->view_list, link) + weston_view_set_position(view->view, pos); + + return; + } if (surface->use_geometry) { + struct weston_geometry geometry, parent_geometry; struct weston_desktop_surface *parent = weston_desktop_surface_get_parent(surface); - struct weston_geometry geometry, parent_geometry; - struct weston_coord offset; - - offset = weston_coord(surface->position.x, surface->position.y); geometry = weston_desktop_surface_get_geometry(surface); parent_geometry = weston_desktop_surface_get_geometry(parent); - offset.x += parent_geometry.x - geometry.x; - offset.y += parent_geometry.y - geometry.y; - wl_list_for_each(view, &surface->view_list, link) { - struct weston_view *wv = view->view; - struct weston_coord_surface surf_offset; + x += parent_geometry.x - geometry.x; + y += parent_geometry.y - geometry.y; + } - surf_offset.c = offset; - surf_offset.coordinate_space_id = wv->geometry.parent->surface; - weston_view_set_rel_position(wv, surf_offset); - } - } else { - struct weston_coord_global pos; + wl_list_for_each(view, &surface->view_list, link) { + struct weston_coord_surface offset; + struct weston_view *wv = view->view; - pos.c = weston_coord(surface->position.x, surface->position.y); - - wl_list_for_each(view, &surface->view_list, link) - weston_view_set_position(view->view, pos); + offset = weston_coord_surface(x, y, wv->geometry.parent->surface); + weston_view_set_rel_position(view->view, offset); } }