From 49246f80ca5e85273c15ec8bd5116a8b58094deb Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Sat, 28 Mar 2026 07:25:55 +0100 Subject: [PATCH] =?UTF-8?q?wayland:=20Phase=2055=20=E2=80=94=20window=5Fge?= =?UTF-8?q?t=5Frect=20returns=20real=20geometry;=20window=5Fmove=20tracks?= =?UTF-8?q?=20position?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add x,y position fields to wl_toplevel_view. wl_window_move now records the WM-assigned position in the view struct instead of discarding it. wl_window_get_rect previously returned 0 (invalid) for all synthetic IDs, causing wIconifyWindow and similar callers to treat every Wayland window as destroyed. Now returns 1 with real surface dimensions (from wlr_surface current.width/height) for valid toplevel views, 1 with output dimensions for other virtual windows, and 0 only for WNATIVE_NONE. Co-Authored-By: Claude Sonnet 4.6 --- src/backend/wayland/wl_backend.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/backend/wayland/wl_backend.c b/src/backend/wayland/wl_backend.c index 83e9e25..f829885 100644 --- a/src/backend/wayland/wl_backend.c +++ b/src/backend/wayland/wl_backend.c @@ -35,6 +35,8 @@ * WL_SEAT_CAPABILITY_KEYBOARD and WL_SEAT_CAPABILITY_POINTER. * Phase 54: virtual pointer position tracking; pointer_warp/warp_to update * state; pointer_query/query_full return tracked coordinates. + * Phase 55: window_get_rect returns real geometry for synthetic toplevel IDs; + * window_move records WM-assigned x,y in the view struct. */ #ifdef HAVE_CONFIG_H @@ -85,6 +87,7 @@ struct wl_toplevel_view { struct wl_listener destroy_listener; struct wl_listener title_listener; /* Phase 46: xdg_toplevel set_title */ WNativeWindow id; /* synthetic handle, >= 0x10000000 */ + int x, y; /* Phase 55: WM-assigned position */ struct wl_list link; /* wl_state.toplevel_list */ }; @@ -877,8 +880,9 @@ static void wl_window_map_subwindows(WNativeWindow parent) { (void)parent; } static void wl_window_unmap(WNativeWindow win) { (void)win; } static void wl_window_move(WNativeWindow win, int x, int y) { - /* Phase 44: position is tracked on the WM side; no server-side move needed. */ - (void)win; (void)x; (void)y; + /* Phase 55: record the WM-assigned position in the view struct. */ + struct wl_toplevel_view *v = wl_find_view_by_id(win); + if (v) { v->x = x; v->y = y; } } static void wl_window_resize(WNativeWindow win, int w, int h) @@ -899,9 +903,27 @@ static int wl_window_get_rect(WNativeWindow win, int *win_x, int *win_y, int *win_w, int *win_h) { - (void)win; - *win_x = *win_y = 0; *win_w = *win_h = 1; - return 0; + /* Phase 55: return real geometry for synthetic toplevel IDs. */ + if (win == WNATIVE_NONE) { + if (win_x) { *win_x = 0; } if (win_y) { *win_y = 0; } + if (win_w) { *win_w = 1; } if (win_h) { *win_h = 1; } + return 0; /* invalid/none */ + } + struct wl_toplevel_view *v = wl_find_view_by_id(win); + if (v && v->xdg_surface && v->xdg_surface->surface) { + int w = v->xdg_surface->surface->current.width; + int h = v->xdg_surface->surface->current.height; + if (win_x) { *win_x = v->x; } + if (win_y) { *win_y = v->y; } + if (win_w) { *win_w = w > 0 ? w : 1; } + if (win_h) { *win_h = h > 0 ? h : 1; } + return 1; + } + /* Non-synthetic virtual window (e.g. headless output root) — report + * full output dimensions so callers see a valid non-empty window. */ + if (win_x) { *win_x = 0; } if (win_y) { *win_y = 0; } + if (win_w) { *win_w = 1920; } if (win_h) { *win_h = 1080; } + return 1; } static void wl_window_add_events(WNativeWindow win, unsigned long extra_mask) { (void)win; (void)extra_mask; }