X11Systray.Show() now takes the icon background color as second optional argument.

[GB.DESKTOP.X11]
* NEW: X11Systray.Show() now takes the icon background color as second optional argument. The default color is black.
This commit is contained in:
gambas 2020-05-12 09:43:47 +02:00
parent fc79447baa
commit 78a969ea0c
5 changed files with 21 additions and 9 deletions

View file

@ -47,10 +47,10 @@ void SYSTRAY_raise_arrange(void)
//---------------------------------------------------------------------------
BEGIN_METHOD(X11Systray_Show, GB_INTEGER window)
BEGIN_METHOD(X11Systray_Show, GB_INTEGER window; GB_INTEGER background)
X11_init();
SYSTRAY_init(X11_display, VARG(window));
SYSTRAY_init(X11_display, VARG(window), VARGOPT(background, 0));
END_METHOD
@ -178,7 +178,7 @@ GB_DESC X11SystrayDesc[] =
{
GB_DECLARE_VIRTUAL("X11Systray"),
GB_STATIC_METHOD("Show", NULL, X11Systray_Show, "(Window)i"),
GB_STATIC_METHOD("Show", NULL, X11Systray_Show, "(Window)i[(Background)i]"),
GB_STATIC_PROPERTY_READ("Count", "i", X11Systray_Count),
GB_STATIC_METHOD("_get", "X11SystrayIcon", X11Systray_get, "(Index)i"),
GB_STATIC_METHOD("Refresh", NULL, X11Systray_Refresh, NULL),

View file

@ -65,8 +65,6 @@ int embedder_embed(struct TrayIcon *ti)
{
int rc;
//XSetWindowAttributes xswa;
/* If the icon is being embedded as hidden,
* we just start listening for property changes
* to track _XEMBED mapped state */
@ -93,6 +91,8 @@ int embedder_embed(struct TrayIcon *ti)
//xswa.win_gravity = settings.bit_gravity;
//XChangeWindowAttributes(tray_data.dpy, ti->mid_parent, CWWinGravity, &xswa);
XSetWindowBackground(tray_data.dpy, ti->wid, tray_data.bg);
//XSetWindowBackgroundPixmap(tray_data.dpy, ti->mid_parent, ParentRelative);
//if (!x11_ok() || ti->mid_parent == None) RETURN_STATUS(FAILURE);
@ -111,7 +111,8 @@ int embedder_embed(struct TrayIcon *ti)
break;
}
XSetWindowBackgroundPixmap(tray_data.dpy, ti->wid, ParentRelative);
//XSetWindowBackgroundPixmap(tray_data.dpy, ti->wid, ParentRelative);
/* 4. Show mid-parent */
//XMapWindow(tray_data.dpy, ti->mid_parent);

View file

@ -773,7 +773,7 @@ int SYSTRAY_event_filter(XEvent *e)
destroy_notify(ev.xdestroywindow);
break;
case ClientMessage:
LOG_TRACE(("ClientMessage(from 0x%x?)\n", ev.xclient.window));
PRINT_LOG(("ClientMessage(from 0x%x?)\n", ev.xclient.window));
if (client_message(ev.xclient))
return 1;
break;
@ -896,8 +896,10 @@ int remote_main(int argc, char **argv)
#endif
/* main() */
void SYSTRAY_init(Display *display, Window window)
void SYSTRAY_init(Display *display, Window window, uint bg)
{
XWindowAttributes xwa;
XColor color;
/* Read settings */
tray_init();
@ -921,6 +923,14 @@ void SYSTRAY_init(Display *display, Window window)
else
LOG_TRACE(("Opened dpy %p\n", tray_data.dpy));*/
tray_data.dpy = display;
color.red = ((bg >> 16) & 0xFF) << 8;
color.green = ((bg >> 8) & 0xFF) << 8;
color.blue = (bg & 0xFF) << 8;
XGetWindowAttributes(tray_data.dpy, window, &xwa);
XAllocColor(display, DefaultColormapOfScreen(xwa.screen), &color);
tray_data.bg = color.pixel;
#ifdef ENABLE_GRACEFUL_EXIT_HACK
if ((async_dpy = XOpenDisplay(settings.display_str)) == NULL)

View file

@ -35,7 +35,7 @@ typedef
//#define DEBUG
void SYSTRAY_init(Display *display, Window window);
void SYSTRAY_init(Display *display, Window window, uint bg);
void SYSTRAY_exit();
int SYSTRAY_event_filter(XEvent *ev);
int SYSTRAY_get_count();

View file

@ -79,6 +79,7 @@ struct TrayData {
Window tray; /* ID of tray window */
Window hint_win; /* ID of icon window */
Display *dpy; /* Display pointer */
unsigned long bg; // background color
XSizeHints xsh; /* Size & position of the tray window */
XSizeHints root_wnd; /* Size & position :) of the root window */
Window old_selection_owner; /* Old owner of tray selection */