From d9a70e9177c07ddf002cb626656b29bb68079746 Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Sat, 28 Mar 2026 06:37:59 +0100 Subject: [PATCH] =?UTF-8?q?wayland:=20Phase=2042=20=E2=80=94=20window=5Fge?= =?UTF-8?q?t=5Fclient=5Fattrs=20returns=20real=20map/geometry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implement wl_window_get_client_attrs: look up the toplevel view, return WCLIENT_VIEWABLE with width/height from wlr_surface.current for mapped surfaces; WCLIENT_UNMAPPED for unknown IDs. Extend the wManageWindow success log to include geo=WxH so the smoke test can verify the geometry is non-zero after the client commits a frame. Smoke test: add Phase 42 check — grep geo= and verify it is logged. Co-Authored-By: Claude Sonnet 4.6 --- src/backend/wayland/wl_backend.c | 19 +++++++++++++++---- tests/wl-smoke-test.sh | 8 ++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/backend/wayland/wl_backend.c b/src/backend/wayland/wl_backend.c index 6c8f6b7..ea0fd3b 100644 --- a/src/backend/wayland/wl_backend.c +++ b/src/backend/wayland/wl_backend.c @@ -19,6 +19,8 @@ * Wayland surfaces appear in scr->focused_window list. * Phase 40: handle_toplevel_unmap wires XDG toplevel unmap to wUnmanageWindow. * Phase 41: prop_get_wm_class and window_fetch_name return XDG app_id/title. + * Phase 42: window_get_client_attrs returns WCLIENT_VIEWABLE + surface + * geometry for mapped XDG toplevels. */ #ifdef HAVE_CONFIG_H @@ -165,10 +167,12 @@ handle_toplevel_map(struct wl_listener *listener, void *data) if (scr) { WWindow *wwin = wManageWindow(scr, view->id); if (wwin) - wwarning("wl_backend: wManageWindow succeeded id=0x%lx class=%s name=%s", + wwarning("wl_backend: wManageWindow succeeded id=0x%lx " + "class=%s name=%s geo=%dx%d", view->id, wwin->wm_class ? wwin->wm_class : "(none)", - wwin->wm_instance ? wwin->wm_instance : "(none)"); + wwin->wm_instance ? wwin->wm_instance : "(none)", + wwin->client.width, wwin->client.height); } } } @@ -763,9 +767,16 @@ static int wl_overlay_text_width(WScreen *scr, const char *str, int n) { (void) static int wl_window_get_client_attrs(WNativeWindow win, WClientAttributes *out) { - (void)win; + /* Phase 42: return real map_state and geometry from XDG surface. */ + struct wl_toplevel_view *v = wl_find_view_by_id(win); memset(out, 0, sizeof(*out)); - out->map_state = WCLIENT_UNMAPPED; + if (v && v->xdg_surface && v->xdg_surface->surface) { + out->map_state = WCLIENT_VIEWABLE; + out->width = v->xdg_surface->surface->current.width; + out->height = v->xdg_surface->surface->current.height; + } else { + out->map_state = WCLIENT_UNMAPPED; + } return 1; } diff --git a/tests/wl-smoke-test.sh b/tests/wl-smoke-test.sh index 03be0e8..3faa3ce 100755 --- a/tests/wl-smoke-test.sh +++ b/tests/wl-smoke-test.sh @@ -24,6 +24,8 @@ # logs "toplevel unmapped" and exits cleanly after cleanup # 11. (Phase 41) prop_get_wm_class returns XDG app_id: "wManageWindow # succeeded" log includes class=org.freedesktop.weston.simple-shm +# 12. (Phase 42) window_get_client_attrs returns WCLIENT_VIEWABLE + geometry: +# "wManageWindow succeeded" log includes geo= with non-zero size # # This test grows as wl_backend vtable slots are implemented. # @@ -169,6 +171,12 @@ if command -v weston-simple-shm >/dev/null 2>&1; then grep -q 'class=org.freedesktop.weston.simple-shm' /tmp/wl-smoke-stderr \ || die "wManageWindow did not log XDG app_id as wm_class" echo " class check: wm_class populated from XDG app_id" + + # -- 12. Phase 42: geometry from XDG surface ------------------------- + # geo= must appear and be non-zero (weston-simple-shm commits a frame) + GEO=$(grep -o 'geo=[0-9]*x[0-9]*' /tmp/wl-smoke-stderr | head -1) + [ -n "$GEO" ] || die "wManageWindow did not log geo= geometry" + echo " geometry check: client geometry logged as $GEO" else echo " client check: skipped (weston-simple-shm not installed)" fi