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