Wayland-only build: guard X11 backend in Makefile.am, add wm_backend.c, WINGs _wl.c stubs

This commit is contained in:
Window Maker 2026-06-04 08:07:21 +02:00
parent cfa1e4aad7
commit 8c1cbfaca8
9 changed files with 108 additions and 96 deletions

View File

@ -99,7 +99,7 @@ else
# 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 += wappresource_wl.c wcolorpanel_wl.c wstubs_no_x11.c
libWINGs_la_SOURCES += wappresource_wl.c wballoon_wl.c wcolorpanel_wl.c wstubs_no_x11.c
endif
if USE_WAYLAND_CLIENT

View File

@ -1,100 +1,37 @@
/*
* wballoon_wl.c -- Wayland backend for tooltip balloon windows.
*
* Tooltip balloon rendering is delegated to the backend's scene graph.
* This module manages balloon state (text, font, colors, timing) and
* triggers redraws through the event system. The actual pixel rendering
* happens in the backend's frame painting path.
* Balloon rendering is delegated to the backend's scene graph and
* frame painting path. This module provides the WINGs API stubs
* needed by the core WM when running on Wayland.
*/
#include "WINGsP.h"
#include <string.h>
/*
* W_BalloonShowText -- called by the core WM to display a balloon.
* In Wayland mode the backend draws balloon text onto its own surfaces;
* this is a no-op here since the backend reads balloon state directly
* from the WMScreen and W_View structures.
*/
struct W_Balloon *
W_CreateBalloon(WMScreen *scr)
{
(void)scr;
return NULL;
}
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;
}
void
WMSetBalloonTextAlignment(WMScreen *scr, WMAlignment alignment)
{
scr->balloonTextAlignment = alignment;
}
void
WMSetBalloonTextForView(const char *text, WMView *view)
{
if (!view)
return;
/* Store the balloon text — the backend reads it during frame paint */
if (view->balloonText)
wfree(view->balloonText);
view->balloonText = text ? wstrdup(text) : NULL;
}
void
WMSetBalloonFont(WMScreen *scr, WMFont *font)
{
scr->balloon_font = font;
}
void
WMSetBalloonTextColor(WMScreen *scr, WMColor *color)
{
scr->balloonTextColor = color;
}
void
WMSetBalloonDelay(WMScreen *scr, int delay)
{
scr->balloonDelay = delay;
}
void
WMSetBalloonEnabled(WMScreen *scr, Bool flag)
{
scr->balloonEnabled = flag;
}
void
W_BalloonHandleLeaveView(WMView *view)
{
if (!view || !view->balloonTimer)
return;
WTimerDestroy(view->balloonTimer);
view->balloonTimer = NULL;
(void)view;
}
void
W_BalloonHandleEnterView(WMView *view)
{
if (!view || !view->screen->balloonEnabled || !view->balloonText || !view->balloonText[0])
return;
/* In Wayland mode, the backend handles balloon show/hide timing */
}
void
WMSetBalloonBackColor(WMScreen *scr, WMColor *color)
{
scr->balloonBackColor = color;
}
Bool
WMGetBalloonTextExtents(WMScreen *scr, const char *text, int *width, int *height)
{
if (!scr || !text || !scr->balloon_font)
return False;
*width = WMWidthOfString(scr->balloon_font, text, strlen(text)) + 10;
*height = WMFontHeight(scr->balloon_font) + 6;
return True;
(void)view;
}
void
@ -102,3 +39,52 @@ W_BalloonCleanup(WMScreen *scr)
{
(void)scr;
}
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
WMSetBalloonBackColor(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;
}

View File

@ -126,22 +126,15 @@ void W_SetPreeditPositon(W_View *view, int x, int 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) */
@ -187,3 +180,12 @@ WMScreen *WMCreateSimpleApplicationScreen(Display *display)
"WMCreateSimpleApplicationScreen unavailable"));
return NULL;
}
const char *WMSelectionOwnerDidChangeNotification = "WMSelectionOwnerDidChangeNotification";
#include "WINGsP.h"
GC WMColorGC(WMColor *color)
{
(void)color;
return NULL;
}

View File

@ -106,6 +106,10 @@ wmaker_SOURCES = \
xutil.h \
backend/backend.h \
backend/backend_types.h \
backend/wm_backend.c
if USE_X11_BACKEND
wmaker_SOURCES += \
backend/x11/x11_compat.h \
backend/x11/x11_backend.h \
backend/x11/x11_backend.c \
@ -118,7 +122,10 @@ wmaker_SOURCES = \
backend/x11/wmspec.h \
backend/x11/wmspec.c \
backend/x11/xdnd.h \
backend/x11/xdnd.c \
backend/x11/xdnd.c
endif
wmaker_SOURCES += \
geom.h \
geom.c \
wconfig.h \

View File

@ -26,7 +26,11 @@ struct wl_frame_buf *frame_buf_find(WNativeWindow id);
extern void *W_RegisterBacking(unsigned long id, void *img);
extern void W_UnregisterBacking(unsigned long id);
struct wl_toplevel_view *wl_find_view_by_id(WNativeWindow id);
#ifdef USE_X11_BACKEND
pixman_image_t *get_window_image_from_x11(Display *x_display, WNativeWindow win);
#else
pixman_image_t *get_window_image_from_x11(Display *x_display, WNativeWindow win) { (void)x_display; (void)win; return NULL; }
#endif
Bool

10
src/backend/wm_backend.c Normal file
View File

@ -0,0 +1,10 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "backend/backend.h"
/* wm_backend is defined here so it exists even without the X11 backend.
* startup.c sets it to the appropriate backend before any vtable calls. */
#ifndef USE_X11_BACKEND
const WMBackend *wm_backend = NULL;
#endif

View File

@ -782,7 +782,11 @@ static int real_main(int argc, char **argv)
wm_backend = &wl_backend;
else
#endif
#ifdef USE_X11_BACKEND
wm_backend = &x11_backend;
#else
wm_backend = &wl_backend;
#endif
/* open display */
dpy = (Display *)wm_backend->display_open(DisplayName);

View File

@ -57,9 +57,7 @@
* The `@!USE_X11_WRASTER@`-prefixed lines below are kept by
* script/replace-ac-keywords.sh ONLY when USE_X11_WRASTER is NOT
* defined in config.h. */
@!USE_X11_WRASTER@#ifndef WRASTER_NO_XLIB
@!USE_X11_WRASTER@#define WRASTER_NO_XLIB
@!USE_X11_WRASTER@#endif
/* X11 types are used throughout the wraster public API for the X11
* conversion path (RConvertImage, RPutXImage, RCreateContext, etc.).

View File

@ -155,3 +155,4 @@ RImage *RLoadXPM(RContext *context, const char *file)
RErrorCode = RERR_BADFORMAT;
return NULL;
}
void r_destroy_conversion_tables(void) { }