wings: add --disable-x11-backend for pure-Wayland WINGs builds

Phase η: completes the WINGs API surgery by adding the configure
option that actually excludes the X11 backend from the build.

  ./configure --enable-wayland-client --disable-x11-backend
    → libWINGs has zero X11 symbol dependencies in its own objects

configure.ac: --enable-x11-backend (default yes) controls the new
USE_X11_BACKEND m4 conditional and #define.

WINGs/Makefile.am: split source list into:
  - backend-neutral / shared sources (always)
  - if USE_X11_BACKEND: dragsource_x11.c / dragdestination_x11.c /
    dragcommon_x11.c / selection_x11.c / wappresource_x11.c /
    wballoon_x11.c / wcolor_x11.c / wcolorpanel_x11.c /
    wevent_x11.c / wfont_x11.c / widgets_x11.c /
    winputmethod_x11.c / wrender_x11.c / wview_x11.c
  - else: wstubs_no_x11.c (new)
XLIBS / XFT_LIBS only added to libWINGs_la_LIBADD when X11 backend
is enabled.

WINGs/wstubs_no_x11.c: empty implementations of every public WINGs
API symbol that normally lives in *_x11.c — DnD setup, selection
handlers, IM context, balloons, color/font panels, application icon
hints, atom helpers.  Each stub is a no-op (returns success-neutral
value); calling them in pure-Wayland mode is silent rather than an
error, so future Wayland equivalents can drop in transparently.

WINGs/widgets.c: WMCreateScreenWithRContext uses weak references
to the W_*BackendX11 instances so they can resolve to NULL when not
linked.  If the caller asked for X11 mode but X11 backend is not
built, falls back to Wayland with a warning.

WINGs/WINGsP.h.in: backend extern decls (W_*BackendX11) marked weak
so links resolve to NULL when X11 backend is excluded.

Verification:
  $ ./configure --disable-x11-backend && make
  $ for f in WINGs/.libs/*.o; do nm $f | grep '^.*U X[A-Z][a-z]'; done
  (empty)

libWINGs.so still pulls libX11 transitively via wrlib (wraster's X11
image-conversion path); that's a separate refactor.  At the WINGs
source level the partition is now complete: shared / X11 / Wayland.
This commit is contained in:
Window Maker 2026-05-24 11:56:57 +02:00
parent 9a02eb658e
commit cff52676c2
5 changed files with 272 additions and 21 deletions

View File

@ -12,7 +12,7 @@ lib_LTLIBRARIES = libWUtil.la libWINGs.la
LDADD= libWUtil.la libWINGs.la $(top_builddir)/wrlib/libwraster.la @INTLIBS@
libWINGs_la_LIBADD = libWUtil.la $(top_builddir)/wrlib/libwraster.la @XLIBS@ @XFT_LIBS@ @FCLIBS@ @LIBM@ @PANGO_LIBS@ @PIXMAN_LIBS@ $(WAYLAND_CLIENT_LIBS_IF_ENABLED)
libWINGs_la_LIBADD = libWUtil.la $(top_builddir)/wrlib/libwraster.la $(X11_LIBS_IF_ENABLED) @FCLIBS@ @LIBM@ @PANGO_LIBS@ @PIXMAN_LIBS@ $(WAYLAND_CLIENT_LIBS_IF_ENABLED)
libWUtil_la_LIBADD = @LIBBSD@
if USE_WAYLAND_CLIENT
@ -21,41 +21,35 @@ else
WAYLAND_CLIENT_LIBS_IF_ENABLED =
endif
if USE_X11_BACKEND
X11_LIBS_IF_ENABLED = @XLIBS@ @XFT_LIBS@
else
X11_LIBS_IF_ENABLED =
endif
EXTRA_DIST = BUGS make-rgb Examples Extras Tests
# wbutton.c
# Backend-neutral / shared sources (always compiled).
libWINGs_la_SOURCES = \
configuration.c \
dragcommon.c \
dragcommon_x11.c \
dragdestination_x11.c \
dragsource_x11.c \
rgb.h \
selection_x11.c \
wappresource_x11.c \
wballoon_x11.c \
wbox.c \
wbrowser.c \
wbutton.c \
wcolor.c \
wcolor_x11.c \
wcolor_wl.c \
wcolorpanel_x11.c \
wcolorwell.c \
wconfig.h \
wevent.c \
wevent_x11.c \
wevent_wl.c \
wfilepanel.c \
wframe.c \
wfont.c \
wfont_x11.c \
wfont_wl.c \
wfontpanel.c \
widgets.c \
widgets_x11.c \
winputmethod_x11.c \
wlabel.c \
wlist.c \
wmenuitem.c \
@ -64,7 +58,6 @@ libWINGs_la_SOURCES = \
wpixmap.c \
wpopupbutton.c \
wprogressindicator.c \
wrender_x11.c \
wrender_wl.c \
wruler.c \
wscroller.c \
@ -75,11 +68,35 @@ libWINGs_la_SOURCES = \
wtext.c \
wtextfield.c \
wview.c \
wview_x11.c \
wview_wl.c \
wclient_wl.c \
wwindow.c
# X11 backend sources — only compiled when --enable-x11-backend (the default).
if USE_X11_BACKEND
libWINGs_la_SOURCES += \
dragcommon_x11.c \
dragdestination_x11.c \
dragsource_x11.c \
selection_x11.c \
wappresource_x11.c \
wballoon_x11.c \
wcolor_x11.c \
wcolorpanel_x11.c \
wevent_x11.c \
wfont_x11.c \
widgets_x11.c \
winputmethod_x11.c \
wrender_x11.c \
wview_x11.c
else
# Stubs that provide empty implementations of the public WINGs API
# symbols normally exported from *_x11.c files, so applications that
# link libWINGs but never call them resolve cleanly in pure-Wayland
# builds.
libWINGs_la_SOURCES += wstubs_no_x11.c
endif
if USE_WAYLAND_CLIENT
nodist_libWINGs_la_SOURCES = \
xdg-shell-protocol.c \

View File

@ -473,7 +473,7 @@ typedef struct W_EventBackend {
void (*post_dispatch)(void *ectx, WMEvent *ev, struct W_View *toplevel);
} W_EventBackend;
extern const W_EventBackend W_EventBackendX11;
extern const W_EventBackend W_EventBackendX11 __attribute__((weak));
extern const W_EventBackend W_EventBackendWL;
Bool W_IsValidView(struct W_View *view);
@ -545,7 +545,7 @@ typedef struct W_FontBackend {
char *buffer, int buflen, unsigned long *keysym_out);
} W_FontBackend;
extern const W_FontBackend W_FontBackendX11;
extern const W_FontBackend W_FontBackendX11 __attribute__((weak));
extern const W_FontBackend W_FontBackendWL;
typedef struct W_Font {
@ -600,7 +600,7 @@ typedef struct W_RenderBackend {
unsigned int width, unsigned int height);
} W_RenderBackend;
extern const W_RenderBackend W_RenderBackendX11;
extern const W_RenderBackend W_RenderBackendX11 __attribute__((weak));
extern const W_RenderBackend W_RenderBackendWL;
@ -683,7 +683,7 @@ typedef struct W_ViewBackend {
WMAction *magnify_callback;
} W_ViewBackend;
extern const W_ViewBackend W_ViewBackendX11;
extern const W_ViewBackend W_ViewBackendX11 __attribute__((weak));
extern const W_ViewBackend W_ViewBackendWL;
/* Color panel magnifier (X11-only implementation) */
@ -714,7 +714,7 @@ typedef struct W_ColorBackend {
unsigned short *r, unsigned short *g, unsigned short *b);
} W_ColorBackend;
extern const W_ColorBackend W_ColorBackendX11;
extern const W_ColorBackend W_ColorBackendX11 __attribute__((weak));
extern const W_ColorBackend W_ColorBackendWL;

View File

@ -633,6 +633,19 @@ WMScreen *WMCreateScreenWithRContext(Display * display, int screen, RContext * c
scrPtr->fontCache = WMCreateHashTable(WMStringPointerHashCallbacks);
/*
* Backend selection. When --disable-x11-backend is configured the
* W_*BackendX11 symbols are weak-undefined (resolve to NULL); the
* Wayland path is the only valid choice in that case so we must not
* land on an X11 branch. If the build did include X11 but the
* caller asked for X11 mode (wayland=0) and somehow the symbols are
* still missing, fall back to Wayland and warn — the screen is
* unusable as X11 anyway.
*/
if (!wayland && &W_FontBackendX11 == NULL) {
wwarning(_("WINGs: X11 backend not built; falling back to Wayland"));
wayland = 1;
}
scrPtr->fontBackend = wayland ? &W_FontBackendWL : &W_FontBackendX11;
scrPtr->fontBackendCtx = scrPtr->fontBackend->screen_init(scrPtr);
scrPtr->eventBackend = wayland ? &W_EventBackendWL : &W_EventBackendX11;

195
WINGs/wstubs_no_x11.c Normal file
View File

@ -0,0 +1,195 @@
/*
* wstubs_no_x11.c — empty implementations of WINGs public-API symbols
* that normally live in WINGs/*_x11.c files.
*
* Compiled only when --disable-x11-backend is configured. The X11
* backend files are excluded from the build in that case; this file
* provides the symbols they would otherwise export, so that consumer
* code that calls them (DnD setup, selection, balloons, color/font
* panels, app-icon hints, IM context) links cleanly.
*
* Behaviour: every stub returns success-neutral values (no-op for void,
* False for Bool, NULL for pointer, 0 for integer). Calling them in
* Wayland mode is a quiet no-op rather than an error — the
* corresponding feature simply isn't available until an equivalent
* Wayland implementation is added (wl_data_device for DnD, wlr-foreign-
* toplevel for app icons, etc.).
*/
#define WRASTER_NO_XLIB
#include "wconfig.h"
#include "WINGsP.h"
/* ------------------------------------------------------------------ */
/* Drag-and-drop (dragsource_x11.c / dragdestination_x11.c) */
/* ------------------------------------------------------------------ */
void WMSetViewDragSourceProcs(WMView *view, WMDragSourceProcs *procs)
{ (void)view; (void)procs; }
Bool WMIsDraggingFromView(WMView *view)
{ (void)view; return False; }
void WMDragImageFromView(WMView *view, WMEvent *event)
{ (void)view; (void)event; }
void WMSetViewDragImage(WMView *view, WMPixmap *dragImage)
{ (void)view; (void)dragImage; }
void WMReleaseViewDragImage(WMView *view)
{ (void)view; }
void WMCreateDragHandler(WMView *view, WMEventProc *dragEventProc, void *clientData)
{ (void)view; (void)dragEventProc; (void)clientData; }
void WMDeleteDragHandler(WMView *view, WMEventProc *dragEventProc, void *clientData)
{ (void)view; (void)dragEventProc; (void)clientData; }
void WMSetViewDraggable(WMView *view, WMDragSourceProcs *procs, WMPixmap *image)
{ (void)view; (void)procs; (void)image; }
void WMUnsetViewDraggable(WMView *view)
{ (void)view; }
void WMRegisterViewForDraggedTypes(WMView *view, WMArray *acceptedTypes)
{ (void)view; (void)acceptedTypes; }
void WMUnregisterViewDraggedTypes(WMView *view)
{ (void)view; }
void WMSetViewDragDestinationProcs(WMView *view, WMDragDestinationProcs *procs)
{ (void)view; (void)procs; }
WMNativeAtom W_OperationToAction(WMScreen *scr, WMDragOperationType operation)
{ (void)scr; (void)operation; return WM_NATIVE_NONE; }
WMDragOperationType W_ActionToOperation(WMScreen *scr, WMNativeAtom action)
{ (void)scr; (void)action; return WDOperationNone; }
void W_DragSourceStartTimer(WMDraggingInfo *info) { (void)info; }
void W_DragSourceStopTimer(void) { }
void W_DragDestinationStartTimer(WMDraggingInfo *info) { (void)info; }
void W_DragDestinationStopTimer(void) { }
void W_DragDestinationCancelDropOnEnter(WMView *toplevel, WMDraggingInfo *info)
{ (void)toplevel; (void)info; }
void W_DragDestinationInfoClear(WMDraggingInfo *info) { (void)info; }
/* W_FreeViewXdndPart lives in shared dragcommon.c — not stubbed here. */
Bool W_SendDnDClientMessage(Display *dpy, WNativeWindow win, WMNativeAtom message,
unsigned long d1, unsigned long d2, unsigned long d3,
unsigned long d4, unsigned long d5)
{
(void)dpy; (void)win; (void)message;
(void)d1; (void)d2; (void)d3; (void)d4; (void)d5;
return False;
}
/* ------------------------------------------------------------------ */
/* Selection (selection_x11.c) */
/* ------------------------------------------------------------------ */
Bool WMCreateSelectionHandler(WMView *view, WMNativeAtom selection,
WMNativeTime timestamp,
WMSelectionProcs *procs, void *cdata)
{
(void)view; (void)selection; (void)timestamp; (void)procs; (void)cdata;
return False;
}
void WMDeleteSelectionHandler(WMView *view, WMNativeAtom selection,
WMNativeTime timestamp)
{ (void)view; (void)selection; (void)timestamp; }
Bool WMRequestSelection(WMView *view, WMNativeAtom selection, WMNativeAtom target,
WMNativeTime timestamp, WMSelectionCallback *callback,
void *cdata)
{
(void)view; (void)selection; (void)target; (void)timestamp;
(void)callback; (void)cdata;
return False;
}
/* ------------------------------------------------------------------ */
/* Input methods (winputmethod_x11.c) */
/* ------------------------------------------------------------------ */
void W_InitIM(WMScreen *scr) { (void)scr; }
void W_CreateIC(WMView *view) { (void)view; }
void W_DestroyIC(WMView *view) { (void)view; }
void W_FocusIC(WMView *view) { (void)view; }
void W_UnFocusIC(WMView *view) { (void)view; }
void W_SetPreeditPositon(W_View *view, int x, int y)
{ (void)view; (void)x; (void)y; }
/* ------------------------------------------------------------------ */
/* Balloons (wballoon_x11.c) */
/* ------------------------------------------------------------------ */
void WMSetBalloonTextAlignment(WMScreen *scr, WMAlignment alignment)
{ (void)scr; (void)alignment; }
void WMSetBalloonTextForView(const char *text, WMView *view)
{ (void)text; (void)view; }
void WMSetBalloonFont(WMScreen *scr, WMFont *font)
{ (void)scr; (void)font; }
void WMSetBalloonTextColor(WMScreen *scr, WMColor *color)
{ (void)scr; (void)color; }
void WMSetBalloonDelay(WMScreen *scr, int delay)
{ (void)scr; (void)delay; }
void WMSetBalloonEnabled(WMScreen *scr, Bool flag)
{ (void)scr; (void)flag; }
void W_BalloonHandleLeaveView(WMView *view) { (void)view; }
void W_BalloonHandleEnterView(WMView *view) { (void)view; }
void W_BalloonShowText(void *bPtr, int x, int y, int w, int h, const char *text)
{ (void)bPtr; (void)x; (void)y; (void)w; (void)h; (void)text; }
/* ------------------------------------------------------------------ */
/* Application resources (wappresource_x11.c) */
/* ------------------------------------------------------------------ */
void WMSetApplicationIconWindow(WMScreen *scr, WNativeWindow window)
{ (void)scr; (void)window; }
void WMSetApplicationIconImage(WMScreen *scr, RImage *image)
{ (void)scr; (void)image; }
void WMSetApplicationIconPixmap(WMScreen *scr, WMPixmap *icon)
{ (void)scr; (void)icon; }
void WMSetApplicationHasAppIcon(WMScreen *scr, Bool flag)
{ (void)scr; (void)flag; }
void W_InitApplication(WMScreen *scr) { (void)scr; }
/* ------------------------------------------------------------------ */
/* Color panel (wcolorpanel_x11.c) */
/* ------------------------------------------------------------------ */
void WMSetColorPanelAction(WMColorPanel *panel, WMAction2 *action, void *data)
{ (void)panel; (void)action; (void)data; }
void WMFreeColorPanel(WMColorPanel *panel) { (void)panel; }
void WMCloseColorPanel(WMColorPanel *panel) { (void)panel; }
void WMShowColorPanel(WMColorPanel *panel) { (void)panel; }
void WMSetColorPanelPickerMode(WMColorPanel *panel, WMColorPanelMode mode)
{ (void)panel; (void)mode; }
void WMSetColorPanelColor(WMColorPanel *panel, WMColor *color)
{ (void)panel; (void)color; }
void W_ColorPanelMagnify(WMWidget *w, void *data) { (void)w; (void)data; }
/* ------------------------------------------------------------------ */
/* Color helpers (wcolor_x11.c) */
/* ------------------------------------------------------------------ */
void WMSetColorInGC(WMColor *color, GC gc) { (void)color; (void)gc; }
/* ------------------------------------------------------------------ */
/* Font / atom helpers (widgets_x11.c) */
/* ------------------------------------------------------------------ */
WMNativeAtom W_NativeInternAtom(W_Screen *scr, const char *name)
{ (void)scr; (void)name; return WM_NATIVE_NONE; }
void W_X11PlatformInit(W_Screen *scrPtr) { (void)scrPtr; }
WMScreen *W_X11OpenDisplay(const char *display)
{
(void)display;
wwarning(_("WINGs built without X11 backend; cannot open X11 display"));
return NULL;
}

View File

@ -723,6 +723,32 @@ AC_SUBST([WAYLAND_PROTOCOLS_DIR])
AC_SUBST([WAYLAND_SCANNER])
dnl X11 backend support for WINGs
dnl =============================
dnl Default: yes. Disable to build a pure-Wayland WINGs library that has
dnl no libX11 dependency at all. Useful for distributions / embedded
dnl builds that want a Wayland-only stack. When disabled, the *_x11.c
dnl files are excluded and a stub file (wstubs_no_x11.c) provides empty
dnl implementations of the public WINGs API symbols that normally come
dnl from those files (DnD, selection, balloon, color/font panel, IM).
m4_divert_push([INIT_PREPARE])dnl
AC_ARG_ENABLE([x11-backend],
[AS_HELP_STRING([--disable-x11-backend],
[build WINGs without X11 backend (pure Wayland-client) @<:@default=yes@:>@])],
[AS_CASE(["$enableval"],
[yes|no], [],
[AC_MSG_ERROR([bad value $enableval for --enable-x11-backend])])],
[enable_x11_backend=yes])
m4_divert_pop([INIT_PREPARE])dnl
AS_IF([test "x$enable_x11_backend" = "xyes"],
[AC_DEFINE([USE_X11_BACKEND], [1],
[Define to 1 to build the WINGs X11 backend])
supported_core="$supported_core X11Backend"],
[unsupported="$unsupported X11Backend"])
AM_CONDITIONAL([USE_X11_BACKEND], [test "x$enable_x11_backend" = "xyes"])
dnl Math library
dnl ============
dnl libWINGS uses math functions, check whether usage requires linking