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