windowmaker-wl/WINGs/wballoon_wl.c

105 lines
2.4 KiB
C

/*
* 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;
}