]>
Dogcows Code - chaz/tint2/blob - src/tint.c
794aefbefee0ca97efb5ff8f8bfd1ac2a74345c8
1 /**************************************************************************
5 * Copyright (C) 2007 Pål Staurland (staura@gmail.com)
6 * Modified (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr) from Omega distribution
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.
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 **************************************************************************/
27 #include <X11/Xutil.h>
28 #include <X11/Xatom.h>
29 #include <X11/Xlocale.h>
30 #include <X11/extensions/Xdamage.h>
40 #include "systraybar.h"
45 #include "xsettings-client.h"
48 void signal_handler(int sig
)
50 // signal handler is light as it should be
55 void init (int argc
, char *argv
[])
63 memset(&server
, 0, sizeof(Server_global
));
74 for (i
= 1; i
< argc
; ++i
) {
75 if (!strcmp(argv
[i
], "-h") || !strcmp(argv
[i
], "--help")) {
76 printf("Usage: tint2 [-c] <config_file>\n");
79 if (!strcmp(argv
[i
], "-v") || !strcmp(argv
[i
], "--version")) {
80 printf("tint2 version %s\n", VERSION_STRING
);
83 if (!strcmp(argv
[i
], "-c")) {
86 config_path
= strdup(argv
[i
]);
88 if (!strcmp(argv
[i
], "-s")) {
91 snapshot_path
= strdup(argv
[i
]);
96 struct sigaction sa
= { .sa_handler
= signal_handler
};
97 struct sigaction sa_chld
= { .sa_handler
= SIG_DFL
, .sa_flags
= SA_NOCLDWAIT
};
98 sigaction(SIGUSR1
, &sa
, 0);
99 sigaction(SIGINT
, &sa
, 0);
100 sigaction(SIGTERM
, &sa
, 0);
101 sigaction(SIGHUP
, &sa
, 0);
102 sigaction(SIGCHLD
, &sa_chld
, 0);
104 // BSD does not support pselect(), therefore we have to use select and hope that we do not
105 // end up in a race condition there (see 'man select()' on a linux machine for more information)
106 // block all signals, such that no race conditions occur before pselect in our main loop
107 // sigset_t block_mask;
108 // sigaddset(&block_mask, SIGINT);
109 // sigaddset(&block_mask, SIGTERM);
110 // sigaddset(&block_mask, SIGHUP);
111 // sigaddset(&block_mask, SIGUSR1);
112 // sigprocmask(SIG_BLOCK, &block_mask, 0);
117 server
.dsp
= XOpenDisplay (NULL
);
119 fprintf(stderr
, "tint2 exit : could not open display.\n");
122 server_init_atoms ();
123 server
.screen
= DefaultScreen (server
.dsp
);
124 server
.root_win
= RootWindow(server
.dsp
, server
.screen
);
125 server
.desktop
= server_get_current_desktop ();
126 server_init_visual();
127 XSetErrorHandler ((XErrorHandler
) server_catch_error
);
129 imlib_context_set_display (server
.dsp
);
130 imlib_context_set_visual (server
.visual
);
131 imlib_context_set_colormap (server
.colormap
);
134 XSelectInput (server
.dsp
, server
.root_win
, PropertyChangeMask
|StructureNotifyMask
);
136 setlocale (LC_ALL
, "");
137 // config file use '.' as decimal separator
138 setlocale(LC_NUMERIC
, "POSIX");
142 const gchar
* const *data_dirs
;
143 data_dirs
= g_get_system_data_dirs ();
145 for (i
= 0; data_dirs
[i
] != NULL
; i
++) {
146 path
= g_build_filename(data_dirs
[i
], "tint2", "default_icon.png", NULL
);
147 if (g_file_test (path
, G_FILE_TEST_EXISTS
))
148 default_icon
= imlib_load_image(path
);
152 // get monitor and desktop config
164 #ifdef ENABLE_BATTERY
171 imlib_context_set_image(default_icon
);
174 imlib_context_disconnect_display();
178 if (server
.dsp
) XCloseDisplay(server
.dsp
);
182 void get_snapshot(const char *path
)
184 Panel
*panel
= &panel1
[0];
186 if (panel
->area
.width
> server
.monitor
[0].width
)
187 panel
->area
.width
= server
.monitor
[0].width
;
189 panel
->temp_pmap
= XCreatePixmap(server
.dsp
, server
.root_win
, panel
->area
.width
, panel
->area
.height
, server
.depth
);
192 Imlib_Image img
= NULL
;
193 imlib_context_set_drawable(panel
->temp_pmap
);
194 img
= imlib_create_image_from_drawable(0, 0, 0, panel
->area
.width
, panel
->area
.height
, 0);
196 imlib_context_set_image(img
);
197 if (!panel_horizontal
) {
198 // rotate 90° vertical panel
199 imlib_image_flip_horizontal();
200 imlib_image_flip_diagonal();
202 imlib_save_image(path
);
207 void window_action (Task
*tsk
, int action
)
213 set_close (tsk
->win
);
216 set_active(tsk
->win
);
219 XIconifyWindow (server
.dsp
, tsk
->win
, server
.screen
);
222 if (task_active
&& tsk
->win
== task_active
->win
)
223 XIconifyWindow (server
.dsp
, tsk
->win
, server
.screen
);
225 set_active (tsk
->win
);
228 window_toggle_shade (tsk
->win
);
230 case MAXIMIZE_RESTORE
:
231 window_maximize_restore (tsk
->win
);
234 window_maximize_restore (tsk
->win
);
237 window_maximize_restore (tsk
->win
);
240 if ( tsk
->desktop
== 0 ) break;
241 desk
= tsk
->desktop
- 1;
242 windows_set_desktop(tsk
->win
, desk
);
243 if (desk
== server
.desktop
)
244 set_active(tsk
->win
);
247 if (tsk
->desktop
== server
.nb_desktop
) break;
248 desk
= tsk
->desktop
+ 1;
249 windows_set_desktop(tsk
->win
, desk
);
250 if (desk
== server
.desktop
)
251 set_active(tsk
->win
);
256 tsk1
= next_task(task_active
);
257 set_active(tsk1
->win
);
263 tsk1
= prev_task(task_active
);
264 set_active(tsk1
->win
);
270 int tint2_handles_click(Panel
* panel
, XButtonEvent
* e
)
272 Task
* task
= click_task(panel
, e
->x
, e
->y
);
275 || (e
->button
== 2 && mouse_middle
!= 0)
276 || (e
->button
== 3 && mouse_right
!= 0)
277 || (e
->button
== 4 && mouse_scroll_up
!= 0)
278 || (e
->button
== 5 && mouse_scroll_down
!=0) )
285 LauncherIcon
*icon
= click_launcher_icon(panel
, e
->x
, e
->y
);
287 if (e
->button
== 1) {
293 // no launcher/task clicked --> check if taskbar clicked
294 Taskbar
*tskbar
= click_taskbar(panel
, e
->x
, e
->y
);
295 if (tskbar
&& e
->button
== 1 && panel_mode
== MULTI_DESKTOP
)
297 if (click_clock(panel
, e
->x
, e
->y
)) {
298 if ( (e
->button
== 1 && clock_lclick_command
) || (e
->button
== 3 && clock_rclick_command
) )
307 void forward_click(XEvent
* e
)
309 // forward the click to the desktop window (thanks conky)
310 XUngrabPointer(server
.dsp
, e
->xbutton
.time
);
311 e
->xbutton
.window
= server
.root_win
;
312 // icewm doesn't open under the mouse.
313 // and xfce doesn't open at all.
314 e
->xbutton
.x
= e
->xbutton
.x_root
;
315 e
->xbutton
.y
= e
->xbutton
.y_root
;
316 //printf("**** %d, %d\n", e->xbutton.x, e->xbutton.y);
317 //XSetInputFocus(server.dsp, e->xbutton.window, RevertToParent, e->xbutton.time);
318 XSendEvent(server
.dsp
, e
->xbutton
.window
, False
, ButtonPressMask
, e
);
322 void event_button_press (XEvent
*e
)
324 Panel
*panel
= get_panel(e
->xany
.window
);
328 if (wm_menu
&& !tint2_handles_click(panel
, &e
->xbutton
) ) {
332 task_drag
= click_task(panel
, e
->xbutton
.x
, e
->xbutton
.y
);
334 if (panel_layer
== BOTTOM_LAYER
)
335 XLowerWindow (server
.dsp
, panel
->main_win
);
338 void event_button_motion_notify (XEvent
*e
)
340 Panel
* panel
= get_panel(e
->xany
.window
);
341 if(!panel
|| !task_drag
)
344 // Find the taskbar on the event's location
345 Taskbar
* event_taskbar
= click_taskbar(panel
, e
->xbutton
.x
, e
->xbutton
.y
);
346 if(event_taskbar
== NULL
)
349 // Find the task on the event's location
350 Task
* event_task
= click_task(panel
, e
->xbutton
.x
, e
->xbutton
.y
);
352 // If the event takes place on the same taskbar as the task being dragged
353 if(event_taskbar
== task_drag
->area
.parent
) {
354 // Swap the task_drag with the task on the event's location (if they differ)
355 if(event_task
&& event_task
!= task_drag
) {
356 GSList
* drag_iter
= g_slist_find(event_taskbar
->area
.list
, task_drag
);
357 GSList
* task_iter
= g_slist_find(event_taskbar
->area
.list
, event_task
);
358 if(drag_iter
&& task_iter
) {
359 gpointer temp
= task_iter
->data
;
360 task_iter
->data
= drag_iter
->data
;
361 drag_iter
->data
= temp
;
362 event_taskbar
->area
.resize
= 1;
368 else { // The event is on another taskbar than the task being dragged
369 if(task_drag
->desktop
== ALLDESKTOP
|| panel_mode
!= MULTI_DESKTOP
)
372 Taskbar
* drag_taskbar
= (Taskbar
*)task_drag
->area
.parent
;
373 drag_taskbar
->area
.list
= g_slist_remove(drag_taskbar
->area
.list
, task_drag
);
375 if(event_taskbar
->area
.posx
> drag_taskbar
->area
.posx
|| event_taskbar
->area
.posy
> drag_taskbar
->area
.posy
)
376 event_taskbar
->area
.list
= g_slist_prepend(event_taskbar
->area
.list
, task_drag
);
378 event_taskbar
->area
.list
= g_slist_append(event_taskbar
->area
.list
, task_drag
);
380 // Move task to other desktop (but avoid the 'Window desktop changed' code in 'event_property_notify')
381 task_drag
->area
.parent
= event_taskbar
;
382 task_drag
->desktop
= event_taskbar
->desktop
;
384 windows_set_desktop(task_drag
->win
, event_taskbar
->desktop
);
386 event_taskbar
->area
.resize
= 1;
387 drag_taskbar
->area
.resize
= 1;
393 void event_button_release (XEvent
*e
)
395 Panel
*panel
= get_panel(e
->xany
.window
);
398 if (wm_menu
&& !tint2_handles_click(panel
, &e
->xbutton
)) {
400 if (panel_layer
== BOTTOM_LAYER
)
401 XLowerWindow (server
.dsp
, panel
->main_win
);
406 int action
= TOGGLE_ICONIFY
;
407 switch (e
->xbutton
.button
) {
409 action
= mouse_middle
;
412 action
= mouse_right
;
415 action
= mouse_scroll_up
;
418 action
= mouse_scroll_down
;
421 action
= mouse_tilt_left
;
424 action
= mouse_tilt_right
;
428 if ( click_clock(panel
, e
->xbutton
.x
, e
->xbutton
.y
)) {
429 clock_action(e
->xbutton
.button
);
430 if (panel_layer
== BOTTOM_LAYER
)
431 XLowerWindow (server
.dsp
, panel
->main_win
);
436 if ( click_launcher(panel
, e
->xbutton
.x
, e
->xbutton
.y
)) {
437 LauncherIcon
*icon
= click_launcher_icon(panel
, e
->xbutton
.x
, e
->xbutton
.y
);
439 launcher_action(icon
);
446 if ( !(tskbar
= click_taskbar(panel
, e
->xbutton
.x
, e
->xbutton
.y
)) ) {
447 // TODO: check better solution to keep window below
448 if (panel_layer
== BOTTOM_LAYER
)
449 XLowerWindow (server
.dsp
, panel
->main_win
);
454 // drag and drop task
462 if (panel_mode
== MULTI_DESKTOP
) {
463 if (tskbar
->desktop
!= server
.desktop
&& action
!= CLOSE
&& action
!= DESKTOP_LEFT
&& action
!= DESKTOP_RIGHT
)
464 set_desktop (tskbar
->desktop
);
468 window_action( click_task(panel
, e
->xbutton
.x
, e
->xbutton
.y
), action
);
470 // to keep window below
471 if (panel_layer
== BOTTOM_LAYER
)
472 XLowerWindow (server
.dsp
, panel
->main_win
);
476 void event_property_notify (XEvent
*e
)
480 Window win
= e
->xproperty
.window
;
481 Atom at
= e
->xproperty
.atom
;
483 if (win
== server
.root_win
) {
484 if (!server
.got_root_win
) {
485 XSelectInput (server
.dsp
, server
.root_win
, PropertyChangeMask
|StructureNotifyMask
);
486 server
.got_root_win
= 1;
489 // Change name of desktops
490 else if (at
== server
.atom
._NET_DESKTOP_NAMES
) {
491 printf("_NET_DESKTOP_NAMES\n");
494 // Change number of desktops
495 else if (at
== server
.atom
._NET_NUMBER_OF_DESKTOPS
) {
496 if (!taskbar_enabled
) return;
497 server
.nb_desktop
= server_get_number_of_desktop ();
500 for (i
=0 ; i
< nb_panel
; i
++) {
501 init_taskbar_panel(&panel1
[i
]);
502 set_panel_items_order(&panel1
[i
]);
503 visible_taskbar(&panel1
[i
]);
504 panel1
[i
].area
.resize
= 1;
506 task_refresh_tasklist();
511 else if (at
== server
.atom
._NET_CURRENT_DESKTOP
) {
512 if (!taskbar_enabled
) return;
513 int old_desktop
= server
.desktop
;
514 server
.desktop
= server_get_current_desktop ();
515 for (i
=0 ; i
< nb_panel
; i
++) {
516 Panel
*panel
= &panel1
[i
];
517 set_taskbar_state(&panel
->taskbar
[old_desktop
], TASKBAR_NORMAL
);
518 set_taskbar_state(&panel
->taskbar
[server
.desktop
], TASKBAR_ACTIVE
);
519 // check ALLDESKTOP task => resize taskbar
523 if (server
.nb_desktop
> old_desktop
) {
524 tskbar
= &panel
->taskbar
[old_desktop
];
525 for (l
= tskbar
->area
.list
; l
; l
= l
->next
) {
527 if (tsk
->desktop
== ALLDESKTOP
) {
528 tsk
->area
.on_screen
= 0;
529 tskbar
->area
.resize
= 1;
534 tskbar
= &panel
->taskbar
[server
.desktop
];
535 for (l
= tskbar
->area
.list
; l
; l
= l
->next
) {
537 if (tsk
->desktop
== ALLDESKTOP
) {
538 tsk
->area
.on_screen
= 1;
539 tskbar
->area
.resize
= 1;
545 else if (at
== server
.atom
._NET_CLIENT_LIST
) {
546 task_refresh_tasklist();
550 else if (at
== server
.atom
._NET_ACTIVE_WINDOW
) {
554 else if (at
== server
.atom
._XROOTPMAP_ID
) {
556 for (i
=0 ; i
< nb_panel
; i
++) {
557 set_panel_background(&panel1
[i
]);
563 tsk
= task_get_task (win
);
565 if (at
!= server
.atom
._NET_WM_STATE
)
568 // xfce4 sends _NET_WM_STATE after minimized to tray, so we need to check if window is mapped
569 // if it is mapped and not set as skip_taskbar, we must add it to our task list
570 XWindowAttributes wa
;
571 XGetWindowAttributes(server
.dsp
, win
, &wa
);
572 if (wa
.map_state
== IsViewable
&& !window_is_skip_taskbar(win
)) {
573 if ( (tsk
= add_task(win
)) )
582 //printf("atom root_win = %s, %s\n", XGetAtomName(server.dsp, at), tsk->title);
584 // Window title changed
585 if (at
== server
.atom
._NET_WM_VISIBLE_NAME
|| at
== server
.atom
._NET_WM_NAME
|| at
== server
.atom
.WM_NAME
) {
586 if (get_title(tsk
)) {
587 if (g_tooltip
.mapped
&& (g_tooltip
.area
== (Area
*)tsk
)) {
588 tooltip_copy_text((Area
*)tsk
);
595 else if (at
== server
.atom
._NET_WM_STATE
) {
596 if (window_is_urgent (win
)) {
599 if (window_is_skip_taskbar(win
)) {
604 else if (at
== server
.atom
.WM_STATE
) {
606 int state
= (task_active
&& tsk
->win
== task_active
->win
? TASK_ACTIVE
: TASK_NORMAL
);
607 if (window_is_iconified(win
))
608 state
= TASK_ICONIFIED
;
609 set_task_state(tsk
, state
);
612 // Window icon changed
613 else if (at
== server
.atom
._NET_WM_ICON
) {
617 // Window desktop changed
618 else if (at
== server
.atom
._NET_WM_DESKTOP
) {
619 int desktop
= window_get_desktop (win
);
620 //printf(" Window desktop changed %d, %d\n", tsk->desktop, desktop);
621 // bug in windowmaker : send unecessary 'desktop changed' when focus changed
622 if (desktop
!= tsk
->desktop
) {
624 tsk
= add_task (win
);
629 else if (at
== server
.atom
.WM_HINTS
) {
630 XWMHints
* wmhints
= XGetWMHints(server
.dsp
, win
);
631 if (wmhints
&& wmhints
->flags
& XUrgencyHint
) {
637 if (!server
.got_root_win
) server
.root_win
= RootWindow (server
.dsp
, server
.screen
);
642 void event_expose (XEvent
*e
)
645 panel
= get_panel(e
->xany
.window
);
647 // TODO : one panel_refresh per panel ?
652 void event_configure_notify (Window win
)
654 // change in root window (xrandr)
655 if (win
== server
.root_win
) {
656 signal_pending
= SIGUSR1
;
660 // 'win' is a trayer icon
663 for (l
= systray
.list_icons
; l
; l
= l
->next
) {
664 traywin
= (TrayWindow
*)l
->data
;
665 if (traywin
->tray_id
== win
) {
666 //printf("move tray %d\n", traywin->x);
667 XMoveResizeWindow(server
.dsp
, traywin
->id
, traywin
->x
, traywin
->y
, traywin
->width
, traywin
->height
);
668 XResizeWindow(server
.dsp
, traywin
->tray_id
, traywin
->width
, traywin
->height
);
674 // 'win' move in another monitor
675 if (nb_panel
== 1) return;
676 Task
*tsk
= task_get_task (win
);
679 Panel
*p
= tsk
->area
.panel
;
680 if (p
->monitor
!= window_get_monitor (win
)) {
682 tsk
= add_task (win
);
683 if (win
== window_get_active ()) {
684 set_task_state(tsk
, TASK_ACTIVE
);
692 void dnd_message(XClientMessageEvent
*e
)
694 Panel
*panel
= get_panel(e
->window
);
695 int x
, y
, mapX
, mapY
;
697 x
= (e
->data
.l
[2] >> 16) & 0xFFFF;
698 y
= e
->data
.l
[2] & 0xFFFF;
699 XTranslateCoordinates(server
.dsp
, server
.root_win
, e
->window
, x
, y
, &mapX
, &mapY
, &child
);
700 Task
* task
= click_task(panel
, mapX
, mapY
);
702 if (task
->desktop
!= server
.desktop
)
703 set_desktop (task
->desktop
);
704 window_action(task
, TOGGLE
);
707 // send XdndStatus event to get more XdndPosition events
708 XClientMessageEvent se
;
709 se
.type
= ClientMessage
;
710 se
.window
= e
->data
.l
[0];
711 se
.message_type
= server
.atom
.XdndStatus
;
713 se
.data
.l
[0] = e
->window
; // XID of the target window
714 se
.data
.l
[1] = 0; // bit 0: accept drop bit 1: send XdndPosition events if inside rectangle
715 se
.data
.l
[2] = 0; // Rectangle x,y for which no more XdndPosition events
716 se
.data
.l
[3] = (1 << 16) | 1; // Rectangle w,h for which no more XdndPosition events
717 se
.data
.l
[4] = None
; // None = drop will not be accepted
718 XSendEvent(server
.dsp
, e
->data
.l
[0], False
, NoEventMask
, (XEvent
*)&se
);
722 int main (int argc
, char *argv
[])
725 XClientMessageEvent
*ev
;
730 struct timeval
* timeout
;
739 i
= config_read_file (config_path
);
743 fprintf(stderr
, "usage: tint2 [-c] <config_file>\n");
750 get_snapshot(snapshot_path
);
755 int damage_event
, damage_error
;
756 XDamageQueryExtension(server
.dsp
, &damage_event
, &damage_error
);
757 x11_fd
= ConnectionNumber(server
.dsp
);
758 XSync(server
.dsp
, False
);
760 // sigset_t empty_mask;
761 // sigemptyset(&empty_mask);
767 for (i
=0 ; i
< nb_panel
; i
++) {
770 if (panel
->is_hidden
) {
771 XCopyArea(server
.dsp
, panel
->hidden_pixmap
, panel
->main_win
, server
.gc
, 0, 0, panel
->hidden_width
, panel
->hidden_height
, 0, 0);
772 XSetWindowBackgroundPixmap(server
.dsp
, panel
->main_win
, panel
->hidden_pixmap
);
775 if (panel
->temp_pmap
) XFreePixmap(server
.dsp
, panel
->temp_pmap
);
776 panel
->temp_pmap
= XCreatePixmap(server
.dsp
, server
.root_win
, panel
->area
.width
, panel
->area
.height
, server
.depth
);
778 XCopyArea(server
.dsp
, panel
->temp_pmap
, panel
->main_win
, server
.gc
, 0, 0, panel
->area
.width
, panel
->area
.height
, 0, 0);
783 panel
= (Panel
*)systray
.area
.panel
;
784 if (refresh_systray
&& panel
&& !panel
->is_hidden
) {
786 // tint2 doen't draw systray icons. it just redraw background.
787 XSetWindowBackgroundPixmap (server
.dsp
, panel
->main_win
, panel
->temp_pmap
);
788 // force icon's refresh
789 refresh_systray_icon();
793 // thanks to AngryLlama for the timer
794 // Create a File Description Set containing x11_fd
796 FD_SET (x11_fd
, &fdset
);
797 update_next_timeout();
798 if (next_timeout
.tv_sec
>= 0 && next_timeout
.tv_usec
>= 0)
799 timeout
= &next_timeout
;
803 // Wait for X Event or a Timer
804 if (select(x11_fd
+1, &fdset
, 0, 0, timeout
) > 0) {
805 while (XPending (server
.dsp
)) {
806 XNextEvent(server
.dsp
, &e
);
807 if (xsettings_client
!= NULL
) {
808 xsettings_client_process_event(xsettings_client
, &e
);
811 panel
= get_panel(e
.xany
.window
);
812 if (panel
&& panel_autohide
) {
813 if (e
.type
== EnterNotify
)
814 autohide_trigger_show(panel
);
815 else if (e
.type
== LeaveNotify
)
816 autohide_trigger_hide(panel
);
817 if (panel
->is_hidden
) {
818 if (e
.type
== ClientMessage
&& e
.xclient
.message_type
== server
.atom
.XdndPosition
) {
820 autohide_show(panel
);
823 continue; // discard further processing of this event because the panel is not visible yet
825 else if (hidden_dnd
&& e
.type
== ClientMessage
&& e
.xclient
.message_type
== server
.atom
.XdndLeave
) {
827 autohide_hide(panel
);
834 event_button_press (&e
);
838 event_button_release(&e
);
842 unsigned int button_mask
= Button1Mask
| Button2Mask
| Button3Mask
| Button4Mask
| Button5Mask
;
843 if (e
.xmotion
.state
& button_mask
)
844 event_button_motion_notify (&e
);
846 if (!g_tooltip
.enabled
) break;
847 Panel
* panel
= get_panel(e
.xmotion
.window
);
848 Area
* area
= click_area(panel
, e
.xmotion
.x
, e
.xmotion
.y
);
849 if (area
->_get_tooltip_text
)
850 tooltip_trigger_show(area
, panel
, &e
);
852 tooltip_trigger_hide();
857 if (g_tooltip
.enabled
)
858 tooltip_trigger_hide();
866 event_property_notify(&e
);
869 case ConfigureNotify
:
870 event_configure_notify (e
.xconfigure
.window
);
874 if (!systray_enabled
)
876 panel
= (Panel
*)systray
.area
.panel
;
877 if (e
.xany
.window
== panel
->main_win
) // reparented to us
879 // FIXME: 'reparent to us' badly detected => disabled
883 if (e
.xany
.window
== server
.composite_manager
) {
884 // Stop real_transparency
885 signal_pending
= SIGUSR1
;
888 if (e
.xany
.window
== g_tooltip
.window
|| !systray_enabled
)
890 for (it
= systray
.list_icons
; it
; it
= g_slist_next(it
)) {
891 if (((TrayWindow
*)it
->data
)->tray_id
== e
.xany
.window
) {
892 remove_icon((TrayWindow
*)it
->data
);
900 if (ev
->data
.l
[1] == server
.atom
._NET_WM_CM_S0
) {
901 if (ev
->data
.l
[2] == None
)
902 // Stop real_transparency
903 signal_pending
= SIGUSR1
;
905 // Start real_transparency
906 signal_pending
= SIGUSR1
;
908 if (systray_enabled
&& e
.xclient
.message_type
== server
.atom
._NET_SYSTEM_TRAY_OPCODE
&& e
.xclient
.format
== 32 && e
.xclient
.window
== net_sel_win
) {
909 net_message(&e
.xclient
);
911 else if (e
.xclient
.message_type
== server
.atom
.XdndPosition
) {
912 dnd_message(&e
.xclient
);
917 if (e
.type
== XDamageNotify
+damage_event
) {
918 // union needed to avoid strict-aliasing warnings by gcc
919 union { XEvent e
; XDamageNotifyEvent de
; } event_union
= {.e
=e
};
922 XDamageNotifyEvent
* de
= &event_union
.de
;
923 for (l
= systray
.list_icons
; l
; l
= l
->next
) {
924 traywin
= (TrayWindow
*)l
->data
;
925 if ( traywin
->id
== de
->drawable
) {
926 systray_render_icon(traywin
);
935 callback_timeout_expired();
937 if (signal_pending
) {
939 if (signal_pending
== SIGUSR1
) {
941 // SIGUSR1 used when : user's signal, composite manager stop/start or xrandr
942 FD_CLR (x11_fd
, &fdset
); // not sure if needed
946 // SIGINT, SIGTERM, SIGHUP
This page took 0.068081 seconds and 3 git commands to generate.