]> Dogcows Code - chaz/tint2/blob - src/tint.c
*change* make tooltip more generous, and preparation for setting a tooltip on the...
[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 <unistd.h>
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <stdint.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 #include "tooltip.h"
41 #include "timer.h"
42
43 void signal_handler(int sig)
44 {
45 // signal handler is light as it should be
46 signal_pending = sig;
47 }
48
49
50 void init (int argc, char *argv[])
51 {
52 int i;
53
54 // read options
55 for (i = 1; i < argc; ++i) {
56 if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {
57 printf("Usage: tint2 [-c] <config_file>\n");
58 exit(0);
59 }
60 if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version")) {
61 printf("tint2 version 0.7.svn\n");
62 exit(0);
63 }
64 if (!strcmp(argv[i], "-c")) {
65 i++;
66 if (i < argc)
67 config_path = strdup(argv[i]);
68 }
69 if (!strcmp(argv[i], "-s")) {
70 i++;
71 if (i < argc)
72 snapshot_path = strdup(argv[i]);
73 }
74 }
75
76 // Set signal handler
77 struct sigaction sa = { .sa_handler = signal_handler };
78 sigaction(SIGUSR1, &sa, 0);
79 sigaction(SIGINT, &sa, 0);
80 sigaction(SIGTERM, &sa, 0);
81 sigaction(SIGHUP, &sa, 0);
82 signal(SIGCHLD, SIG_IGN); // don't have to wait() after fork()
83 // block all signals, such that no race conditions occur before pselect in our main loop
84 sigset_t block_mask;
85 sigaddset(&block_mask, SIGINT);
86 sigaddset(&block_mask, SIGTERM);
87 sigaddset(&block_mask, SIGHUP);
88 sigaddset(&block_mask, SIGUSR1);
89 sigprocmask(SIG_BLOCK, &block_mask, 0);
90
91
92 // set global data
93 memset(&server, 0, sizeof(Server_global));
94 memset(&systray, 0, sizeof(Systraybar));
95
96 server.dsp = XOpenDisplay (NULL);
97 if (!server.dsp) {
98 fprintf(stderr, "tint2 exit : could not open display.\n");
99 exit(0);
100 }
101 server_init_atoms ();
102 server.screen = DefaultScreen (server.dsp);
103 server.root_win = RootWindow(server.dsp, server.screen);
104 server.depth = DefaultDepth (server.dsp, server.screen);
105 server.visual = DefaultVisual (server.dsp, server.screen);
106 server.desktop = server_get_current_desktop ();
107 XGCValues gcv;
108 server.gc = XCreateGC (server.dsp, server.root_win, (unsigned long)0, &gcv);
109
110 XSetErrorHandler ((XErrorHandler) server_catch_error);
111
112 imlib_context_set_display (server.dsp);
113 imlib_context_set_visual (server.visual);
114 imlib_context_set_colormap (DefaultColormap (server.dsp, server.screen));
115
116 /* Catch events */
117 XSelectInput (server.dsp, server.root_win, PropertyChangeMask|StructureNotifyMask);
118
119 setlocale (LC_ALL, "");
120
121 // load default icon
122 gchar *path;
123 const gchar * const *data_dirs;
124 data_dirs = g_get_system_data_dirs ();
125 for (i = 0; data_dirs[i] != NULL; i++) {
126 path = g_build_filename(data_dirs[i], "tint2", "default_icon.png", NULL);
127 if (g_file_test (path, G_FILE_TEST_EXISTS))
128 default_icon = imlib_load_image(path);
129 g_free(path);
130 }
131
132 // get monitor and desktop config
133 get_monitors();
134 get_desktops();
135 }
136
137
138 void cleanup()
139 {
140 cleanup_systray();
141 stop_net();
142 cleanup_panel();
143 cleanup_tooltip();
144 cleanup_clock();
145 #ifdef ENABLE_BATTERY
146 cleanup_battery();
147 #endif
148
149 if (default_icon) {
150 imlib_context_set_image(default_icon);
151 imlib_free_image();
152 }
153 if (config_path) g_free(config_path);
154 if (snapshot_path) g_free(snapshot_path);
155
156 if (server.monitor) free(server.monitor);
157 XFreeGC(server.dsp, server.gc);
158 XCloseDisplay(server.dsp);
159 }
160
161
162 void get_snapshot(const char *path)
163 {
164 Panel *panel = &panel1[0];
165
166 if (panel->temp_pmap) XFreePixmap(server.dsp, panel->temp_pmap);
167 panel->temp_pmap = XCreatePixmap(server.dsp, server.root_win, panel->area.width, panel->area.height, server.depth);
168
169 refresh(&panel->area);
170
171 Imlib_Image img = NULL;
172 imlib_context_set_drawable(panel->temp_pmap);
173 img = imlib_create_image_from_drawable(0, 0, 0, panel->area.width, panel->area.height, 0);
174
175 imlib_context_set_image(img);
176 imlib_save_image(path);
177 imlib_free_image();
178 }
179
180
181 void window_action (Task *tsk, int action)
182 {
183 if (!tsk) return;
184 int desk;
185 switch (action) {
186 case CLOSE:
187 set_close (tsk->win);
188 break;
189 case TOGGLE:
190 set_active(tsk->win);
191 break;
192 case ICONIFY:
193 XIconifyWindow (server.dsp, tsk->win, server.screen);
194 break;
195 case TOGGLE_ICONIFY:
196 if (task_active && tsk->win == task_active->win)
197 XIconifyWindow (server.dsp, tsk->win, server.screen);
198 else
199 set_active (tsk->win);
200 break;
201 case SHADE:
202 window_toggle_shade (tsk->win);
203 break;
204 case MAXIMIZE_RESTORE:
205 window_maximize_restore (tsk->win);
206 break;
207 case MAXIMIZE:
208 window_maximize_restore (tsk->win);
209 break;
210 case RESTORE:
211 window_maximize_restore (tsk->win);
212 break;
213 case DESKTOP_LEFT:
214 if ( tsk->desktop == 0 ) break;
215 desk = tsk->desktop - 1;
216 windows_set_desktop(tsk->win, desk);
217 if (desk == server.desktop)
218 set_active(tsk->win);
219 break;
220 case DESKTOP_RIGHT:
221 if (tsk->desktop == server.nb_desktop ) break;
222 desk = tsk->desktop + 1;
223 windows_set_desktop(tsk->win, desk);
224 if (desk == server.desktop)
225 set_active(tsk->win);
226 }
227 }
228
229
230 void event_button_press (XEvent *e)
231 {
232 Panel *panel = get_panel(e->xany.window);
233 if (!panel) return;
234
235 task_drag = click_task(panel, e->xbutton.x, e->xbutton.y);
236
237 if (wm_menu && !task_drag && !click_clock(panel, e->xbutton.x, e->xbutton.y) && (e->xbutton.button != 1) ) {
238 // forward the click to the desktop window (thanks conky)
239 XUngrabPointer(server.dsp, e->xbutton.time);
240 e->xbutton.window = server.root_win;
241 // icewm doesn't open under the mouse.
242 // and xfce doesn't open at all.
243 e->xbutton.x = e->xbutton.x_root;
244 e->xbutton.y = e->xbutton.y_root;
245 //printf("**** %d, %d\n", e->xbutton.x, e->xbutton.y);
246 //XSetInputFocus(server.dsp, e->xbutton.window, RevertToParent, e->xbutton.time);
247 XSendEvent(server.dsp, e->xbutton.window, False, ButtonPressMask, e);
248 return;
249 }
250
251 XLowerWindow (server.dsp, panel->main_win);
252 }
253
254
255 void event_button_release (XEvent *e)
256 {
257 Panel *panel = get_panel(e->xany.window);
258 if (!panel) return;
259
260 int action = TOGGLE_ICONIFY;
261 switch (e->xbutton.button) {
262 case 2:
263 action = mouse_middle;
264 break;
265 case 3:
266 action = mouse_right;
267 break;
268 case 4:
269 action = mouse_scroll_up;
270 break;
271 case 5:
272 action = mouse_scroll_down;
273 break;
274 case 6:
275 action = mouse_tilt_left;
276 break;
277 case 7:
278 action = mouse_tilt_right;
279 break;
280 }
281
282 if ( click_clock(panel, e->xbutton.x, e->xbutton.y)) {
283 clock_action(e->xbutton.button);
284 XLowerWindow (server.dsp, panel->main_win);
285 task_drag = 0;
286 return;
287 }
288
289 Taskbar *tskbar;
290 if ( !(tskbar = click_taskbar(panel, e->xbutton.x, e->xbutton.y)) ) {
291 // TODO: check better solution to keep window below
292 XLowerWindow (server.dsp, panel->main_win);
293 task_drag = 0;
294 return;
295 }
296
297 // drag and drop task
298 if (task_drag) {
299 if (tskbar != task_drag->area.parent && action == TOGGLE_ICONIFY) {
300 if (task_drag->desktop != ALLDESKTOP && panel_mode == MULTI_DESKTOP) {
301 windows_set_desktop(task_drag->win, tskbar->desktop);
302 if (tskbar->desktop == server.desktop)
303 set_active(task_drag->win);
304 task_drag = 0;
305 }
306 return;
307 }
308 else task_drag = 0;
309 }
310
311 // switch desktop
312 if (panel_mode == MULTI_DESKTOP) {
313 if (tskbar->desktop != server.desktop && action != CLOSE && action != DESKTOP_LEFT && action != DESKTOP_RIGHT)
314 set_desktop (tskbar->desktop);
315 }
316
317 // action on task
318 window_action( click_task(panel, e->xbutton.x, e->xbutton.y), action);
319
320 // to keep window below
321 XLowerWindow (server.dsp, panel->main_win);
322 }
323
324
325 void event_property_notify (XEvent *e)
326 {
327 int i, j;
328 Task *tsk;
329 Window win = e->xproperty.window;
330 Atom at = e->xproperty.atom;
331
332 if (win == server.root_win) {
333 if (!server.got_root_win) {
334 XSelectInput (server.dsp, server.root_win, PropertyChangeMask|StructureNotifyMask);
335 server.got_root_win = 1;
336 }
337
338 // Change number of desktops
339 else if (at == server.atom._NET_NUMBER_OF_DESKTOPS) {
340 server.nb_desktop = server_get_number_of_desktop ();
341 cleanup_taskbar();
342 init_taskbar();
343 visible_object();
344 for (i=0 ; i < nb_panel ; i++) {
345 panel1[i].area.resize = 1;
346 }
347 task_refresh_tasklist();
348 panel_refresh = 1;
349 }
350 // Change desktop
351 else if (at == server.atom._NET_CURRENT_DESKTOP) {
352 int old_desktop = server.desktop;
353 server.desktop = server_get_current_desktop ();
354 for (i=0 ; i < nb_panel ; i++) {
355 Panel *panel = &panel1[i];
356 if (panel_mode == MULTI_DESKTOP && panel->g_taskbar.use_active) {
357 // redraw both taskbar
358 panel->taskbar[old_desktop].area.is_active = 0;
359 panel->taskbar[old_desktop].area.resize = 1;
360 panel->taskbar[server.desktop].area.is_active = 1;
361 panel->taskbar[server.desktop].area.resize = 1;
362 panel_refresh = 1;
363 }
364 // check ALLDESKTOP task => resize taskbar
365 Taskbar *tskbar;
366 Task *tsk;
367 GSList *l;
368 tskbar = &panel->taskbar[old_desktop];
369 for (l = tskbar->area.list; l ; l = l->next) {
370 tsk = l->data;
371 if (tsk->desktop == ALLDESKTOP) {
372 tsk->area.on_screen = 0;
373 tskbar->area.resize = 1;
374 panel_refresh = 1;
375 }
376 }
377 tskbar = &panel->taskbar[server.desktop];
378 for (l = tskbar->area.list; l ; l = l->next) {
379 tsk = l->data;
380 if (tsk->desktop == ALLDESKTOP) {
381 tsk->area.on_screen = 1;
382 tskbar->area.resize = 1;
383 }
384 }
385 }
386 if (panel_mode != MULTI_DESKTOP) {
387 visible_object();
388 }
389 }
390 // Window list
391 else if (at == server.atom._NET_CLIENT_LIST) {
392 task_refresh_tasklist();
393 panel_refresh = 1;
394 }
395 // Change active
396 else if (at == server.atom._NET_ACTIVE_WINDOW) {
397 active_task();
398 panel_refresh = 1;
399 }
400 else if (at == server.atom._XROOTPMAP_ID) {
401 // change Wallpaper
402 for (i=0 ; i < nb_panel ; i++) {
403 set_panel_background(&panel1[i]);
404 }
405 panel_refresh = 1;
406 }
407 }
408 else {
409 tsk = task_get_task (win);
410 if (!tsk) {
411 if (at != server.atom._NET_WM_STATE)
412 return;
413 else {
414 // xfce4 sends _NET_WM_STATE after minimized to tray, so we need to check if window is mapped
415 // if it is mapped and not set as skip_taskbar, we must add it to our task list
416 XWindowAttributes wa;
417 XGetWindowAttributes(server.dsp, win, &wa);
418 if (wa.map_state == IsViewable && !window_is_skip_taskbar(win)) {
419 if ( (tsk = add_task(win)) )
420 panel_refresh = 1;
421 else
422 return;
423 }
424 }
425 }
426 //printf("atom root_win = %s, %s\n", XGetAtomName(server.dsp, at), tsk->title);
427
428 // Window title changed
429 if (at == server.atom._NET_WM_VISIBLE_NAME || at == server.atom._NET_WM_NAME || at == server.atom.WM_NAME) {
430 Task *tsk2;
431 GSList *l0;
432 get_title(tsk);
433 // changed other tsk->title
434 for (i=0 ; i < nb_panel ; i++) {
435 for (j=0 ; j < panel1[i].nb_desktop ; j++) {
436 for (l0 = panel1[i].taskbar[j].area.list; l0 ; l0 = l0->next) {
437 tsk2 = l0->data;
438 if (tsk->win == tsk2->win && tsk != tsk2) {
439 tsk2->title = tsk->title;
440 tsk2->area.redraw = 1;
441 }
442 }
443 }
444 }
445 panel_refresh = 1;
446 }
447 // Demand attention
448 else if (at == server.atom._NET_WM_STATE) {
449 if (window_is_urgent (win)) {
450 add_urgent(tsk);
451 }
452 if (window_is_skip_taskbar(win)) {
453 remove_task( tsk );
454 panel_refresh = 1;
455 }
456 }
457 // We do not check for the iconified state, since it only unsets our active window
458 // but in openbox a shaded window is considered iconified. So we would loose the active window
459 // property on unshading it again (commented 01.10.2009)
460 // else if (at == server.atom.WM_STATE) {
461 // // Iconic state
462 // // TODO : try to delete following code
463 // if (window_is_iconified (win)) {
464 // if (task_active) {
465 // if (task_active->win == tsk->win) {
466 // Task *tsk2;
467 // GSList *l0;
468 // for (i=0 ; i < nb_panel ; i++) {
469 // for (j=0 ; j < panel1[i].nb_desktop ; j++) {
470 // for (l0 = panel1[i].taskbar[j].area.list; l0 ; l0 = l0->next) {
471 // tsk2 = l0->data;
472 // tsk2->area.is_active = 0;
473 // }
474 // }
475 // }
476 // task_active = 0;
477 // }
478 // }
479 // }
480 // }
481 // Window icon changed
482 else if (at == server.atom._NET_WM_ICON) {
483 get_icon(tsk);
484 Task *tsk2;
485 GSList *l0;
486 for (i=0 ; i < nb_panel ; i++) {
487 for (j=0 ; j < panel1[i].nb_desktop ; j++) {
488 for (l0 = panel1[i].taskbar[j].area.list; l0 ; l0 = l0->next) {
489 tsk2 = l0->data;
490 if (tsk->win == tsk2->win && tsk != tsk2) {
491 tsk2->icon_width = tsk->icon_width;
492 tsk2->icon_height = tsk->icon_height;
493 tsk2->icon = tsk->icon;
494 tsk2->icon_active = tsk->icon_active;
495 tsk2->area.redraw = 1;
496 }
497 }
498 }
499 }
500 panel_refresh = 1;
501 }
502 // Window desktop changed
503 else if (at == server.atom._NET_WM_DESKTOP) {
504 int desktop = window_get_desktop (win);
505 int active = tsk->area.is_active;
506 //printf(" Window desktop changed %d, %d\n", tsk->desktop, desktop);
507 // bug in windowmaker : send unecessary 'desktop changed' when focus changed
508 if (desktop != tsk->desktop) {
509 remove_task (tsk);
510 tsk = add_task (win);
511 if (tsk && active) {
512 tsk->area.is_active = 1;
513 task_active = tsk;
514 }
515 panel_refresh = 1;
516 }
517 }
518 else if (at == server.atom.WM_HINTS) {
519 XWMHints* wmhints = XGetWMHints(server.dsp, win);
520 if (wmhints && wmhints->flags & XUrgencyHint) {
521 add_urgent(tsk);
522 }
523 XFree(wmhints);
524 }
525
526 if (!server.got_root_win) server.root_win = RootWindow (server.dsp, server.screen);
527 }
528 }
529
530
531 void event_expose (XEvent *e)
532 {
533 Panel *panel;
534 panel = get_panel(e->xany.window);
535 if (!panel) return;
536 // TODO : one panel_refresh per panel ?
537 panel_refresh = 1;
538 }
539
540
541 void event_configure_notify (Window win)
542 {
543 // change in root window (xrandr)
544 if (win == server.root_win) {
545 get_monitors();
546 init_config();
547 config_read_file (config_path);
548 init_panel();
549 cleanup_config();
550 return;
551 }
552
553 // 'win' is a trayer icon
554 TrayWindow *traywin;
555 GSList *l;
556 for (l = systray.list_icons; l ; l = l->next) {
557 traywin = (TrayWindow*)l->data;
558 if (traywin->id == win) {
559 //printf("move tray %d\n", traywin->x);
560 XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, traywin->width, traywin->height);
561 panel_refresh = 1;
562 return;
563 }
564 }
565
566 // 'win' move in another monitor
567 if (nb_panel == 1) return;
568 Task *tsk = task_get_task (win);
569 if (!tsk) return;
570
571 Panel *p = tsk->area.panel;
572 if (p->monitor != window_get_monitor (win)) {
573 remove_task (tsk);
574 add_task (win);
575 if (win == window_get_active ()) {
576 Task *tsk = task_get_task (win);
577 tsk->area.is_active = 1;
578 task_active = tsk;
579 }
580 panel_refresh = 1;
581 }
582 }
583
584
585 void dnd_message(XClientMessageEvent *e)
586 {
587 Panel *panel = get_panel(e->window);
588 int x, y, mapX, mapY;
589 Window child;
590 x = (e->data.l[2] >> 16) & 0xFFFF;
591 y = e->data.l[2] & 0xFFFF;
592 XTranslateCoordinates(server.dsp, server.root_win, e->window, x, y, &mapX, &mapY, &child);
593 Task* task = click_task(panel, mapX, mapY);
594 if (task) {
595 if (task->desktop != server.desktop )
596 set_desktop (task->desktop);
597 window_action(task, TOGGLE);
598 }
599
600 // send XdndStatus event to get more XdndPosition events
601 XClientMessageEvent se;
602 se.type = ClientMessage;
603 se.window = e->data.l[0];
604 se.message_type = server.atom.XdndStatus;
605 se.format = 32;
606 se.data.l[0] = e->window; // XID of the target window
607 se.data.l[1] = 0; // bit 0: accept drop bit 1: send XdndPosition events if inside rectangle
608 se.data.l[2] = 0; // Rectangle x,y for which no more XdndPosition events
609 se.data.l[3] = (1 << 16) | 1; // Rectangle w,h for which no more XdndPosition events
610 se.data.l[4] = None; // None = drop will not be accepted
611 XSendEvent(server.dsp, e->data.l[0], False, NoEventMask, (XEvent*)&se);
612 }
613
614
615 int main (int argc, char *argv[])
616 {
617 XEvent e;
618 fd_set fdset;
619 int x11_fd, i;
620 Panel *panel;
621 GSList *it;
622 GSList* timer_iter;
623 struct timer* timer;
624
625 init (argc, argv);
626
627 i = 0;
628 init_config();
629 if (config_path)
630 i = config_read_file (config_path);
631 else
632 i = config_read ();
633 if (!i) {
634 fprintf(stderr, "usage: tint2 [-c] <config_file>\n");
635 cleanup();
636 exit(1);
637 }
638 init_panel();
639 cleanup_config();
640 if (snapshot_path) {
641 get_snapshot(snapshot_path);
642 cleanup();
643 exit(0);
644 }
645
646 x11_fd = ConnectionNumber(server.dsp);
647 XSync(server.dsp, False);
648
649 sigset_t empty_mask;
650 sigemptyset(&empty_mask);
651
652 while (1) {
653 if (panel_refresh) {
654 panel_refresh = 0;
655
656 if (refresh_systray) {
657 panel = (Panel*)systray.area.panel;
658 XSetWindowBackgroundPixmap (server.dsp, panel->main_win, None);
659 }
660 for (i=0 ; i < nb_panel ; i++) {
661 panel = &panel1[i];
662
663 if (panel->temp_pmap) XFreePixmap(server.dsp, panel->temp_pmap);
664 panel->temp_pmap = XCreatePixmap(server.dsp, server.root_win, panel->area.width, panel->area.height, server.depth);
665
666 refresh(&panel->area);
667 XCopyArea(server.dsp, panel->temp_pmap, panel->main_win, server.gc, 0, 0, panel->area.width, panel->area.height, 0, 0);
668 }
669 XFlush (server.dsp);
670
671 if (refresh_systray) {
672 refresh_systray = 0;
673 panel = (Panel*)systray.area.panel;
674 // tint2 doen't draw systray icons. it just redraw background.
675 XSetWindowBackgroundPixmap (server.dsp, panel->main_win, panel->temp_pmap);
676 // force icon's refresh
677 refresh_systray_icon();
678 }
679 }
680
681 // thanks to AngryLlama for the timer
682 // Create a File Description Set containing x11_fd, and every timer_fd
683 FD_ZERO (&fdset);
684 FD_SET (x11_fd, &fdset);
685 int max_fd = x11_fd;
686 timer_iter = timer_list;
687 while (timer_iter) {
688 timer = timer_iter->data;
689 max_fd = timer->id > max_fd ? timer->id : max_fd;
690 FD_SET(timer->id, &fdset);
691 timer_iter = timer_iter->next;
692 }
693
694 // Wait for X Event or a Timer
695 if (pselect(max_fd+1, &fdset, 0, 0, 0, &empty_mask) > 0) {
696 while (XPending (server.dsp)) {
697 XNextEvent(server.dsp, &e);
698
699 switch (e.type) {
700 case ButtonPress:
701 tooltip_hide();
702 event_button_press (&e);
703 break;
704
705 case ButtonRelease:
706 event_button_release(&e);
707 break;
708
709 case MotionNotify: {
710 if (!g_tooltip.enabled) break;
711 Panel* panel = get_panel(e.xmotion.window);
712 Area* area = click_area(panel, e.xmotion.x, e.xmotion.y);
713 if (area->_get_tooltip_text) {
714 tooltip_trigger_show(area, panel, e.xmotion.x_root, e.xmotion.y_root);
715 }
716 else
717 tooltip_trigger_hide();
718 break;
719 }
720
721 case LeaveNotify:
722 tooltip_trigger_hide();
723 break;
724
725 case Expose:
726 event_expose(&e);
727 break;
728
729 case MapNotify:
730 if (e.xany.window == g_tooltip.window)
731 tooltip_update();
732 break;
733
734 case PropertyNotify:
735 event_property_notify(&e);
736 break;
737
738 case ConfigureNotify:
739 event_configure_notify (e.xconfigure.window);
740 break;
741
742 case ReparentNotify:
743 if (!systray_enabled)
744 break;
745 panel = (Panel*)systray.area.panel;
746 if (e.xany.window == panel->main_win) // reparented to us
747 break;
748 // FIXME: 'reparent to us' badly detected => disabled
749 break;
750 case UnmapNotify:
751 case DestroyNotify:
752 if (e.xany.window == g_tooltip.window || !systray.area.on_screen)
753 break;
754 for (it = systray.list_icons; it; it = g_slist_next(it)) {
755 if (((TrayWindow*)it->data)->id == e.xany.window) {
756 remove_icon((TrayWindow*)it->data);
757 break;
758 }
759 }
760 break;
761
762 case ClientMessage:
763 if (!systray.area.on_screen) break;
764 if (e.xclient.message_type == server.atom._NET_SYSTEM_TRAY_OPCODE && e.xclient.format == 32 && e.xclient.window == net_sel_win) {
765 net_message(&e.xclient);
766 }
767 else if (e.xclient.message_type == server.atom.XdndPosition) {
768 dnd_message(&e.xclient);
769 }
770 break;
771 }
772 }
773
774 // we need to iterate over the whole timer list, since fd_set can only be checked with the
775 // brute force method FD_ISSET for every possible timer
776 timer_iter = timer_list;
777 while (timer_iter) {
778 timer = timer_iter->data;
779 if (FD_ISSET(timer->id, &fdset)) {
780 uint64_t dummy;
781 read(timer->id, &dummy, sizeof(uint64_t));
782 timer->_callback();
783 }
784 timer_iter = timer_iter->next;
785 }
786 }
787
788 switch (signal_pending) {
789 case SIGUSR1: // reload config file
790 signal_pending = 0;
791 init_config();
792 config_read_file (config_path);
793 init_panel();
794 cleanup_config();
795 break;
796 case SIGINT:
797 case SIGTERM:
798 case SIGHUP:
799 cleanup ();
800 return 0;
801 }
802 }
803 }
804
805
This page took 0.069983 seconds and 5 git commands to generate.