From 04f8a46ae5281fe14e436fe4dcb1a2d8c8e87553 Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Sat, 28 Mar 2026 08:57:52 +0100 Subject: [PATCH] =?UTF-8?q?wayland:=20Phase=2061=20=E2=80=94=20allocate=20?= =?UTF-8?q?workspace=200=20in=20Wayland=20screen=20init?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit wScreenInit skips wWorkspaceNew (which calls wDockCreate, an X11 operation) via goto screen_done. This left workspace_count=0, causing a divide-by-zero in wManageWindow when a window carries saved state (workspace % scr->workspace_count). Allocate a minimal WWorkspace directly before the goto so the Wayland path always has exactly one workspace. Co-Authored-By: Claude Sonnet 4.6 --- src/screen.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/screen.c b/src/screen.c index f62ed97..fb62bac 100644 --- a/src/screen.c +++ b/src/screen.c @@ -158,9 +158,19 @@ WScreen *wScreenInit(int screen_number) wm_backend->monitors_select_events(scr); wm_backend->screen_set_root_cursor(scr, WCUR_ROOT); - /* Wayland path: screen_open() sets geometry; X11/wrlib context not needed. */ - if (!dpy) + /* Wayland path: screen_open() sets geometry; X11/wrlib context not needed. + * Allocate workspace 0 directly (wWorkspaceNew is unsafe here because it + * calls wDockCreate which requires X11 rendering resources). */ + if (!dpy) { + WWorkspace *wspace = wmalloc(sizeof(WWorkspace)); + wspace->name = wstrdup("Workspace 1"); + wspace->clip = NULL; + wspace->map = NULL; + scr->workspaces = wmalloc(sizeof(WWorkspace *)); + scr->workspaces[0] = wspace; + scr->workspace_count = 1; goto screen_done; + } /* screen descriptor for raster graphic library */ rattr.flags = RC_RenderMode | RC_ColorsPerChannel | RC_StandardColormap;