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