wayland: Phase 61 — allocate workspace 0 in Wayland screen init

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 <noreply@anthropic.com>
This commit is contained in:
Levi Neely 2026-03-28 08:57:52 +01:00
parent 3c428e25d9
commit 04f8a46ae5
1 changed files with 12 additions and 2 deletions

View File

@ -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;