]> Dogcows Code - chaz/tint2/blob - src/systray/systraybar.c
SIGUSR1 does now a full restat of tint2
[chaz/tint2] / src / systray / systraybar.c
1 /**************************************************************************
2 * Tint2 : systraybar
3 *
4 * Copyright (C) 2009 thierry lorthiois (lorthiois@bbsoft.fr)
5 * based on 'docker-1.5' from Ben Jansens.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License version 2
9 * as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 **************************************************************************/
19
20 #include <X11/Xlib.h>
21 #include <X11/Xutil.h>
22 #include <X11/Xatom.h>
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include <glib.h>
27 #include <Imlib2.h>
28 #include <X11/extensions/Xdamage.h>
29 #include <X11/extensions/Xcomposite.h>
30 #include <X11/extensions/Xrender.h>
31
32
33 #include "systraybar.h"
34 #include "server.h"
35 #include "panel.h"
36
37 GSList *icons;
38
39 /* defined in the systray spec */
40 #define SYSTEM_TRAY_REQUEST_DOCK 0
41 #define SYSTEM_TRAY_BEGIN_MESSAGE 1
42 #define SYSTEM_TRAY_CANCEL_MESSAGE 2
43
44 // selection window
45 Window net_sel_win = None;
46
47 // freedesktop specification doesn't allow multi systray
48 Systraybar systray;
49 int refresh_systray;
50 int systray_enabled;
51 int systray_max_icon_size;
52
53 // background pixmap if we render ourselves the icons
54 static Pixmap render_background;
55
56
57 void default_systray()
58 {
59 printf("*** default_systray()\n");
60 memset(&systray, 0, sizeof(Systraybar));
61 render_background = 0;
62 systray.alpha = 100;
63 systray.sort = 3;
64 systray.area._draw_foreground = draw_systray;
65 systray.area._resize = resize_systray;
66 }
67
68 void cleanup_systray()
69 {
70 printf("*** cleanup_systray()\n");
71 systray_enabled = 0;
72 systray_max_icon_size = 0;
73 systray.area.on_screen = 0;
74 free_area(&systray.area);
75 if (render_background) {
76 XFreePixmap(server.dsp, render_background);
77 render_background = 0;
78 }
79 }
80
81 void init_systray()
82 {
83 start_net();
84
85 if (!systray_enabled)
86 return;
87
88 if (!server.visual32 && (systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0)) {
89 printf("No 32 bit visual for your X implementation. 'systray_asb = 100 0 0' will be forced\n");
90 systray.alpha = 100;
91 systray.brightness = systray.saturation = 0;
92 }
93 systray.area.resize = 1;
94 systray.area.redraw = 1;
95 systray.area.on_screen = 1;
96 refresh_systray = 0;
97 }
98
99
100 void init_systray_panel(void *p)
101 {
102 Panel *panel =(Panel*)p;
103
104 if (panel_horizontal) {
105 systray.area.posy = panel->area.bg->border.width + panel->area.paddingy;
106 systray.area.height = panel->area.height - (2 * systray.area.posy);
107 }
108 else {
109 systray.area.posx = panel->area.bg->border.width + panel->area.paddingy;
110 systray.area.width = panel->area.width - (2 * panel->area.bg->border.width) - (2 * panel->area.paddingy);
111 }
112 systray.area.parent = p;
113 systray.area.panel = p;
114 }
115
116
117 void draw_systray(void *obj, cairo_t *c)
118 {
119 if (server.real_transparency || systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0) {
120 if (render_background) XFreePixmap(server.dsp, render_background);
121 render_background = XCreatePixmap(server.dsp, server.root_win, systray.area.width, systray.area.height, server.depth);
122 XCopyArea(server.dsp, systray.area.pix, render_background, server.gc, 0, 0, systray.area.width, systray.area.height, 0, 0);
123 }
124
125 refresh_systray = 1;
126 }
127
128
129 void resize_systray(void *obj)
130 {
131 Systraybar *sysbar = obj;
132 Panel *panel = sysbar->area.panel;
133 TrayWindow *traywin;
134 GSList *l;
135 int count, icon_size;
136 int icons_per_column=1, icons_per_row=1, marging=0;
137
138 if (panel_horizontal)
139 icon_size = sysbar->area.height;
140 else
141 icon_size = sysbar->area.width;
142 icon_size = icon_size - (2 * sysbar->area.bg->border.width) - (2 * sysbar->area.paddingy);
143 if (systray_max_icon_size > 0 && icon_size > systray_max_icon_size)
144 icon_size = systray_max_icon_size;
145 count = 0;
146 for (l = systray.list_icons; l ; l = l->next) {
147 if (!((TrayWindow*)l->data)->hide)
148 count++;
149 }
150 //printf("count %d\n", count);
151
152 if (panel_horizontal) {
153 if (!count) systray.area.width = 0;
154 else {
155 int height = sysbar->area.height - 2*sysbar->area.bg->border.width - 2*sysbar->area.paddingy;
156 // here icons_per_column always higher than 0
157 icons_per_column = (height+sysbar->area.paddingx) / (icon_size+sysbar->area.paddingx);
158 marging = height - (icons_per_column-1)*(icon_size+sysbar->area.paddingx) - icon_size;
159 icons_per_row = count / icons_per_column + (count%icons_per_column != 0);
160 systray.area.width = (2 * systray.area.bg->border.width) + (2 * systray.area.paddingxlr) + (icon_size * icons_per_row) + ((icons_per_row-1) * systray.area.paddingx);
161 }
162
163 systray.area.posx = panel->area.width - panel->area.bg->border.width - panel->area.paddingxlr - systray.area.width;
164 if (panel->clock.area.on_screen)
165 systray.area.posx -= (panel->clock.area.width + panel->area.paddingx);
166 #ifdef ENABLE_BATTERY
167 if (panel->battery.area.on_screen)
168 systray.area.posx -= (panel->battery.area.width + panel->area.paddingx);
169 #endif
170 }
171 else {
172 if (!count) systray.area.height = 0;
173 else {
174 int width = sysbar->area.width - 2*sysbar->area.bg->border.width - 2*sysbar->area.paddingy;
175 // here icons_per_row always higher than 0
176 icons_per_row = (width+sysbar->area.paddingx) / (icon_size+sysbar->area.paddingx);
177 marging = width - (icons_per_row-1)*(icon_size+sysbar->area.paddingx) - icon_size;
178 icons_per_column = count / icons_per_row+ (count%icons_per_row != 0);
179 systray.area.height = (2 * systray.area.bg->border.width) + (2 * systray.area.paddingxlr) + (icon_size * icons_per_column) + ((icons_per_column-1) * systray.area.paddingx);
180 }
181
182 systray.area.posy = panel->area.bg->border.width + panel->area.paddingxlr;
183 if (panel->clock.area.on_screen)
184 systray.area.posy += (panel->clock.area.height + panel->area.paddingx);
185 #ifdef ENABLE_BATTERY
186 if (panel->battery.area.on_screen)
187 systray.area.posy += (panel->battery.area.height + panel->area.paddingx);
188 #endif
189 }
190
191 int i, posx, posy;
192 int start = panel->area.bg->border.width + panel->area.paddingy + systray.area.bg->border.width + systray.area.paddingy +marging/2;
193 if (panel_horizontal) {
194 posy = start;
195 posx = systray.area.posx + systray.area.bg->border.width + systray.area.paddingxlr;
196 }
197 else {
198 posx = start;
199 posy = systray.area.posy + systray.area.bg->border.width + systray.area.paddingxlr;
200 }
201
202 for (i=1, l = systray.list_icons; l ; i++, l = l->next) {
203 traywin = (TrayWindow*)l->data;
204 if (traywin->hide) continue;
205
206 traywin->y = posy;
207 traywin->x = posx;
208 traywin->width = icon_size;
209 traywin->height = icon_size;
210 if (panel_horizontal) {
211 if (i % icons_per_column)
212 posy += icon_size + sysbar->area.paddingx;
213 else {
214 posy = start;
215 posx += (icon_size + systray.area.paddingx);
216 }
217 }
218 else {
219 if (i % icons_per_row)
220 posx += icon_size + systray.area.paddingx;
221 else {
222 posx = start;
223 posy += (icon_size + systray.area.paddingx);
224 }
225 }
226
227 // position and size the icon window
228 XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, icon_size, icon_size);
229 XResizeWindow(server.dsp, traywin->tray_id, icon_size, icon_size);
230 }
231 // resize force the redraw
232 systray.area.redraw = 1;
233 }
234
235
236 // ***********************************************
237 // systray protocol
238
239 void start_net()
240 {
241 if (net_sel_win) {
242 // protocol already started
243 if (!systray_enabled)
244 stop_net();
245 return;
246 }
247 else
248 if (!systray_enabled)
249 return;
250
251 Window win = XGetSelectionOwner(server.dsp, server.atom._NET_SYSTEM_TRAY_SCREEN);
252
253 // freedesktop systray specification
254 if (win != None) {
255 // search pid
256 Atom _NET_WM_PID, actual_type;
257 int actual_format;
258 unsigned long nitems;
259 unsigned long bytes_after;
260 unsigned char *prop = 0;
261 int pid;
262
263 _NET_WM_PID = XInternAtom(server.dsp, "_NET_WM_PID", True);
264 int ret = XGetWindowProperty(server.dsp, win, _NET_WM_PID, 0, 1024, False, AnyPropertyType, &actual_type, &actual_format, &nitems, &bytes_after, &prop);
265
266 fprintf(stderr, "tint2 : another systray is running");
267 if (ret == Success && prop) {
268 pid = prop[1] * 256;
269 pid += prop[0];
270 fprintf(stderr, " pid=%d", pid);
271 }
272 fprintf(stderr, "\n");
273 return;
274 }
275
276 // init systray protocol
277 net_sel_win = XCreateSimpleWindow(server.dsp, server.root_win, -1, -1, 1, 1, 0, 0, 0);
278
279 // v0.3 trayer specification. tint2 always horizontal.
280 // Vertical panel will draw the systray horizontal.
281 int orient = 0;
282 XChangeProperty(server.dsp, net_sel_win, server.atom._NET_SYSTEM_TRAY_ORIENTATION, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &orient, 1);
283 VisualID vid;
284 if (server.visual32 && (systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0))
285 vid = XVisualIDFromVisual(server.visual32);
286 else
287 vid = XVisualIDFromVisual(server.visual);
288 XChangeProperty(server.dsp, net_sel_win, XInternAtom(server.dsp, "_NET_SYSTEM_TRAY_VISUAL", False), XA_VISUALID, 32, PropModeReplace, (unsigned char*)&vid, 1);
289
290 XSetSelectionOwner(server.dsp, server.atom._NET_SYSTEM_TRAY_SCREEN, net_sel_win, CurrentTime);
291 if (XGetSelectionOwner(server.dsp, server.atom._NET_SYSTEM_TRAY_SCREEN) != net_sel_win) {
292 stop_net();
293 fprintf(stderr, "tint2 : can't get systray manager\n");
294 return;
295 }
296
297 //fprintf(stderr, "tint2 : systray started\n");
298 XClientMessageEvent ev;
299 ev.type = ClientMessage;
300 ev.window = server.root_win;
301 ev.message_type = server.atom.MANAGER;
302 ev.format = 32;
303 ev.data.l[0] = CurrentTime;
304 ev.data.l[1] = server.atom._NET_SYSTEM_TRAY_SCREEN;
305 ev.data.l[2] = net_sel_win;
306 ev.data.l[3] = 0;
307 ev.data.l[4] = 0;
308 XSendEvent(server.dsp, server.root_win, False, StructureNotifyMask, (XEvent*)&ev);
309 }
310
311
312 void stop_net()
313 {
314 //fprintf(stderr, "tint2 : systray stopped\n");
315 if (systray.list_icons) {
316 // remove_icon change systray.list_icons
317 while(systray.list_icons)
318 remove_icon((TrayWindow*)systray.list_icons->data);
319
320 g_slist_free(systray.list_icons);
321 systray.list_icons = 0;
322 }
323
324 if (net_sel_win != None) {
325 XDestroyWindow(server.dsp, net_sel_win);
326 net_sel_win = None;
327 }
328 }
329
330
331 gboolean error;
332 int window_error_handler(Display *d, XErrorEvent *e)
333 {
334 d=d;e=e;
335 error = TRUE;
336 if (e->error_code != BadWindow) {
337 printf("error_handler %d\n", e->error_code);
338 }
339 return 0;
340 }
341
342
343 static gint compare_traywindows(gconstpointer a, gconstpointer b)
344 {
345 const TrayWindow * traywin_a = (TrayWindow*)a;
346 const TrayWindow * traywin_b = (TrayWindow*)b;
347 XTextProperty name_a, name_b;
348
349 if(XGetWMName(server.dsp, traywin_a->tray_id, &name_a) == 0) {
350 return -1;
351 }
352 else if(XGetWMName(server.dsp, traywin_b->tray_id, &name_b) == 0) {
353 XFree(name_a.value);
354 return 1;
355 }
356 else {
357 gint retval = g_ascii_strncasecmp((char*)name_a.value, (char*)name_b.value, -1) * systray.sort;
358 XFree(name_a.value);
359 XFree(name_b.value);
360 return retval;
361 }
362 }
363
364
365 gboolean add_icon(Window id)
366 {
367 TrayWindow *traywin;
368 XErrorHandler old;
369 Panel *panel = systray.area.panel;
370 int hide = 0;
371
372 error = FALSE;
373 XWindowAttributes attr;
374 if ( XGetWindowAttributes(server.dsp, id, &attr) == False ) return FALSE;
375 unsigned long mask = 0;
376 XSetWindowAttributes set_attr;
377 printf("icon with depth: %d\n", attr.depth);
378 if (attr.depth != server.depth || systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0) {
379 set_attr.colormap = attr.colormap;
380 set_attr.background_pixel = 0;
381 set_attr.border_pixel = 0;
382 mask = CWColormap|CWBackPixel|CWBorderPixel;
383 }
384 else {
385 set_attr.background_pixmap = ParentRelative;
386 mask = CWBackPixmap;
387 }
388 Window parent_window;
389 parent_window = XCreateWindow(server.dsp, panel->main_win, 0, 0, 30, 30, 0, attr.depth, InputOutput, attr.visual, mask, &set_attr);
390 old = XSetErrorHandler(window_error_handler);
391 XReparentWindow(server.dsp, id, parent_window, 0, 0);
392 XSync(server.dsp, False);
393 XSetErrorHandler(old);
394 if (error != FALSE) {
395 fprintf(stderr, "tint2 : not icon_swallow\n");
396 XDestroyWindow(server.dsp, parent_window);
397 return FALSE;
398 }
399
400 {
401 Atom acttype;
402 int actfmt;
403 unsigned long nbitem, bytes;
404 unsigned char *data = 0;
405 int ret;
406
407 ret = XGetWindowProperty(server.dsp, id, server.atom._XEMBED_INFO, 0, 2, False, server.atom._XEMBED_INFO, &acttype, &actfmt, &nbitem, &bytes, &data);
408 if (ret == Success) {
409 if (data) {
410 if (nbitem == 2) {
411 //hide = ((data[1] & XEMBED_MAPPED) == 0);
412 //printf("hide %d\n", hide);
413 }
414 XFree(data);
415 }
416 }
417 else {
418 fprintf(stderr, "tint2 : xembed error\n");
419 XDestroyWindow(server.dsp, parent_window);
420 return FALSE;
421 }
422 }
423 {
424 XEvent e;
425 e.xclient.type = ClientMessage;
426 e.xclient.serial = 0;
427 e.xclient.send_event = True;
428 e.xclient.message_type = server.atom._XEMBED;
429 e.xclient.window = id;
430 e.xclient.format = 32;
431 e.xclient.data.l[0] = CurrentTime;
432 e.xclient.data.l[1] = XEMBED_EMBEDDED_NOTIFY;
433 e.xclient.data.l[2] = 0;
434 e.xclient.data.l[3] = parent_window;
435 e.xclient.data.l[4] = 0;
436 XSendEvent(server.dsp, id, False, 0xFFFFFF, &e);
437 }
438
439 printf("Adding systray with window: %d\n", id);
440 traywin = g_new0(TrayWindow, 1);
441 traywin->id = parent_window;
442 traywin->tray_id = id;
443 traywin->hide = hide;
444 traywin->depth = attr.depth;
445 traywin->damage = 0;
446
447 if (systray.sort == 3)
448 systray.list_icons = g_slist_prepend(systray.list_icons, traywin);
449 else if (systray.sort == 2)
450 systray.list_icons = g_slist_append(systray.list_icons, traywin);
451 else
452 systray.list_icons = g_slist_insert_sorted(systray.list_icons, traywin, compare_traywindows);
453 systray.area.resize = 1;
454 //printf("add_icon id %lx, %d\n", id, g_slist_length(systray.list_icons));
455
456 // watch for the icon trying to resize itself!
457 XSelectInput(server.dsp, traywin->tray_id, StructureNotifyMask);
458 if (server.real_transparency || systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0) {
459 traywin->damage = XDamageCreate(server.dsp, traywin->id, XDamageReportRawRectangles);
460 XCompositeRedirectWindow(server.dsp, traywin->id, CompositeRedirectManual);
461 }
462
463 // show the window
464 if (!traywin->hide)
465 XMapWindow(server.dsp, traywin->tray_id);
466 if (!traywin->hide && !panel->is_hidden)
467 XMapRaised(server.dsp, traywin->id);
468
469 // changed in systray force resize on panel
470 panel->area.resize = 1;
471 panel_refresh = 1;
472 return TRUE;
473 }
474
475
476 void remove_icon(TrayWindow *traywin)
477 {
478 XErrorHandler old;
479
480 printf("Removing systray with window: %d\n", traywin->tray_id);
481 // remove from our list
482 systray.list_icons = g_slist_remove(systray.list_icons, traywin);
483 systray.area.resize = 1;
484 //printf("remove_icon id %lx, %d\n", traywin->id);
485
486 XSelectInput(server.dsp, traywin->tray_id, NoEventMask);
487 if (traywin->damage)
488 XDamageDestroy(server.dsp, traywin->damage);
489
490 // reparent to root
491 error = FALSE;
492 old = XSetErrorHandler(window_error_handler);
493 if (!traywin->hide)
494 XUnmapWindow(server.dsp, traywin->tray_id);
495 XReparentWindow(server.dsp, traywin->tray_id, server.root_win, 0, 0);
496 XDestroyWindow(server.dsp, traywin->id);
497 XSync(server.dsp, False);
498 XSetErrorHandler(old);
499 if (traywin->render_timeout)
500 stop_timeout(traywin->render_timeout);
501 g_free(traywin);
502
503 // changed in systray force resize on panel
504 Panel *panel = systray.area.panel;
505 panel->area.resize = 1;
506 panel_refresh = 1;
507 }
508
509
510 void net_message(XClientMessageEvent *e)
511 {
512 unsigned long opcode;
513 Window id;
514
515 opcode = e->data.l[1];
516 switch (opcode) {
517 case SYSTEM_TRAY_REQUEST_DOCK:
518 id = e->data.l[2];
519 if (id) add_icon(id);
520 break;
521
522 case SYSTEM_TRAY_BEGIN_MESSAGE:
523 case SYSTEM_TRAY_CANCEL_MESSAGE:
524 // we don't show baloons messages.
525 break;
526
527 default:
528 if (opcode == server.atom._NET_SYSTEM_TRAY_MESSAGE_DATA)
529 printf("message from dockapp: %s\n", e->data.b);
530 else
531 fprintf(stderr, "SYSTEM_TRAY : unknown message type\n");
532 break;
533 }
534 }
535
536 void systray_render_icon_now(void* t)
537 {
538 // we end up in this function only in real transparency mode or if systray_task_asb != 100 0 0
539 // we made also sure, that we always have a 32 bit visual, i.e. we can safely create 32 bit pixmaps here
540 TrayWindow* traywin = t;
541 traywin->render_timeout = 0;
542
543 // good systray icons support 32 bit depth, but some icons are still 24 bit.
544 // We create a heuristic mask for these icons, i.e. we get the rgb value in the top left corner, and
545 // mask out all pixel with the same rgb value
546 Panel* panel = systray.area.panel;
547
548 // Very ugly hack, but somehow imlib2 is not able to get the image from the traywindow itself,
549 // so we first render the tray window onto a pixmap, and then we tell imlib2 to use this pixmap as
550 // drawable. If someone knows why it does not work with the traywindow itself, please tell me ;)
551 Pixmap tmp_pmap = XCreatePixmap(server.dsp, server.root_win, traywin->width, traywin->height, 32);
552 XRenderPictFormat* f;
553 if (traywin->depth == 24)
554 f = XRenderFindStandardFormat(server.dsp, PictStandardRGB24);
555 else if (traywin->depth == 32)
556 f = XRenderFindStandardFormat(server.dsp, PictStandardARGB32);
557 else {
558 printf("Strange tray icon found with depth: %d\n", traywin->depth);
559 return;
560 }
561 Picture pict_image;
562 if (server.real_transparency)
563 pict_image = XRenderCreatePicture(server.dsp, traywin->id, f, 0, 0);
564 else
565 pict_image = XRenderCreatePicture(server.dsp, traywin->tray_id, f, 0, 0);
566 Picture pict_drawable = XRenderCreatePicture(server.dsp, tmp_pmap, XRenderFindVisualFormat(server.dsp, server.visual32), 0, 0);
567 XRenderComposite(server.dsp, PictOpSrc, pict_image, None, pict_drawable, 0, 0, 0, 0, 0, 0, traywin->width, traywin->height);
568 XRenderFreePicture(server.dsp, pict_image);
569 XRenderFreePicture(server.dsp, pict_drawable);
570 // end of the ugly hack and we can continue as before
571
572 imlib_context_set_visual(server.visual32);
573 imlib_context_set_colormap(server.colormap32);
574 imlib_context_set_drawable(tmp_pmap);
575 Imlib_Image image = imlib_create_image_from_drawable(0, 0, 0, traywin->width, traywin->height, 1);
576 if (image == 0)
577 return;
578
579 imlib_context_set_image(image);
580 imlib_image_set_has_alpha(1);
581 DATA32* data = imlib_image_get_data();
582 if (traywin->depth == 24) {
583 createHeuristicMask(data, traywin->width, traywin->height);
584 }
585 if (systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0)
586 adjust_asb(data, traywin->width, traywin->height, systray.alpha, (float)systray.saturation/100, (float)systray.brightness/100);
587 imlib_image_put_back_data(data);
588 XCopyArea(server.dsp, render_background, systray.area.pix, server.gc, traywin->x-systray.area.posx, traywin->y-systray.area.posy, traywin->width, traywin->height, traywin->x-systray.area.posx, traywin->y-systray.area.posy);
589 render_image(systray.area.pix, traywin->x-systray.area.posx, traywin->y-systray.area.posy, traywin->width, traywin->height);
590 XCopyArea(server.dsp, systray.area.pix, panel->main_win, server.gc, traywin->x-systray.area.posx, traywin->y-systray.area.posy, traywin->width, traywin->height, traywin->x, traywin->y);
591 imlib_free_image_and_decache();
592 XFreePixmap(server.dsp, tmp_pmap);
593 imlib_context_set_visual(server.visual);
594 imlib_context_set_colormap(server.colormap);
595
596 if (traywin->damage)
597 XDamageSubtract(server.dsp, traywin->damage, None, None);
598 XFlush(server.dsp);
599 }
600
601
602 void systray_render_icon(TrayWindow* traywin)
603 {
604 if (server.real_transparency || systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0) {
605 // wine tray icons update whenever mouse is over them, so we limit the updates to 50 ms
606 if (traywin->render_timeout == 0)
607 traywin->render_timeout = add_timeout(50, 0, systray_render_icon_now, traywin);
608 }
609 else {
610 // comment by andreas: I'm still not sure, what exactly we need to do here... Somehow trayicons which do not
611 // offer the same depth as tint2 does, need to draw a background pixmap, but this cannot be done with
612 // XCopyArea... So we actually need XRenderComposite???
613 // Pixmap pix = XCreatePixmap(server.dsp, server.root_win, traywin->width, traywin->height, server.depth);
614 // XCopyArea(server.dsp, panel->temp_pmap, pix, server.gc, traywin->x, traywin->y, traywin->width, traywin->height, 0, 0);
615 // XSetWindowBackgroundPixmap(server.dsp, traywin->id, pix);
616 XClearArea(server.dsp, traywin->tray_id, 0, 0, traywin->width, traywin->height, True);
617 }
618 }
619
620
621 void refresh_systray_icon()
622 {
623 TrayWindow *traywin;
624 GSList *l;
625 for (l = systray.list_icons; l ; l = l->next) {
626 traywin = (TrayWindow*)l->data;
627 if (traywin->hide) continue;
628 systray_render_icon(traywin);
629 }
630 }
This page took 0.069637 seconds and 5 git commands to generate.