]> Dogcows Code - chaz/tint2/blob - src/tint.c
ac6980bdedc045696a62b7cfd7571422da5252d5
[chaz/tint2] / src / tint.c
1 /**************************************************************************
2 *
3 * Tint2 panel
4 *
5 * Copyright (C) 2007 Pål Staurland (staura@gmail.com)
6 * Modified (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr)
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version 2
10 * as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 **************************************************************************/
20
21 #include <sys/stat.h>
22 #include <sys/time.h>
23 #include <unistd.h>
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <string.h>
27 #include <X11/Xutil.h>
28 #include <X11/Xatom.h>
29 #include <X11/Xlocale.h>
30 #include <Imlib2.h>
31 #include <signal.h>
32
33 #include "server.h"
34 #include "window.h"
35 #include "config.h"
36 #include "task.h"
37 #include "taskbar.h"
38 #include "systraybar.h"
39 #include "panel.h"
40
41
42 void signal_handler(int sig)
43 {
44 // signal handler is light as it should be
45 signal_pending = sig;
46 }
47
48
49 void init (int argc, char *argv[])
50 {
51 int c;
52
53 // read options
54 c = getopt (argc, argv, "c:");
55 if (c != -1) {
56 config_path = strdup (optarg);
57 c = getopt (argc, argv, "j:");
58 if (c != -1)
59 thumbnail_path = strdup (optarg);
60 }
61
62 // Set signal handler
63 signal(SIGUSR1, signal_handler);
64 signal(SIGINT, signal_handler);
65 signal(SIGTERM, signal_handler);
66 signal(SIGHUP, signal_handler);
67 signal(SIGCHLD, SIG_IGN); // don't have to wait() after fork()
68
69 // set global data
70 memset(&server, 0, sizeof(Server_global));
71 memset(&systray, 0, sizeof(Systraybar));
72
73 server.dsp = XOpenDisplay (NULL);
74 if (!server.dsp) {
75 fprintf(stderr, "tint2 exit : could not open display.\n");
76 exit(0);
77 }
78 server_init_atoms ();
79 server.screen = DefaultScreen (server.dsp);
80 server.root_win = RootWindow(server.dsp, server.screen);
81 server.depth = DefaultDepth (server.dsp, server.screen);
82 server.visual = DefaultVisual (server.dsp, server.screen);
83 server.desktop = server_get_current_desktop ();
84 XGCValues gcv;
85 server.gc = XCreateGC (server.dsp, server.root_win, (unsigned long)0, &gcv) ;
86
87 XSetErrorHandler ((XErrorHandler) server_catch_error);
88
89 imlib_context_set_display (server.dsp);
90 imlib_context_set_visual (server.visual);
91 imlib_context_set_colormap (DefaultColormap (server.dsp, server.screen));
92
93 /* Catch events */
94 XSelectInput (server.dsp, server.root_win, PropertyChangeMask|StructureNotifyMask);
95
96 setlocale (LC_ALL, "");
97 }
98
99
100 void cleanup()
101 {
102 cleanup_panel();
103
104 if (time1_font_desc) pango_font_description_free(time1_font_desc);
105 if (time2_font_desc) pango_font_description_free(time2_font_desc);
106 if (time1_format) g_free(time1_format);
107 if (time2_format) g_free(time2_format);
108 #ifdef ENABLE_BATTERY
109 if (bat1_font_desc) pango_font_description_free(bat1_font_desc);
110 if (bat2_font_desc) pango_font_description_free(bat2_font_desc);
111 if (battery_low_cmd) g_free(battery_low_cmd);
112 if (path_energy_now) g_free(path_energy_now);
113 if (path_energy_full) g_free(path_energy_full);
114 if (path_current_now) g_free(path_current_now);
115 if (path_status) g_free(path_status);
116 #endif
117 if (clock_lclick_command) g_free(clock_lclick_command);
118 if (clock_rclick_command) g_free(clock_rclick_command);
119 if (config_path) g_free(config_path);
120 if (thumbnail_path) g_free(thumbnail_path);
121
122 if (server.monitor) free(server.monitor);
123 XFreeGC(server.dsp, server.gc);
124 XCloseDisplay(server.dsp);
125 }
126
127
128 Taskbar *click_taskbar (Panel *panel, XEvent *e)
129 {
130 GSList *l0;
131 Taskbar *tskbar = NULL;
132 if (panel_horizontal) {
133 int x = e->xbutton.x;
134 for (l0 = panel->area.list; l0 ; l0 = l0->next) {
135 tskbar = l0->data;
136 if (!tskbar->area.on_screen) continue;
137 if (x >= tskbar->area.posx && x <= (tskbar->area.posx + tskbar->area.width))
138 break;
139 }
140 }
141 else {
142 int y = e->xbutton.y;
143 for (l0 = panel->area.list; l0 ; l0 = l0->next) {
144 tskbar = l0->data;
145 if (!tskbar->area.on_screen) continue;
146 if (y >= tskbar->area.posy && y <= (tskbar->area.posy + tskbar->area.height))
147 break;
148 }
149 }
150 return tskbar;
151 }
152
153
154 Task *click_task (Panel *panel, XEvent *e)
155 {
156 GSList *l0;
157 Taskbar *tskbar;
158
159 if ( (tskbar = click_taskbar(panel, e)) ) {
160 if (panel_horizontal) {
161 int x = e->xbutton.x;
162 Task *tsk;
163 for (l0 = tskbar->area.list; l0 ; l0 = l0->next) {
164 tsk = l0->data;
165 if (x >= tsk->area.posx && x <= (tsk->area.posx + tsk->area.width)) {
166 return tsk;
167 }
168 }
169 }
170 else {
171 int y = e->xbutton.y;
172 Task *tsk;
173 for (l0 = tskbar->area.list; l0 ; l0 = l0->next) {
174 tsk = l0->data;
175 if (y >= tsk->area.posy && y <= (tsk->area.posy + tsk->area.height)) {
176 return tsk;
177 }
178 }
179 }
180 }
181 return NULL;
182 }
183
184
185 int click_padding(Panel *panel, XEvent *e)
186 {
187 if (panel_horizontal) {
188 if (e->xbutton.x < panel->area.paddingxlr || e->xbutton.x > panel->area.width-panel->area.paddingxlr)
189 return 1;
190 }
191 else {
192 if (e->xbutton.y < panel->area.paddingxlr || e->xbutton.y > panel->area.height-panel->area.paddingxlr)
193 return 1;
194 }
195 return 0;
196 }
197
198
199 int click_clock(Panel *panel, XEvent *e)
200 {
201 Clock clk = panel->clock;
202 if (panel_horizontal) {
203 if (clk.area.on_screen && e->xbutton.x >= clk.area.posx && e->xbutton.x <= (clk.area.posx + clk.area.width))
204 return TRUE;
205 } else {
206 if (clk.area.on_screen && e->xbutton.y >= clk.area.posy && e->xbutton.y <= (clk.area.posy + clk.area.height))
207 return TRUE;
208 }
209 return FALSE;
210 }
211
212
213 void window_action (Task *tsk, int action)
214 {
215 if (!tsk) return;
216 int desk;
217 switch (action) {
218 case CLOSE:
219 set_close (tsk->win);
220 break;
221 case TOGGLE:
222 set_active(tsk->win);
223 break;
224 case ICONIFY:
225 XIconifyWindow (server.dsp, tsk->win, server.screen);
226 break;
227 case TOGGLE_ICONIFY:
228 if (tsk == task_active) XIconifyWindow (server.dsp, tsk->win, server.screen);
229 else set_active (tsk->win);
230 break;
231 case SHADE:
232 window_toggle_shade (tsk->win);
233 break;
234 case MAXIMIZE_RESTORE:
235 window_maximize_restore (tsk->win);
236 break;
237 case MAXIMIZE:
238 window_maximize_restore (tsk->win);
239 break;
240 case RESTORE:
241 window_maximize_restore (tsk->win);
242 break;
243 case DESKTOP_LEFT:
244 if ( tsk->desktop == 0 ) break;
245 desk = tsk->desktop - 1;
246 windows_set_desktop(tsk->win, desk);
247 if (desk == server.desktop)
248 set_active(tsk->win);
249 break;
250 case DESKTOP_RIGHT:
251 if (tsk->desktop == server.nb_desktop ) break;
252 desk = tsk->desktop + 1;
253 windows_set_desktop(tsk->win, desk);
254 if (desk == server.desktop)
255 set_active(tsk->win);
256 }
257 }
258
259
260 void event_button_press (XEvent *e)
261 {
262 Panel *panel = get_panel(e->xany.window);
263 if (!panel) return;
264
265 if (panel_mode == MULTI_DESKTOP)
266 task_drag = click_task(panel, e);
267
268 if (wm_menu && !task_drag && !click_clock(panel, e) && (e->xbutton.button != 1) ) {
269 // forward the click to the desktop window (thanks conky)
270 XUngrabPointer(server.dsp, e->xbutton.time);
271 e->xbutton.window = server.root_win;
272 // icewm doesn't open under the mouse.
273 // and xfce doesn't open at all.
274 //e->xbutton.x = e->xbutton.x_root;
275 //e->xbutton.y = e->xbutton.y_root;
276 //printf("**** %d, %d\n", e->xbutton.x, e->xbutton.y);
277 XSetInputFocus(server.dsp, e->xbutton.window, RevertToParent, e->xbutton.time);
278 XSendEvent(server.dsp, e->xbutton.window, False, ButtonPressMask, e);
279 return;
280 }
281
282 XLowerWindow (server.dsp, panel->main_win);
283 }
284
285
286 void event_button_release (XEvent *e)
287 {
288 Panel *panel = get_panel(e->xany.window);
289 if (!panel) return;
290
291 if (wm_menu && click_padding(panel, e)) {
292 // forward the click to the desktop window (thanks conky)
293 e->xbutton.window = server.root_win;
294 XSendEvent(server.dsp, e->xbutton.window, False, ButtonReleaseMask, e);
295 return;
296 }
297
298 int action = TOGGLE_ICONIFY;
299 switch (e->xbutton.button) {
300 case 2:
301 action = mouse_middle;
302 break;
303 case 3:
304 action = mouse_right;
305 break;
306 case 4:
307 action = mouse_scroll_up;
308 break;
309 case 5:
310 action = mouse_scroll_down;
311 break;
312 case 6:
313 action = mouse_tilt_left;
314 break;
315 case 7:
316 action = mouse_tilt_right;
317 break;
318 }
319
320 if ( click_clock(panel, e)) {
321 clock_action(e->xbutton.button);
322 XLowerWindow (server.dsp, panel->main_win);
323 task_drag = 0;
324 return;
325 }
326
327 Taskbar *tskbar;
328 if ( !(tskbar = click_taskbar(panel, e)) ) {
329 // TODO: check better solution to keep window below
330 XLowerWindow (server.dsp, panel->main_win);
331 task_drag = 0;
332 return;
333 }
334
335 // drag and drop task
336 if (task_drag) {
337 if (tskbar != task_drag->area.parent && action == TOGGLE_ICONIFY) {
338 if (task_drag->desktop != ALLDESKTOP && panel_mode == MULTI_DESKTOP) {
339 windows_set_desktop(task_drag->win, tskbar->desktop);
340 if (tskbar->desktop == server.desktop)
341 set_active(task_drag->win);
342 task_drag = 0;
343 }
344 return;
345 }
346 else task_drag = 0;
347 }
348
349 // switch desktop
350 if (panel_mode == MULTI_DESKTOP) {
351 if (tskbar->desktop != server.desktop && action != CLOSE && action != DESKTOP_LEFT && action != DESKTOP_RIGHT)
352 set_desktop (tskbar->desktop);
353 }
354
355 // action on task
356 window_action( click_task(panel, e), action);
357
358 // to keep window below
359 XLowerWindow (server.dsp, panel->main_win);
360 }
361
362
363 void event_property_notify (XEvent *e)
364 {
365 int i, j;
366 Task *tsk;
367 Window win = e->xproperty.window;
368 Atom at = e->xproperty.atom;
369
370 if (win == server.root_win) {
371 if (!server.got_root_win) {
372 XSelectInput (server.dsp, server.root_win, PropertyChangeMask|StructureNotifyMask);
373 server.got_root_win = 1;
374 }
375
376 // Change number of desktops
377 else if (at == server.atom._NET_NUMBER_OF_DESKTOPS) {
378 server.nb_desktop = server_get_number_of_desktop ();
379 cleanup_taskbar();
380 init_taskbar();
381 visible_object();
382 for (i=0 ; i < nb_panel ; i++) {
383 panel1[i].area.resize = 1;
384 }
385 task_refresh_tasklist();
386 panel_refresh = 1;
387 }
388 // Change desktop
389 else if (at == server.atom._NET_CURRENT_DESKTOP) {
390 server.desktop = server_get_current_desktop ();
391 for (i=0 ; i < nb_panel ; i++) {
392 Panel *panel = &panel1[i];
393 if (panel_mode == MULTI_DESKTOP && panel->g_taskbar.use_active) {
394 // redraw taskbar
395 panel_refresh = 1;
396 Taskbar *tskbar;
397 Task *tsk;
398 GSList *l;
399 for (j=0 ; j < panel->nb_desktop ; j++) {
400 tskbar = &panel->taskbar[j];
401 if (tskbar->area.is_active) {
402 tskbar->area.is_active = 0;
403 tskbar->area.redraw = 1;
404 for (l = tskbar->area.list; l ; l = l->next) {
405 tsk = l->data;
406 tsk->area.redraw = 1;
407 }
408 }
409 if (j == server.desktop) {
410 tskbar->area.is_active = 1;
411 tskbar->area.redraw = 1;
412 for (l = tskbar->area.list; l ; l = l->next) {
413 tsk = l->data;
414 tsk->area.redraw = 1;
415 }
416 }
417 }
418 }
419 }
420 if (panel_mode != MULTI_DESKTOP) {
421 visible_object();
422 }
423 }
424 // Window list
425 else if (at == server.atom._NET_CLIENT_LIST) {
426 task_refresh_tasklist();
427 panel_refresh = 1;
428 }
429 // Change active
430 else if (at == server.atom._NET_ACTIVE_WINDOW) {
431 GSList *l0;
432 if (task_active) {
433 for (i=0 ; i < nb_panel ; i++) {
434 for (j=0 ; j < panel1[i].nb_desktop ; j++) {
435 for (l0 = panel1[i].taskbar[j].area.list; l0 ; l0 = l0->next) {
436 tsk = l0->data;
437 tsk->area.is_active = 0;
438 }
439 }
440 }
441 task_active = 0;
442 }
443 Window w1 = window_get_active ();
444 Task *t = task_get_task(w1);
445 if (!t) {
446 Window w2;
447 if (XGetTransientForHint(server.dsp, w1, &w2) != 0)
448 if (w2) t = task_get_task(w2);
449 }
450 if (task_urgent == t) {
451 init_precision();
452 task_urgent = 0;
453 }
454 // put active state on all task (multi_desktop)
455 if (t) {
456 for (i=0 ; i < nb_panel ; i++) {
457 for (j=0 ; j < panel1[i].nb_desktop ; j++) {
458 for (l0 = panel1[i].taskbar[j].area.list; l0 ; l0 = l0->next) {
459 tsk = l0->data;
460 if (tsk->win == t->win) {
461 tsk->area.is_active = 1;
462 //printf("active monitor %d, task %s\n", panel1[i].monitor, tsk->title);
463 }
464 }
465 }
466 }
467 task_active = t;
468 }
469 panel_refresh = 1;
470 }
471 else if (at == server.atom._XROOTPMAP_ID) {
472 // change Wallpaper
473 for (i=0 ; i < nb_panel ; i++) {
474 set_panel_background(&panel1[i]);
475 }
476 panel_refresh = 1;
477 }
478 }
479 else {
480 tsk = task_get_task (win);
481 if (!tsk) {
482 if ( at != server.atom._NET_WM_STATE)
483 return;
484 else if ( !(tsk = add_task(win)) )
485 return;
486 }
487 //printf("atom root_win = %s, %s\n", XGetAtomName(server.dsp, at), tsk->title);
488
489 // Window title changed
490 if (at == server.atom._NET_WM_VISIBLE_NAME || at == server.atom._NET_WM_NAME || at == server.atom.WM_NAME) {
491 Task *tsk2;
492 GSList *l0;
493 get_title(tsk);
494 // changed other tsk->title
495 for (i=0 ; i < nb_panel ; i++) {
496 for (j=0 ; j < panel1[i].nb_desktop ; j++) {
497 for (l0 = panel1[i].taskbar[j].area.list; l0 ; l0 = l0->next) {
498 tsk2 = l0->data;
499 if (tsk->win == tsk2->win && tsk != tsk2) {
500 tsk2->title = tsk->title;
501 tsk2->area.redraw = 1;
502 }
503 }
504 }
505 }
506 panel_refresh = 1;
507 }
508 // Demand attention
509 else if (at == server.atom._NET_WM_STATE) {
510 if (window_is_urgent (win)) {
511 task_urgent = tsk;
512 tick_urgent = 0;
513 time_precision = 1;
514 }
515 if (window_is_skip_taskbar(win)) {
516 remove_task( tsk );
517 panel_refresh = 1;
518 }
519 }
520 else if (at == server.atom.WM_STATE) {
521 // Iconic state
522 // TODO : try to delete following code
523 if (window_is_iconified (win)) {
524 if (task_active) {
525 if (task_active->win == tsk->win) {
526 Task *tsk2;
527 GSList *l0;
528 for (i=0 ; i < nb_panel ; i++) {
529 for (j=0 ; j < panel1[i].nb_desktop ; j++) {
530 for (l0 = panel1[i].taskbar[j].area.list; l0 ; l0 = l0->next) {
531 tsk2 = l0->data;
532 tsk2->area.is_active = 0;
533 }
534 }
535 }
536 task_active = 0;
537 }
538 }
539 }
540 }
541 // Window icon changed
542 else if (at == server.atom._NET_WM_ICON) {
543 get_icon(tsk);
544 Task *tsk2;
545 GSList *l0;
546 for (i=0 ; i < nb_panel ; i++) {
547 for (j=0 ; j < panel1[i].nb_desktop ; j++) {
548 for (l0 = panel1[i].taskbar[j].area.list; l0 ; l0 = l0->next) {
549 tsk2 = l0->data;
550 if (tsk->win == tsk2->win && tsk != tsk2) {
551 tsk2->icon_width = tsk->icon_width;
552 tsk2->icon_height = tsk->icon_height;
553 tsk2->icon_data = tsk->icon_data;
554 tsk2->icon_data_active = tsk->icon_data_active;
555 tsk2->area.redraw = 1;
556 }
557 }
558 }
559 }
560 panel_refresh = 1;
561 }
562 // Window desktop changed
563 else if (at == server.atom._NET_WM_DESKTOP) {
564 int desktop = window_get_desktop (win);
565 int active = tsk->area.is_active;
566 //printf(" Window desktop changed %d, %d\n", tsk->desktop, desktop);
567 // bug in windowmaker : send unecessary 'desktop changed' when focus changed
568 if (desktop != tsk->desktop) {
569 remove_task (tsk);
570 tsk = add_task (win);
571 if (tsk && active) {
572 tsk->area.is_active = 1;
573 task_active = tsk;
574 }
575 panel_refresh = 1;
576 }
577 }
578
579 if (!server.got_root_win) server.root_win = RootWindow (server.dsp, server.screen);
580 }
581 }
582
583
584 void event_expose (XEvent *e)
585 {
586 Panel *panel;
587
588 panel = get_panel(e->xany.window);
589 if (!panel) return;
590 // TODO : one panel_refresh per panel ?
591 panel_refresh = 1;
592 }
593
594
595 void event_configure_notify (Window win)
596 {
597 // check 'win' move in systray
598 TrayWindow *traywin;
599 GSList *l;
600 for (l = systray.list_icons; l ; l = l->next) {
601 traywin = (TrayWindow*)l->data;
602 if (traywin->id == win) {
603 //printf("move tray %d\n", traywin->x);
604 XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, traywin->width, traywin->height);
605 panel_refresh = 1;
606 return;
607 }
608 }
609
610 // check 'win' move in another monitor
611 if (nb_panel == 1) return;
612 if (server.nb_monitor == 1) return;
613 Task *tsk = task_get_task (win);
614 if (!tsk) return;
615
616 Panel *p = tsk->area.panel;
617 if (p->monitor != window_get_monitor (win)) {
618 remove_task (tsk);
619 add_task (win);
620 if (win == window_get_active ()) {
621 Task *tsk = task_get_task (win);
622 tsk->area.is_active = 1;
623 task_active = tsk;
624 }
625 panel_refresh = 1;
626 }
627 }
628
629
630 void event_timer()
631 {
632 struct timeval stv;
633 int i;
634
635 if (gettimeofday(&stv, 0)) return;
636
637 if (abs(stv.tv_sec - time_clock.tv_sec) < time_precision) return;
638 time_clock.tv_sec = stv.tv_sec;
639 time_clock.tv_sec -= time_clock.tv_sec % time_precision;
640
641 // urgent task
642 if (task_urgent) {
643 if (tick_urgent < max_tick_urgent) {
644 task_urgent->area.is_active = !task_urgent->area.is_active;
645 task_urgent->area.redraw = 1;
646 tick_urgent++;
647 }
648 }
649
650 // update battery
651 #ifdef ENABLE_BATTERY
652 if (panel1[0].battery.area.on_screen) {
653 update_battery();
654 for (i=0 ; i < nb_panel ; i++)
655 panel1[i].battery.area.resize = 1;
656 }
657 #endif
658
659 // update clock
660 if (time1_format) {
661 for (i=0 ; i < nb_panel ; i++)
662 panel1[i].clock.area.resize = 1;
663 }
664 panel_refresh = 1;
665 }
666
667
668 int main (int argc, char *argv[])
669 {
670 XEvent e;
671 fd_set fd;
672 int x11_fd, i;
673 struct timeval tv;
674 Panel *panel;
675 GSList *it;
676
677 init (argc, argv);
678
679 load_config:
680 i = 0;
681 init_config();
682 if (config_path)
683 i = config_read_file (config_path);
684 else
685 i = config_read ();
686 if (!i) {
687 fprintf(stderr, "usage: tint2 [-c] <config_file>\n");
688 cleanup();
689 exit(1);
690 }
691 config_finish();
692 if (thumbnail_path) {
693 // usage: tint2 -j <file> for internal use
694 printf("file %s\n", thumbnail_path);
695 cleanup();
696 exit(0);
697 }
698
699 x11_fd = ConnectionNumber(server.dsp);
700 XSync(server.dsp, False);
701
702 while (1) {
703 // thanks to AngryLlama for the timer
704 // Create a File Description Set containing x11_fd
705 FD_ZERO (&fd);
706 FD_SET (x11_fd, &fd);
707
708 tv.tv_usec = 500000;
709 tv.tv_sec = 0;
710
711 // Wait for X Event or a Timer
712 if (select(x11_fd+1, &fd, 0, 0, &tv)) {
713 while (XPending (server.dsp)) {
714 XNextEvent(server.dsp, &e);
715
716 switch (e.type) {
717 case ButtonPress:
718 event_button_press (&e);
719 break;
720
721 case ButtonRelease:
722 event_button_release(&e);
723 break;
724
725 case Expose:
726 event_expose(&e);
727 break;
728
729 case PropertyNotify:
730 event_property_notify(&e);
731 break;
732
733 case ConfigureNotify:
734 if (e.xconfigure.window == server.root_win)
735 goto load_config;
736 else
737 event_configure_notify (e.xconfigure.window);
738 break;
739
740 case ReparentNotify:
741 if (!systray.area.on_screen)
742 break;
743 panel = (Panel*)systray.area.panel;
744 if (e.xany.window == panel->main_win) // reparented to us
745 break;
746 // FIXME: 'reparent to us' badly detected => disabled
747 break;
748 case UnmapNotify:
749 case DestroyNotify:
750 if (!systray.area.on_screen)
751 break;
752 for (it = systray.list_icons; it; it = g_slist_next(it)) {
753 if (((TrayWindow*)it->data)->id == e.xany.window) {
754 remove_icon((TrayWindow*)it->data);
755 break;
756 }
757 }
758 break;
759
760 case ClientMessage:
761 if (!systray.area.on_screen) break;
762 if (e.xclient.message_type == server.atom._NET_SYSTEM_TRAY_OPCODE && e.xclient.format == 32 && e.xclient.window == net_sel_win) {
763 net_message(&e.xclient);
764 }
765 break;
766 }
767 }
768 }
769 event_timer();
770
771 switch (signal_pending) {
772 case SIGUSR1:
773 signal_pending = 0;
774 goto load_config;
775 case SIGINT:
776 case SIGTERM:
777 case SIGHUP:
778 cleanup ();
779 return 0;
780 }
781
782 if (panel_refresh) {
783 panel_refresh = 0;
784
785 if (refresh_systray) {
786 panel = (Panel*)systray.area.panel;
787 XSetWindowBackgroundPixmap (server.dsp, panel->main_win, None);
788 }
789 for (i=0 ; i < nb_panel ; i++) {
790 panel = &panel1[i];
791
792 if (panel->temp_pmap) XFreePixmap(server.dsp, panel->temp_pmap);
793 panel->temp_pmap = XCreatePixmap(server.dsp, server.root_win, panel->area.width, panel->area.height, server.depth);
794
795 refresh(&panel->area);
796 XCopyArea(server.dsp, panel->temp_pmap, panel->main_win, server.gc, 0, 0, panel->area.width, panel->area.height, 0, 0);
797 }
798 XFlush (server.dsp);
799
800 if (refresh_systray) {
801 refresh_systray = 0;
802 panel = (Panel*)systray.area.panel;
803 // tint2 doen't draw systray icons. it just redraw background.
804 XSetWindowBackgroundPixmap (server.dsp, panel->main_win, panel->temp_pmap);
805 // force icon's refresh
806 refresh_systray_icon();
807 }
808 }
809 }
810 }
811
812
This page took 0.072426 seconds and 3 git commands to generate.