WINGs: add wappresource_wl.c, wballoon_wl.c + fix wcolorpanel_wl.c for Wayland-only builds

This commit is contained in:
Window Maker 2026-06-02 22:44:10 +02:00
parent 29aeffd6ac
commit cfa1e4aad7
5 changed files with 206 additions and 23 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 += wcolorpanel_wl.c wstubs_no_x11.c
libWINGs_la_SOURCES += wappresource_wl.c wcolorpanel_wl.c wstubs_no_x11.c
endif
if USE_WAYLAND_CLIENT

100
WINGs/wappresource_wl.c Normal file
View File

@ -0,0 +1,100 @@
/*
* wappresource_wl.c -- Wayland backend for application icon resources.
*
* Stores application icon data (RImage, WMPixmap) without X11 WM hints.
* The backend handles its own icon surface rendering through wlroots;
* this module provides the WINGs API entry points for the core WM.
*/
#include "WINGsP.h"
#include "GNUstep.h"
void
WMSetApplicationIconWindow(WMScreen *scr, WNativeWindow window)
{
scr->applicationIconWindow = window;
}
void
WMSetApplicationIconImage(WMScreen *scr, RImage *image)
{
WMPixmap *icon;
if (scr->applicationIconImage == image)
return;
if (scr->applicationIconImage)
RReleaseImage(scr->applicationIconImage);
scr->applicationIconImage = RRetainImage(image);
if (image != NULL && (icon = WMCreatePixmapFromRImage(scr, image, 128)) != NULL) {
WMSetApplicationIconPixmap(scr, icon);
WMReleasePixmap(icon);
}
}
RImage *
WMGetApplicationIconImage(WMScreen *scr)
{
return scr->applicationIconImage;
}
void
WMSetApplicationIconPixmap(WMScreen *scr, WMPixmap *icon)
{
if (scr->applicationIconPixmap == icon)
return;
if (scr->applicationIconPixmap)
WMReleasePixmap(scr->applicationIconPixmap);
scr->applicationIconPixmap = WMRetainPixmap(icon);
/* Wayland backend reads scr->applicationIconPixmap directly */
}
WMPixmap *
WMGetApplicationIconPixmap(WMScreen *scr)
{
return scr->applicationIconPixmap;
}
WMPixmap *
WMCreateApplicationIconBlendedPixmap(WMScreen *scr, const RColor *color)
{
WMPixmap *pix;
if (scr->applicationIconImage) {
static const RColor gray = {
.red = 0xAE,
.green = 0xAA,
.blue = 0xAE,
.alpha = 0xFF
};
if (!color)
color = &gray;
pix = WMCreateBlendedPixmapFromRImage(scr, scr->applicationIconImage, color);
} else {
pix = NULL;
}
return pix;
}
void
WMSetApplicationHasAppIcon(WMScreen *scr, Bool flag)
{
scr->aflags.hasAppIcon = (flag != 0) ? 1 : 0;
}
void
W_InitApplication(WMScreen *scr)
{
/* No X11 group leader window needed in Wayland mode.
* The backend manages application identity through
* wlr_foreign_toplevel_handle_v1_set_app_id. */
scr->groupLeader = WNATIVE_NONE;
}

104
WINGs/wballoon_wl.c Normal file
View File

@ -0,0 +1,104 @@
/*
* 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.
*/
#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.
*/
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
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
W_BalloonCleanup(WMScreen *scr)
{
(void)scr;
}

View File

@ -9,7 +9,7 @@
#include "WINGsP.h"
#include "wcolorpanelP.h"
void W_ColorPanelMagnify(struct WMWidget *w, void *data)
void W_ColorPanelMagnify(WMWidget *w, void *data)
{
struct W_ColorPanel *panel = (struct W_ColorPanel *)data;
(void)w;

View File

@ -147,31 +147,10 @@ void W_BalloonShowText(void *bPtr, int x, int y, int w, int h, const char *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) */
/* ------------------------------------------------------------------ */