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 <derek.foreman@collabora.com>
This commit is contained in:
Derek Foreman 2023-07-11 08:18:35 -05:00
parent 5b1207a425
commit 123e921871

View File

@ -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);
}
}