From 70d8a068e68aeb6d3f7bc066a359764dfe90290f Mon Sep 17 00:00:00 2001 From: Window Maker Date: Sun, 24 May 2026 11:13:11 +0200 Subject: [PATCH] wings: route wtextfield XInternAtom through W_NativeInternAtom MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Last X11 symbol leak in shared WINGs code: wtextfield.c's selection request handler called XInternAtom directly to look up TEXT, COMPOUND_TEXT, and TARGETS atoms. Replaced with W_NativeInternAtom(scr, name) — implemented in widgets_x11.c as a thin XInternAtom wrapper. The Wayland-only build (future) will provide a stub that returns WM_NATIVE_NONE, making the requestHandler's downstream comparisons all fall through to 'no match' cleanly. Architectural verification: every WINGs shared object file (i.e. not *_x11.o, not *_wl.o) now has ZERO undefined X11 symbols: $ for f in WINGs/.libs/*.o; do case $f in *_x11.o|*_wl.o) continue;; esac nm $f | awk '$1=="U" {print $2}' | grep -c '^X[A-Z][a-z]' done | sort -u 0 Combined with the *_wl.c files already verified to have zero X11 deps, the WINGs library now cleanly partitions: shared code is backend-neutral, X11 backend code lives in *_x11.c, Wayland backend code lives in *_wl.c. A --disable-x11-backend configure option can now be added that drops *_x11.c from the build for pure-Wayland WINGs apps. --- WINGs/WINGs/WINGsP.h.in | 9 +++++++++ WINGs/widgets_x11.c | 13 +++++++++++++ WINGs/wtextfield.c | 8 ++++---- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/WINGs/WINGs/WINGsP.h.in b/WINGs/WINGs/WINGsP.h.in index de19a63..51ce826 100644 --- a/WINGs/WINGs/WINGsP.h.in +++ b/WINGs/WINGs/WINGsP.h.in @@ -748,6 +748,15 @@ void W_InitIM(WMScreen *scr); WMScreen *W_X11OpenDisplay(const char *display); void W_X11PlatformInit(W_Screen *scrPtr); +/* + * W_NativeInternAtom — wraps XInternAtom for the X11 backend so that + * shared code (e.g. wtextfield.c selection request handler) can intern + * an atom by name without including or directly calling + * XInternAtom. Returns WM_NATIVE_NONE in pure-Wayland builds (handled + * by a future widgets_wl.c stub). + */ +WMNativeAtom W_NativeInternAtom(W_Screen *scr, const char *name); + /* * XLFD → FcPattern parser, defined in wfont.c. Replaces XftXlfdParse * so the shared font code doesn't pull libXft / libX11. Used by diff --git a/WINGs/widgets_x11.c b/WINGs/widgets_x11.c index 81e3a8f..f944714 100644 --- a/WINGs/widgets_x11.c +++ b/WINGs/widgets_x11.c @@ -229,3 +229,16 @@ WMScreen *W_X11OpenDisplay(const char *display) } return WMCreateSimpleApplicationScreen(dpy); } + +/* + * W_NativeInternAtom — atom-intern wrapper used by shared code that + * needs an Atom value at run-time (e.g. wtextfield.c's selection + * request handler). In X11 mode delegates to XInternAtom. In Wayland + * mode the stub in widgets_wl.c returns WM_NATIVE_NONE so the calling + * code falls into a "no match" branch and selection no-ops. Either + * way the shared file does not directly link against XInternAtom. + */ +WMNativeAtom W_NativeInternAtom(W_Screen *scr, const char *name) +{ + return XInternAtom(scr->display, name, False); +} diff --git a/WINGs/wtextfield.c b/WINGs/wtextfield.c index 8b947a9..59d8a99 100644 --- a/WINGs/wtextfield.c +++ b/WINGs/wtextfield.c @@ -238,10 +238,10 @@ static WMData *requestHandler(WMView * view, WMNativeAtom selection, WMNativeAto { TextField *tPtr = view->self; int count; - Display *dpy = tPtr->view->screen->display; + WMScreen *scr = tPtr->view->screen; WMNativeAtom _TARGETS; - WMNativeAtom TEXT = XInternAtom(dpy, "TEXT", False); - WMNativeAtom COMPOUND_TEXT = XInternAtom(dpy, "COMPOUND_TEXT", False); + WMNativeAtom TEXT = W_NativeInternAtom(scr, "TEXT"); + WMNativeAtom COMPOUND_TEXT = W_NativeInternAtom(scr, "COMPOUND_TEXT"); WMData *data; /* Parameter not used, but tell the compiler that it is ok */ @@ -260,7 +260,7 @@ static WMData *requestHandler(WMView * view, WMNativeAtom selection, WMNativeAto return data; } - _TARGETS = XInternAtom(dpy, "TARGETS", False); + _TARGETS = W_NativeInternAtom(scr, "TARGETS"); if (target == _TARGETS) { WMNativeAtom supported_type[4];