]>
Dogcows Code - chaz/tint2/blob - src/tint.c
1 /**************************************************************************
5 * Copyright (C) 2007 Pål Staurland (staura@gmail.com)
6 * Modified (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr)
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"
47 void signal_handler(int sig
)
49 // signal handler is light as it should be
54 void init (int argc
, char *argv
[])
62 memset(&server
, 0, sizeof(Server_global
));
73 for (i
= 1; i
< argc
; ++i
) {
74 if (!strcmp(argv
[i
], "-h") || !strcmp(argv
[i
], "--help")) {
75 printf("Usage: tint2 [-c] <config_file>\n");
78 if (!strcmp(argv
[i
], "-v") || !strcmp(argv
[i
], "--version")) {
79 printf("tint2 version %s\n", VERSION_STRING
);
82 if (!strcmp(argv
[i
], "-c")) {
85 config_path
= strdup(argv
[i
]);
87 if (!strcmp(argv
[i
], "-s")) {
90 snapshot_path
= strdup(argv
[i
]);
95 struct sigaction sa
= { .sa_handler
= signal_handler
};
96 struct sigaction sa_chld
= { .sa_handler
= SIG_DFL
, .sa_flags
= SA_NOCLDWAIT
};
97 sigaction(SIGUSR1
, &sa
, 0);
98 sigaction(SIGINT
, &sa
, 0);
99 sigaction(SIGTERM
, &sa
, 0);
100 sigaction(SIGHUP
, &sa
, 0);
101 sigaction(SIGCHLD
, &sa_chld
, 0);
103 // BSD does not support pselect(), therefore we have to use select and hope that we do not
104 // end up in a race condition there (see 'man select()' on a linux machine for more information)
105 // block all signals, such that no race conditions occur before pselect in our main loop
106 // sigset_t block_mask;
107 // sigaddset(&block_mask, SIGINT);
108 // sigaddset(&block_mask, SIGTERM);
109 // sigaddset(&block_mask, SIGHUP);
110 // sigaddset(&block_mask, SIGUSR1);
111 // sigprocmask(SIG_BLOCK, &block_mask, 0);
116 server
.dsp
= XOpenDisplay (NULL
);
118 fprintf(stderr
, "tint2 exit : could not open display.\n");
121 server_init_atoms ();
122 server
.screen
= DefaultScreen (server
.dsp
);
123 server
.root_win
= RootWindow(server
.dsp
, server
.screen
);
124 server
.desktop
= server_get_current_desktop ();
125 server_init_visual();
126 XSetErrorHandler ((XErrorHandler
) server_catch_error
);
128 imlib_context_set_display (server
.dsp
);
129 imlib_context_set_visual (server
.visual
);
130 imlib_context_set_colormap (server
.colormap
);
133 XSelectInput (server
.dsp
, server
.root_win
, PropertyChangeMask
|StructureNotifyMask
);
135 setlocale (LC_ALL
, "");
136 // config file use '.' as decimal separator
137 setlocale(LC_NUMERIC
, "POSIX");
141 const gchar
* const *data_dirs
;
142 data_dirs
= g_get_system_data_dirs ();
144 for (i
= 0; data_dirs
[i
] != NULL
; i
++) {
145 path
= g_build_filename(data_dirs
[i
], "tint2", "default_icon.png", NULL
);
146 if (g_file_test (path
, G_FILE_TEST_EXISTS
))
147 default_icon
= imlib_load_image(path
);
151 // get monitor and desktop config
165 #ifdef ENABLE_BATTERY
171 imlib_context_set_image(default_icon
);
174 imlib_context_disconnect_display();
177 if (server
.dsp
) XCloseDisplay(server
.dsp
);
181 void get_snapshot(const char *path
)
183 Panel
*panel
= &panel1
[0];
185 if (panel
->area
.width
> server
.monitor
[0].width
)
186 panel
->area
.width
= server
.monitor
[0].width
;
188 panel
->temp_pmap
= XCreatePixmap(server
.dsp
, server
.root_win
, panel
->area
.width
, panel
->area
.height
, server
.depth
);
189 size_by_content(&panel
->area
);
190 size_by_layout(&panel
->area
);
191 refresh(&panel
->area
);
193 Imlib_Image img
= NULL
;
194 imlib_context_set_drawable(panel
->temp_pmap
);
195 img
= imlib_create_image_from_drawable(0, 0, 0, panel
->area
.width
, panel
->area
.height
, 0);
197 imlib_context_set_image(img
);
198 if (!panel_horizontal
) {
199 // rotate 90° vertical panel
200 imlib_image_flip_horizontal();
201 imlib_image_flip_diagonal();
203 imlib_save_image(path
);
208 void window_action (Task
*tsk
, int action
)
214 set_close (tsk
->win
);
217 set_active(tsk
->win
);
220 XIconifyWindow (server
.dsp
, tsk
->win
, server
.screen
);
223 if (task_active
&& tsk
->win
== task_active
->win
)
224 XIconifyWindow (server
.dsp
, tsk
->win
, server
.screen
);
226 set_active (tsk
->win
);
229 window_toggle_shade (tsk
->win
);
231 case MAXIMIZE_RESTORE
:
232 window_maximize_restore (tsk
->win
);
235 window_maximize_restore (tsk
->win
);
238 window_maximize_restore (tsk
->win
);
241 if ( tsk
->desktop
== 0 ) break;
242 desk
= tsk
->desktop
- 1;
243 windows_set_desktop(tsk
->win
, desk
);
244 if (desk
== server
.desktop
)
245 set_active(tsk
->win
);
248 if (tsk
->desktop
== server
.nb_desktop
) break;
249 desk
= tsk
->desktop
+ 1;
250 windows_set_desktop(tsk
->win
, desk
);
251 if (desk
== server
.desktop
)
252 set_active(tsk
->win
);
257 tsk1
= next_task(task_active
);
258 set_active(tsk1
->win
);
264 tsk1
= prev_task(task_active
);
265 set_active(tsk1
->win
);
271 int tint2_handles_click(Panel
* panel
, XButtonEvent
* e
)
273 Task
* task
= click_task(panel
, e
->x
, e
->y
);
276 || (e
->button
== 2 && mouse_middle
!= 0)
277 || (e
->button
== 3 && mouse_right
!= 0)
278 || (e
->button
== 4 && mouse_scroll_up
!= 0)
279 || (e
->button
== 5 && mouse_scroll_down
!=0) )
286 LauncherIcon
*icon
= click_launcher_icon(panel
, e
->x
, e
->y
);
288 if (e
->button
== 1) {
294 // no launcher/task clicked --> check if taskbar clicked
295 Taskbar
*tskbar
= click_taskbar(panel
, e
->x
, e
->y
);
296 if (tskbar
&& e
->button
== 1 && panel_mode
== MULTI_DESKTOP
)
298 if (click_clock(panel
, e
->x
, e
->y
)) {
299 if ( (e
->button
== 1 && clock_lclick_command
) || (e
->button
== 3 && clock_rclick_command
) )
308 void forward_click(XEvent
* e
)
310 // forward the click to the desktop window (thanks conky)
311 XUngrabPointer(server
.dsp
, e
->xbutton
.time
);
312 e
->xbutton
.window
= server
.root_win
;
313 // icewm doesn't open under the mouse.
314 // and xfce doesn't open at all.
315 e
->xbutton
.x
= e
->xbutton
.x_root
;
316 e
->xbutton
.y
= e
->xbutton
.y_root
;
317 //printf("**** %d, %d\n", e->xbutton.x, e->xbutton.y);
318 //XSetInputFocus(server.dsp, e->xbutton.window, RevertToParent, e->xbutton.time);
319 XSendEvent(server
.dsp
, e
->xbutton
.window
, False
, ButtonPressMask
, e
);
323 void event_button_press (XEvent
*e
)
325 Panel
*panel
= get_panel(e
->xany
.window
);
329 if (wm_menu
&& !tint2_handles_click(panel
, &e
->xbutton
) ) {
333 task_drag
= click_task(panel
, e
->xbutton
.x
, e
->xbutton
.y
);
335 if (panel_layer
== BOTTOM_LAYER
)
336 XLowerWindow (server
.dsp
, panel
->main_win
);
339 void event_button_motion_notify (XEvent
*e
)
341 Panel
* panel
= get_panel(e
->xany
.window
);
342 if(!panel
|| !task_drag
)
345 // Find the taskbar on the event's location
346 Taskbar
* event_taskbar
= click_taskbar(panel
, e
->xbutton
.x
, e
->xbutton
.y
);
347 if(event_taskbar
== NULL
)
350 // Find the task on the event's location
351 Task
* event_task
= click_task(panel
, e
->xbutton
.x
, e
->xbutton
.y
);
353 // If the event takes place on the same taskbar as the task being dragged
354 if(event_taskbar
== task_drag
->area
.parent
) {
355 // Swap the task_drag with the task on the event's location (if they differ)
356 if(event_task
&& event_task
!= task_drag
) {
357 GSList
* drag_iter
= g_slist_find(event_taskbar
->area
.list
, task_drag
);
358 GSList
* task_iter
= g_slist_find(event_taskbar
->area
.list
, event_task
);
359 if(drag_iter
&& task_iter
) {
360 gpointer temp
= task_iter
->data
;
361 task_iter
->data
= drag_iter
->data
;
362 drag_iter
->data
= temp
;
363 event_taskbar
->area
.resize
= 1;
369 else { // The event is on another taskbar than the task being dragged
370 if(task_drag
->desktop
== ALLDESKTOP
|| panel_mode
!= MULTI_DESKTOP
)
373 Taskbar
* drag_taskbar
= (Taskbar
*)task_drag
->area
.parent
;
374 drag_taskbar
->area
.list
= g_slist_remove(drag_taskbar
->area
.list
, task_drag
);
376 if(event_taskbar
->area
.posx
> drag_taskbar
->area
.posx
|| event_taskbar
->area
.posy
> drag_taskbar
->area
.posy
)
377 event_taskbar
->area
.list
= g_slist_prepend(event_taskbar
->area
.list
, task_drag
);
379 event_taskbar
->area
.list
= g_slist_append(event_taskbar
->area
.list
, task_drag
);
381 // Move task to other desktop (but avoid the 'Window desktop changed' code in 'event_property_notify')
382 task_drag
->area
.parent
= event_taskbar
;
383 task_drag
->desktop
= event_taskbar
->desktop
;
385 windows_set_desktop(task_drag
->win
, event_taskbar
->desktop
);
387 event_taskbar
->area
.resize
= 1;
388 drag_taskbar
->area
.resize
= 1;
394 void event_button_release (XEvent
*e
)
396 Panel
*panel
= get_panel(e
->xany
.window
);
399 if (wm_menu
&& !tint2_handles_click(panel
, &e
->xbutton
)) {
401 if (panel_layer
== BOTTOM_LAYER
)
402 XLowerWindow (server
.dsp
, panel
->main_win
);
407 int action
= TOGGLE_ICONIFY
;
408 switch (e
->xbutton
.button
) {
410 action
= mouse_middle
;
413 action
= mouse_right
;
416 action
= mouse_scroll_up
;
419 action
= mouse_scroll_down
;
422 action
= mouse_tilt_left
;
425 action
= mouse_tilt_right
;
429 if ( click_clock(panel
, e
->xbutton
.x
, e
->xbutton
.y
)) {
430 clock_action(e
->xbutton
.button
);
431 if (panel_layer
== BOTTOM_LAYER
)
432 XLowerWindow (server
.dsp
, panel
->main_win
);
437 if ( click_launcher(panel
, e
->xbutton
.x
, e
->xbutton
.y
)) {
438 LauncherIcon
*icon
= click_launcher_icon(panel
, e
->xbutton
.x
, e
->xbutton
.y
);
440 launcher_action(icon
);
447 if ( !(tskbar
= click_taskbar(panel
, e
->xbutton
.x
, e
->xbutton
.y
)) ) {
448 // TODO: check better solution to keep window below
449 if (panel_layer
== BOTTOM_LAYER
)
450 XLowerWindow (server
.dsp
, panel
->main_win
);
455 // drag and drop task
463 if (panel_mode
== MULTI_DESKTOP
) {
464 if (tskbar
->desktop
!= server
.desktop
&& action
!= CLOSE
&& action
!= DESKTOP_LEFT
&& action
!= DESKTOP_RIGHT
)
465 set_desktop (tskbar
->desktop
);
469 window_action( click_task(panel
, e
->xbutton
.x
, e
->xbutton
.y
), action
);
471 // to keep window below
472 if (panel_layer
== BOTTOM_LAYER
)
473 XLowerWindow (server
.dsp
, panel
->main_win
);
477 void event_property_notify (XEvent
*e
)
481 Window win
= e
->xproperty
.window
;
482 Atom at
= e
->xproperty
.atom
;
484 if (win
== server
.root_win
) {
485 if (!server
.got_root_win
) {
486 XSelectInput (server
.dsp
, server
.root_win
, PropertyChangeMask
|StructureNotifyMask
);
487 server
.got_root_win
= 1;
490 // Change number of desktops
491 else if (at
== server
.atom
._NET_NUMBER_OF_DESKTOPS
) {
492 server
.nb_desktop
= server_get_number_of_desktop ();
496 for (i
=0 ; i
< nb_panel
; i
++) {
497 panel1
[i
].area
.resize
= 1;
499 task_refresh_tasklist();
504 else if (at
== server
.atom
._NET_CURRENT_DESKTOP
) {
505 int old_desktop
= server
.desktop
;
506 server
.desktop
= server_get_current_desktop ();
507 for (i
=0 ; i
< nb_panel
; i
++) {
508 Panel
*panel
= &panel1
[i
];
509 if (panel_mode
== MULTI_DESKTOP
&& panel
->g_taskbar
.use_active
) {
510 // redraw both taskbar
511 if (server
.nb_desktop
> old_desktop
) {
512 // can happen if last desktop is deleted and we've been on the last desktop
513 panel
->taskbar
[old_desktop
].area
.bg
= panel
->g_taskbar
.bg
;
514 panel
->taskbar
[old_desktop
].area
.resize
= 1;
516 panel
->taskbar
[server
.desktop
].area
.bg
= panel
->g_taskbar
.bg_active
;
517 panel
->taskbar
[server
.desktop
].area
.resize
= 1;
520 // check ALLDESKTOP task => resize taskbar
524 if (server
.nb_desktop
> old_desktop
) {
525 tskbar
= &panel
->taskbar
[old_desktop
];
526 for (l
= tskbar
->area
.list
; l
; l
= l
->next
) {
528 if (tsk
->desktop
== ALLDESKTOP
) {
529 tsk
->area
.on_screen
= 0;
530 tskbar
->area
.resize
= 1;
535 tskbar
= &panel
->taskbar
[server
.desktop
];
536 for (l
= tskbar
->area
.list
; l
; l
= l
->next
) {
538 if (tsk
->desktop
== ALLDESKTOP
) {
539 tsk
->area
.on_screen
= 1;
540 tskbar
->area
.resize
= 1;
544 if (panel_mode
!= MULTI_DESKTOP
) {
549 else if (at
== server
.atom
._NET_CLIENT_LIST
) {
550 task_refresh_tasklist();
554 else if (at
== server
.atom
._NET_ACTIVE_WINDOW
) {
558 else if (at
== server
.atom
._XROOTPMAP_ID
) {
560 for (i
=0 ; i
< nb_panel
; i
++) {
561 set_panel_background(&panel1
[i
]);
567 tsk
= task_get_task (win
);
569 if (at
!= server
.atom
._NET_WM_STATE
)
572 // xfce4 sends _NET_WM_STATE after minimized to tray, so we need to check if window is mapped
573 // if it is mapped and not set as skip_taskbar, we must add it to our task list
574 XWindowAttributes wa
;
575 XGetWindowAttributes(server
.dsp
, win
, &wa
);
576 if (wa
.map_state
== IsViewable
&& !window_is_skip_taskbar(win
)) {
577 if ( (tsk
= add_task(win
)) )
586 //printf("atom root_win = %s, %s\n", XGetAtomName(server.dsp, at), tsk->title);
588 // Window title changed
589 if (at
== server
.atom
._NET_WM_VISIBLE_NAME
|| at
== server
.atom
._NET_WM_NAME
|| at
== server
.atom
.WM_NAME
) {
591 if (g_tooltip
.mapped
&& (g_tooltip
.area
== (Area
*)tsk
)) {
592 tooltip_copy_text((Area
*)tsk
);
598 else if (at
== server
.atom
._NET_WM_STATE
) {
599 if (window_is_urgent (win
)) {
602 if (window_is_skip_taskbar(win
)) {
607 else if (at
== server
.atom
.WM_STATE
) {
609 int state
= (task_active
&& tsk
->win
== task_active
->win
? TASK_ACTIVE
: TASK_NORMAL
);
610 if (window_is_iconified(win
))
611 state
= TASK_ICONIFIED
;
612 set_task_state(tsk
, state
);
615 // Window icon changed
616 else if (at
== server
.atom
._NET_WM_ICON
) {
620 // Window desktop changed
621 else if (at
== server
.atom
._NET_WM_DESKTOP
) {
622 int desktop
= window_get_desktop (win
);
623 //printf(" Window desktop changed %d, %d\n", tsk->desktop, desktop);
624 // bug in windowmaker : send unecessary 'desktop changed' when focus changed
625 if (desktop
!= tsk
->desktop
) {
627 tsk
= add_task (win
);
632 else if (at
== server
.atom
.WM_HINTS
) {
633 XWMHints
* wmhints
= XGetWMHints(server
.dsp
, win
);
634 if (wmhints
&& wmhints
->flags
& XUrgencyHint
) {
640 if (!server
.got_root_win
) server
.root_win
= RootWindow (server
.dsp
, server
.screen
);
645 void event_expose (XEvent
*e
)
648 panel
= get_panel(e
->xany
.window
);
650 // TODO : one panel_refresh per panel ?
655 void event_configure_notify (Window win
)
657 // change in root window (xrandr)
658 if (win
== server
.root_win
) {
659 signal_pending
= SIGUSR1
;
663 // 'win' is a trayer icon
666 for (l
= systray
.list_icons
; l
; l
= l
->next
) {
667 traywin
= (TrayWindow
*)l
->data
;
668 if (traywin
->tray_id
== win
) {
669 //printf("move tray %d\n", traywin->x);
670 XMoveResizeWindow(server
.dsp
, traywin
->id
, traywin
->x
, traywin
->y
, traywin
->width
, traywin
->height
);
671 XResizeWindow(server
.dsp
, traywin
->tray_id
, traywin
->width
, traywin
->height
);
677 // 'win' move in another monitor
678 if (nb_panel
== 1) return;
679 Task
*tsk
= task_get_task (win
);
682 Panel
*p
= tsk
->area
.panel
;
683 if (p
->monitor
!= window_get_monitor (win
)) {
685 tsk
= add_task (win
);
686 if (win
== window_get_active ()) {
687 set_task_state(tsk
, TASK_ACTIVE
);
695 void dnd_message(XClientMessageEvent
*e
)
697 Panel
*panel
= get_panel(e
->window
);
698 int x
, y
, mapX
, mapY
;
700 x
= (e
->data
.l
[2] >> 16) & 0xFFFF;
701 y
= e
->data
.l
[2] & 0xFFFF;
702 XTranslateCoordinates(server
.dsp
, server
.root_win
, e
->window
, x
, y
, &mapX
, &mapY
, &child
);
703 Task
* task
= click_task(panel
, mapX
, mapY
);
705 if (task
->desktop
!= server
.desktop
)
706 set_desktop (task
->desktop
);
707 window_action(task
, TOGGLE
);
710 // send XdndStatus event to get more XdndPosition events
711 XClientMessageEvent se
;
712 se
.type
= ClientMessage
;
713 se
.window
= e
->data
.l
[0];
714 se
.message_type
= server
.atom
.XdndStatus
;
716 se
.data
.l
[0] = e
->window
; // XID of the target window
717 se
.data
.l
[1] = 0; // bit 0: accept drop bit 1: send XdndPosition events if inside rectangle
718 se
.data
.l
[2] = 0; // Rectangle x,y for which no more XdndPosition events
719 se
.data
.l
[3] = (1 << 16) | 1; // Rectangle w,h for which no more XdndPosition events
720 se
.data
.l
[4] = None
; // None = drop will not be accepted
721 XSendEvent(server
.dsp
, e
->data
.l
[0], False
, NoEventMask
, (XEvent
*)&se
);
725 int main (int argc
, char *argv
[])
728 XClientMessageEvent
*ev
;
733 struct timeval
* timeout
;
742 i
= config_read_file (config_path
);
746 fprintf(stderr
, "usage: tint2 [-c] <config_file>\n");
753 get_snapshot(snapshot_path
);
758 int damage_event
, damage_error
;
759 XDamageQueryExtension(server
.dsp
, &damage_event
, &damage_error
);
760 x11_fd
= ConnectionNumber(server
.dsp
);
761 XSync(server
.dsp
, False
);
763 // sigset_t empty_mask;
764 // sigemptyset(&empty_mask);
770 for (i
=0 ; i
< nb_panel
; i
++) {
773 if (panel
->is_hidden
) {
774 XCopyArea(server
.dsp
, panel
->hidden_pixmap
, panel
->main_win
, server
.gc
, 0, 0, panel
->hidden_width
, panel
->hidden_height
, 0, 0);
775 XSetWindowBackgroundPixmap(server
.dsp
, panel
->main_win
, panel
->hidden_pixmap
);
778 if (panel
->temp_pmap
) XFreePixmap(server
.dsp
, panel
->temp_pmap
);
779 panel
->temp_pmap
= XCreatePixmap(server
.dsp
, server
.root_win
, panel
->area
.width
, panel
->area
.height
, server
.depth
);
780 size_by_content(&panel
->area
);
781 size_by_layout(&panel
->area
);
782 refresh(&panel
->area
);
783 XCopyArea(server
.dsp
, panel
->temp_pmap
, panel
->main_win
, server
.gc
, 0, 0, panel
->area
.width
, panel
->area
.height
, 0, 0);
788 panel
= (Panel
*)systray
.area
.panel
;
789 if (refresh_systray
&& panel
&& !panel
->is_hidden
) {
791 // tint2 doen't draw systray icons. it just redraw background.
792 XSetWindowBackgroundPixmap (server
.dsp
, panel
->main_win
, panel
->temp_pmap
);
793 // force icon's refresh
794 refresh_systray_icon();
798 // thanks to AngryLlama for the timer
799 // Create a File Description Set containing x11_fd
801 FD_SET (x11_fd
, &fdset
);
802 update_next_timeout();
803 if (next_timeout
.tv_sec
>= 0 && next_timeout
.tv_usec
>= 0)
804 timeout
= &next_timeout
;
808 // Wait for X Event or a Timer
809 if (select(x11_fd
+1, &fdset
, 0, 0, timeout
) > 0) {
810 while (XPending (server
.dsp
)) {
811 XNextEvent(server
.dsp
, &e
);
813 panel
= get_panel(e
.xany
.window
);
814 if (panel
&& panel_autohide
) {
815 if (e
.type
== EnterNotify
)
816 autohide_trigger_show(panel
);
817 else if (e
.type
== LeaveNotify
)
818 autohide_trigger_hide(panel
);
819 if (panel
->is_hidden
) {
820 if (e
.type
== ClientMessage
&& e
.xclient
.message_type
== server
.atom
.XdndPosition
) {
822 autohide_show(panel
);
825 continue; // discard further processing of this event because the panel is not visible yet
827 else if (hidden_dnd
&& e
.type
== ClientMessage
&& e
.xclient
.message_type
== server
.atom
.XdndLeave
) {
829 autohide_hide(panel
);
836 event_button_press (&e
);
840 event_button_release(&e
);
844 unsigned int button_mask
= Button1Mask
| Button2Mask
| Button3Mask
| Button4Mask
| Button5Mask
;
845 if (e
.xmotion
.state
& button_mask
)
846 event_button_motion_notify (&e
);
848 if (!g_tooltip
.enabled
) break;
849 Panel
* panel
= get_panel(e
.xmotion
.window
);
850 Area
* area
= click_area(panel
, e
.xmotion
.x
, e
.xmotion
.y
);
851 if (area
->_get_tooltip_text
)
852 tooltip_trigger_show(area
, panel
, &e
);
854 tooltip_trigger_hide();
859 if (g_tooltip
.enabled
)
860 tooltip_trigger_hide();
868 event_property_notify(&e
);
871 case ConfigureNotify
:
872 event_configure_notify (e
.xconfigure
.window
);
876 if (!systray_enabled
)
878 panel
= (Panel
*)systray
.area
.panel
;
879 if (e
.xany
.window
== panel
->main_win
) // reparented to us
881 // FIXME: 'reparent to us' badly detected => disabled
885 if (e
.xany
.window
== server
.composite_manager
) {
886 // Stop real_transparency
887 signal_pending
= SIGUSR1
;
890 if (e
.xany
.window
== g_tooltip
.window
|| !systray
.area
.on_screen
)
892 for (it
= systray
.list_icons
; it
; it
= g_slist_next(it
)) {
893 if (((TrayWindow
*)it
->data
)->tray_id
== e
.xany
.window
) {
894 remove_icon((TrayWindow
*)it
->data
);
902 if (ev
->data
.l
[1] == server
.atom
._NET_WM_CM_S0
) {
903 if (ev
->data
.l
[2] == None
)
904 // Stop real_transparency
905 signal_pending
= SIGUSR1
;
907 // Start real_transparency
908 signal_pending
= SIGUSR1
;
910 if (systray
.area
.on_screen
&& e
.xclient
.message_type
== server
.atom
._NET_SYSTEM_TRAY_OPCODE
&& e
.xclient
.format
== 32 && e
.xclient
.window
== net_sel_win
) {
911 net_message(&e
.xclient
);
913 else if (e
.xclient
.message_type
== server
.atom
.XdndPosition
) {
914 dnd_message(&e
.xclient
);
919 if (e
.type
== XDamageNotify
+damage_event
) {
920 // union needed to avoid strict-aliasing warnings by gcc
921 union { XEvent e
; XDamageNotifyEvent de
; } event_union
= {.e
=e
};
924 XDamageNotifyEvent
* de
= &event_union
.de
;
925 for (l
= systray
.list_icons
; l
; l
= l
->next
) {
926 traywin
= (TrayWindow
*)l
->data
;
927 if ( traywin
->id
== de
->drawable
) {
928 systray_render_icon(traywin
);
937 callback_timeout_expired();
939 if (signal_pending
) {
941 if (signal_pending
== SIGUSR1
) {
943 // SIGUSR1 used when : user's signal, composite manager stop/start or xrandr
944 FD_CLR (x11_fd
, &fdset
); // not sure if needed
948 // SIGINT, SIGTERM, SIGHUP
This page took 0.097156 seconds and 4 git commands to generate.