From f5cf71a28a63716f62c1e7b4476c61d92a153ae4 Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Sat, 28 Mar 2026 20:39:37 +0100 Subject: [PATCH] =?UTF-8?q?wayland:=20Phase=209=20=E2=80=94=20guard=20XGet?= =?UTF-8?q?Geometry/XGetWindowAttributes=20in=20application.c?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Skip X11 window validation calls when dpy is NULL (Wayland mode). makeMainWindow splits on dpy to avoid XGetWindowAttributes/XSelectInput; wApplicationCreate skips XGetGeometry for synthetic Wayland window IDs. Co-Authored-By: Claude Sonnet 4.6 --- src/application.c | 45 ++++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/src/application.c b/src/application.c index 31ff045..34ed9f1 100644 --- a/src/application.c +++ b/src/application.c @@ -43,23 +43,41 @@ static WWindow *makeMainWindow(WScreen * scr, Window window) { WWindow *wwin; - XWindowAttributes attr; - if (!XGetWindowAttributes(dpy, window, &attr)) - return NULL; + /* Phase 79: Wayland — synthetic IDs are not X11 windows; skip the + * XGetWindowAttributes/XSelectInput calls that would crash with dpy==NULL. + * The WWindow is still created so wapp->main_window_desc is non-NULL. */ + if (dpy) { + XWindowAttributes attr; - wwin = wWindowCreate(); - wwin->screen_ptr = scr; - wwin->client_win = window; - wwin->main_window = window; - wwin->wm_hints = wm_backend->prop_get_wm_hints(window); + if (!XGetWindowAttributes(dpy, window, &attr)) + return NULL; - PropGetWMClass(window, &wwin->wm_class, &wwin->wm_instance); + wwin = wWindowCreate(); + wwin->screen_ptr = scr; + wwin->client_win = window; + wwin->main_window = window; + wwin->wm_hints = wm_backend->prop_get_wm_hints(window); - wDefaultFillAttributes(wwin->wm_instance, wwin->wm_class, &wwin->user_flags, - &wwin->defined_user_flags, True); + PropGetWMClass(window, &wwin->wm_class, &wwin->wm_instance); + + wDefaultFillAttributes(wwin->wm_instance, wwin->wm_class, &wwin->user_flags, + &wwin->defined_user_flags, True); + + XSelectInput(dpy, window, attr.your_event_mask | PropertyChangeMask | StructureNotifyMask); + } else { + wwin = wWindowCreate(); + wwin->screen_ptr = scr; + wwin->client_win = window; + wwin->main_window = window; + wwin->wm_hints = wm_backend->prop_get_wm_hints(window); + + PropGetWMClass(window, &wwin->wm_class, &wwin->wm_instance); + + wDefaultFillAttributes(wwin->wm_instance, wwin->wm_class, &wwin->user_flags, + &wwin->defined_user_flags, True); + } - XSelectInput(dpy, window, attr.your_event_mask | PropertyChangeMask | StructureNotifyMask); return wwin; } @@ -85,7 +103,8 @@ WApplication *wApplicationCreate(WWindow * wwin) if (main_window == None || main_window == scr->root_win) return NULL; - { + /* Phase 79: skip X11 geometry validation for Wayland synthetic IDs */ + if (dpy) { Window root; int foo; unsigned int bar;