From 803666fd5efbb627f10e8ca526b433fa74b80e7e Mon Sep 17 00:00:00 2001 From: Levi Neely <141506390+lneely@users.noreply.github.com> Date: Wed, 13 May 2026 07:38:38 +0200 Subject: [PATCH] WIP: Pure Wayland WINGs screen init (no X11 in WM path) - WMCreateScreenWithRContext: add Wayland path that skips all X11 calls (no GCs, no atoms, no XListProperties, no XCreateGC) - screen.c: skip RCreateContext in Wayland mode (pass NULL rcontext) - Wayland path initializes: font/event/render backends, colors, fonts Current issue: W_RealizeView tries to create X11 windows for WINGs widgets. Need to make view realization work without X11 (views should be pixman buffers in Wayland mode, not X windows). The grey background + cursor render correctly. Startup reaches WINGs init but crashes when widgets try to realize without a display. --- WINGs/widgets.c | 39 +++++++++++++++++++++++++++++++++++++++ src/screen.c | 39 ++++----------------------------------- 2 files changed, 43 insertions(+), 35 deletions(-) diff --git a/WINGs/widgets.c b/WINGs/widgets.c index f5cfd55..4ccb6f9 100644 --- a/WINGs/widgets.c +++ b/WINGs/widgets.c @@ -619,6 +619,45 @@ WMScreen *WMCreateScreenWithRContext(Display * display, int screen, RContext * c scrPtr->screen = screen; scrPtr->rcontext = context; + /* --- Wayland path: no X11 calls --- */ + if (getenv("WMAKER_USE_WAYLAND")) { + scrPtr->depth = context ? context->depth : 24; + scrPtr->visual = context ? context->visual : NULL; + scrPtr->colormap = context ? context->cmap : 0; + scrPtr->rootWin = None; + + scrPtr->fontCache = WMCreateHashTable(WMStringPointerHashCallbacks); + + scrPtr->fontBackend = &W_FontBackendWL; + scrPtr->fontBackendCtx = scrPtr->fontBackend->screen_init(scrPtr); + scrPtr->eventBackend = &W_EventBackendWL; + scrPtr->eventBackendCtx = scrPtr->eventBackend->screen_init(scrPtr); + scrPtr->renderBackend = &W_RenderBackendWL; + scrPtr->renderBackendCtx = scrPtr->renderBackend->screen_init(scrPtr); + + scrPtr->antialiasedText = WINGsConfiguration.antialiasedText; + + /* Allocate basic colors */ + WMWhiteColor(scrPtr); + WMBlackColor(scrPtr); + WMGrayColor(scrPtr); + WMDarkGrayColor(scrPtr); + + /* Load fonts */ + scrPtr->normalFont = WMSystemFontOfSize(scrPtr, 0); + scrPtr->boldFont = WMBoldSystemFontOfSize(scrPtr, 0); + if (!scrPtr->boldFont) + scrPtr->boldFont = scrPtr->normalFont; + if (!scrPtr->normalFont) { + wwarning(_("could not load any fonts.")); + return NULL; + } + + return scrPtr; + } + + /* --- X11 path (unchanged) --- */ + scrPtr->depth = context->depth; scrPtr->visual = context->visual; diff --git a/src/screen.c b/src/screen.c index cf51f93..fa2102f 100644 --- a/src/screen.c +++ b/src/screen.c @@ -163,42 +163,11 @@ WScreen *wScreenInit(int screen_number) * set, Path 1), fall through to the full X11 init so WINGs, RContext, * GCs, and menus work correctly on the XWayland display. */ if (wm_backend->is_wayland && !dpy) { - extern Display *wl_get_x_display(void); - Display *xdpy = wl_get_x_display(); + scr->w_depth = 24; + scr->rcontext = NULL; - if (!xdpy) { - /* No XWayland — truly headless. Minimal workspace only. */ - 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; - wm_backend->screen_create_internals(scr); - goto screen_done; - } - - /* XWayland available — create RContext on it for texture rendering. */ - rattr.flags = RC_RenderMode | RC_ColorsPerChannel | RC_StandardColormap; - rattr.render_mode = RBestMatchRendering; - rattr.colors_per_channel = 4; - rattr.standard_colormap_mode = RUseStdColormap; - - scr->rcontext = RCreateContext(xdpy, DefaultScreen(xdpy), &rattr); - if (!scr->rcontext) { - rattr.flags &= ~RC_StandardColormap; - scr->rcontext = RCreateContext(xdpy, DefaultScreen(xdpy), &rattr); - } - - if (scr->rcontext) { - scr->w_win = scr->rcontext->drawable; - scr->w_visual = scr->rcontext->visual; - scr->w_depth = scr->rcontext->depth; - scr->w_colormap = scr->rcontext->cmap; - - scr->wmscreen = WMCreateScreenWithRContext(xdpy, DefaultScreen(xdpy), scr->rcontext); - } + /* WINGs screen — pure Wayland, no X11. */ + scr->wmscreen = WMCreateScreenWithRContext(NULL, 0, NULL); wm_backend->screen_create_internals(scr); goto screen_done;