]> Dogcows Code - chaz/tint2/blob - src/tint.c
a75b1b4d4117ec860665e17ac3b03e0cbb3e9973
[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) return;
482 //printf("atom root_win = %s, %s\n", XGetAtomName(server.dsp, at), tsk->title);
483
484 // Window title changed
485 if (at == server.atom._NET_WM_VISIBLE_NAME || at == server.atom._NET_WM_NAME || at == server.atom.WM_NAME) {
486 Task *tsk2;
487 GSList *l0;
488 get_title(tsk);
489 // changed other tsk->title
490 for (i=0 ; i < nb_panel ; i++) {
491 for (j=0 ; j < panel1[i].nb_desktop ; j++) {
492 for (l0 = panel1[i].taskbar[j].area.list; l0 ; l0 = l0->next) {
493 tsk2 = l0->data;
494 if (tsk->win == tsk2->win && tsk != tsk2) {
495 tsk2->title = tsk->title;
496 tsk2->area.redraw = 1;
497 }
498 }
499 }
500 }
501 panel_refresh = 1;
502 }
503 // Demand attention
504 else if (at == server.atom._NET_WM_STATE) {
505 if (window_is_urgent (win)) {
506 task_urgent = tsk;
507 tick_urgent = 0;
508 time_precision = 1;
509 }
510 }
511 else if (at == server.atom.WM_STATE) {
512 // Iconic state
513 // TODO : try to delete following code
514 if (window_is_iconified (win)) {
515 if (task_active) {
516 if (task_active->win == tsk->win) {
517 Task *tsk2;
518 GSList *l0;
519 for (i=0 ; i < nb_panel ; i++) {
520 for (j=0 ; j < panel1[i].nb_desktop ; j++) {
521 for (l0 = panel1[i].taskbar[j].area.list; l0 ; l0 = l0->next) {
522 tsk2 = l0->data;
523 tsk2->area.is_active = 0;
524 }
525 }
526 }
527 task_active = 0;
528 }
529 }
530 }
531 }
532 // Window icon changed
533 else if (at == server.atom._NET_WM_ICON) {
534 get_icon(tsk);
535 Task *tsk2;
536 GSList *l0;
537 for (i=0 ; i < nb_panel ; i++) {
538 for (j=0 ; j < panel1[i].nb_desktop ; j++) {
539 for (l0 = panel1[i].taskbar[j].area.list; l0 ; l0 = l0->next) {
540 tsk2 = l0->data;
541 if (tsk->win == tsk2->win && tsk != tsk2) {
542 tsk2->icon_width = tsk->icon_width;
543 tsk2->icon_height = tsk->icon_height;
544 tsk2->icon_data = tsk->icon_data;
545 tsk2->icon_data_active = tsk->icon_data_active;
546 tsk2->area.redraw = 1;
547 }
548 }
549 }
550 }
551 panel_refresh = 1;
552 }
553 // Window desktop changed
554 else if (at == server.atom._NET_WM_DESKTOP) {
555 int desktop = window_get_desktop (win);
556 int active = tsk->area.is_active;
557 //printf(" Window desktop changed %d, %d\n", tsk->desktop, desktop);
558 // bug in windowmaker : send unecessary 'desktop changed' when focus changed
559 if (desktop != tsk->desktop) {
560 remove_task (tsk);
561 tsk = add_task (win);
562 if (tsk && active) {
563 tsk->area.is_active = 1;
564 task_active = tsk;
565 }
566 panel_refresh = 1;
567 }
568 }
569
570 if (!server.got_root_win) server.root_win = RootWindow (server.dsp, server.screen);
571 }
572 }
573
574
575 void event_expose (XEvent *e)
576 {
577 Panel *panel;
578
579 panel = get_panel(e->xany.window);
580 if (!panel) return;
581 // TODO : one panel_refresh per panel ?
582 panel_refresh = 1;
583 }
584
585
586 void event_configure_notify (Window win)
587 {
588 // check 'win' move in systray
589 TrayWindow *traywin;
590 GSList *l;
591 for (l = systray.list_icons; l ; l = l->next) {
592 traywin = (TrayWindow*)l->data;
593 if (traywin->id == win) {
594 //printf("move tray %d\n", traywin->x);
595 XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, traywin->width, traywin->height);
596 panel_refresh = 1;
597 return;
598 }
599 }
600
601 // check 'win' move in another monitor
602 if (nb_panel == 1) return;
603 if (server.nb_monitor == 1) return;
604 Task *tsk = task_get_task (win);
605 if (!tsk) return;
606
607 Panel *p = tsk->area.panel;
608 if (p->monitor != window_get_monitor (win)) {
609 remove_task (tsk);
610 add_task (win);
611 if (win == window_get_active ()) {
612 Task *tsk = task_get_task (win);
613 tsk->area.is_active = 1;
614 task_active = tsk;
615 }
616 panel_refresh = 1;
617 }
618 }
619
620
621 void event_timer()
622 {
623 struct timeval stv;
624 int i;
625
626 if (gettimeofday(&stv, 0)) return;
627
628 if (abs(stv.tv_sec - time_clock.tv_sec) < time_precision) return;
629 time_clock.tv_sec = stv.tv_sec;
630 time_clock.tv_sec -= time_clock.tv_sec % time_precision;
631
632 // urgent task
633 if (task_urgent) {
634 if (tick_urgent < max_tick_urgent) {
635 task_urgent->area.is_active = !task_urgent->area.is_active;
636 task_urgent->area.redraw = 1;
637 tick_urgent++;
638 }
639 }
640
641 // update battery
642 #ifdef ENABLE_BATTERY
643 if (panel1[0].battery.area.on_screen) {
644 update_battery();
645 for (i=0 ; i < nb_panel ; i++)
646 panel1[i].battery.area.resize = 1;
647 }
648 #endif
649
650 // update clock
651 if (time1_format) {
652 for (i=0 ; i < nb_panel ; i++)
653 panel1[i].clock.area.resize = 1;
654 }
655 panel_refresh = 1;
656 }
657
658
659 int main (int argc, char *argv[])
660 {
661 XEvent e;
662 fd_set fd;
663 int x11_fd, i;
664 struct timeval tv;
665 Panel *panel;
666 GSList *it;
667
668 init (argc, argv);
669
670 load_config:
671 i = 0;
672 init_config();
673 if (config_path)
674 i = config_read_file (config_path);
675 else
676 i = config_read ();
677 if (!i) {
678 fprintf(stderr, "usage: tint2 [-c] <config_file>\n");
679 cleanup();
680 exit(1);
681 }
682 config_finish();
683 if (thumbnail_path) {
684 // usage: tint2 -j <file> for internal use
685 printf("file %s\n", thumbnail_path);
686 cleanup();
687 exit(0);
688 }
689
690 x11_fd = ConnectionNumber(server.dsp);
691 XSync(server.dsp, False);
692
693 while (1) {
694 // thanks to AngryLlama for the timer
695 // Create a File Description Set containing x11_fd
696 FD_ZERO (&fd);
697 FD_SET (x11_fd, &fd);
698
699 tv.tv_usec = 500000;
700 tv.tv_sec = 0;
701
702 // Wait for X Event or a Timer
703 if (select(x11_fd+1, &fd, 0, 0, &tv)) {
704 while (XPending (server.dsp)) {
705 XNextEvent(server.dsp, &e);
706
707 switch (e.type) {
708 case ButtonPress:
709 event_button_press (&e);
710 break;
711
712 case ButtonRelease:
713 event_button_release(&e);
714 break;
715
716 case Expose:
717 event_expose(&e);
718 break;
719
720 case PropertyNotify:
721 event_property_notify(&e);
722 break;
723
724 case ConfigureNotify:
725 if (e.xconfigure.window == server.root_win)
726 goto load_config;
727 else
728 event_configure_notify (e.xconfigure.window);
729 break;
730
731 case ReparentNotify:
732 if (!systray.area.on_screen)
733 break;
734 panel = (Panel*)systray.area.panel;
735 if (e.xany.window == panel->main_win) // reparented to us
736 break;
737 // FIXME: 'reparent to us' badly detected => disabled
738 break;
739 case UnmapNotify:
740 case DestroyNotify:
741 if (!systray.area.on_screen)
742 break;
743 for (it = systray.list_icons; it; it = g_slist_next(it)) {
744 if (((TrayWindow*)it->data)->id == e.xany.window) {
745 remove_icon((TrayWindow*)it->data);
746 break;
747 }
748 }
749 break;
750
751 case ClientMessage:
752 if (!systray.area.on_screen) break;
753 if (e.xclient.message_type == server.atom._NET_SYSTEM_TRAY_OPCODE && e.xclient.format == 32 && e.xclient.window == net_sel_win) {
754 net_message(&e.xclient);
755 }
756 break;
757 }
758 }
759 }
760 event_timer();
761
762 switch (signal_pending) {
763 case SIGUSR1:
764 signal_pending = 0;
765 goto load_config;
766 case SIGINT:
767 case SIGTERM:
768 case SIGHUP:
769 cleanup ();
770 return 0;
771 }
772
773 if (panel_refresh) {
774 panel_refresh = 0;
775
776 if (refresh_systray) {
777 panel = (Panel*)systray.area.panel;
778 XSetWindowBackgroundPixmap (server.dsp, panel->main_win, None);
779 }
780 for (i=0 ; i < nb_panel ; i++) {
781 panel = &panel1[i];
782
783 if (panel->temp_pmap) XFreePixmap(server.dsp, panel->temp_pmap);
784 panel->temp_pmap = XCreatePixmap(server.dsp, server.root_win, panel->area.width, panel->area.height, server.depth);
785
786 refresh(&panel->area);
787 XCopyArea(server.dsp, panel->temp_pmap, panel->main_win, server.gc, 0, 0, panel->area.width, panel->area.height, 0, 0);
788 }
789 XFlush (server.dsp);
790
791 if (refresh_systray) {
792 refresh_systray = 0;
793 panel = (Panel*)systray.area.panel;
794 // tint2 doen't draw systray icons. it just redraw background.
795 XSetWindowBackgroundPixmap (server.dsp, panel->main_win, panel->temp_pmap);
796 // force icon's refresh
797 refresh_systray_icon();
798 }
799 }
800 }
801 }
802
803
This page took 0.066827 seconds and 3 git commands to generate.