xwm: Fix crash when querying position of XWAYLAND windows

windows in the XWAYLAND state are popups and other such things that aren't
managed by libweston-desktop, so we crash if we query their position
with weston_desktop_api.

Query the position for these XWAYLAND windows based on their weston_view
and window geometry.

This should result in synthetic configure notify events no longer crashing.

Fixes #831
Fixes #1019

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
Derek Foreman 2025-05-05 12:37:59 -05:00 committed by Marius Vlad
parent 1560cc3f0b
commit cb17b87a65

View file

@ -471,7 +471,23 @@ static void
get_position(struct weston_desktop_xwayland_surface *surface, get_position(struct weston_desktop_xwayland_surface *surface,
int32_t *x, int32_t *y) int32_t *x, int32_t *y)
{ {
if (!surface->surface) { if (surface->state == XWAYLAND) {
struct weston_coord_global pos;
struct weston_geometry geom;
if (surface->has_next_geometry)
geom = surface->next_geometry;
else
geom = weston_desktop_surface_get_geometry(surface->surface);
pos = weston_view_get_pos_offset_global(surface->view);
*x = (int)pos.c.x + geom.x;
*y = (int)pos.c.y + geom.y;
return;
}
if (!surface->surface ||
!weston_desktop_surface_get_user_data(surface->surface)) {
*x = 0; *x = 0;
*y = 0; *y = 0;
return; return;