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