]>
Dogcows Code - chaz/tint2/blob - src/tint.c
db4095985ffa2668afdf23ec237e8b55b13c1d47
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 int i
= (taskbarname_enabled
) ? 1 : 0;
377 event_taskbar
->area
.list
= g_slist_insert(event_taskbar
->area
.list
, task_drag
, i
);
380 event_taskbar
->area
.list
= g_slist_append(event_taskbar
->area
.list
, task_drag
);
382 // Move task to other desktop (but avoid the 'Window desktop changed' code in 'event_property_notify')
383 task_drag
->area
.parent
= event_taskbar
;
384 task_drag
->desktop
= event_taskbar
->desktop
;
386 windows_set_desktop(task_drag
->win
, event_taskbar
->desktop
);
388 event_taskbar
->area
.resize
= 1;
389 drag_taskbar
->area
.resize
= 1;
395 void event_button_release (XEvent
*e
)
397 Panel
*panel
= get_panel(e
->xany
.window
);
400 if (wm_menu
&& !tint2_handles_click(panel
, &e
->xbutton
)) {
402 if (panel_layer
== BOTTOM_LAYER
)
403 XLowerWindow (server
.dsp
, panel
->main_win
);
408 int action
= TOGGLE_ICONIFY
;
409 switch (e
->xbutton
.button
) {
411 action
= mouse_middle
;
414 action
= mouse_right
;
417 action
= mouse_scroll_up
;
420 action
= mouse_scroll_down
;
423 action
= mouse_tilt_left
;
426 action
= mouse_tilt_right
;
430 if ( click_clock(panel
, e
->xbutton
.x
, e
->xbutton
.y
)) {
431 clock_action(e
->xbutton
.button
);
432 if (panel_layer
== BOTTOM_LAYER
)
433 XLowerWindow (server
.dsp
, panel
->main_win
);
438 if ( click_launcher(panel
, e
->xbutton
.x
, e
->xbutton
.y
)) {
439 LauncherIcon
*icon
= click_launcher_icon(panel
, e
->xbutton
.x
, e
->xbutton
.y
);
441 launcher_action(icon
);
448 if ( !(tskbar
= click_taskbar(panel
, e
->xbutton
.x
, e
->xbutton
.y
)) ) {
449 // TODO: check better solution to keep window below
450 if (panel_layer
== BOTTOM_LAYER
)
451 XLowerWindow (server
.dsp
, panel
->main_win
);
456 // drag and drop task
464 if (panel_mode
== MULTI_DESKTOP
) {
465 if (tskbar
->desktop
!= server
.desktop
&& action
!= CLOSE
&& action
!= DESKTOP_LEFT
&& action
!= DESKTOP_RIGHT
)
466 set_desktop (tskbar
->desktop
);
470 window_action( click_task(panel
, e
->xbutton
.x
, e
->xbutton
.y
), action
);
472 // to keep window below
473 if (panel_layer
== BOTTOM_LAYER
)
474 XLowerWindow (server
.dsp
, panel
->main_win
);
478 void event_property_notify (XEvent
*e
)
482 Window win
= e
->xproperty
.window
;
483 Atom at
= e
->xproperty
.atom
;
485 if (xsettings_client
)
486 xsettings_client_process_event(xsettings_client
, e
);
487 if (win
== server
.root_win
) {
488 if (!server
.got_root_win
) {
489 XSelectInput (server
.dsp
, server
.root_win
, PropertyChangeMask
|StructureNotifyMask
);
490 server
.got_root_win
= 1;
493 // Change name of desktops
494 else if (at
== server
.atom
._NET_DESKTOP_NAMES
) {
495 if (!taskbarname_enabled
) return;
496 GSList
*l
, *list
= server_get_name_of_desktop();
500 for (i
=0 ; i
< nb_panel
; i
++) {
501 for (j
=0, l
=list
; j
< panel1
[i
].nb_desktop
; j
++) {
503 name
= g_strdup(l
->data
);
507 name
= g_strdup_printf("%d", j
+1);
508 tskbar
= &panel1
[i
].taskbar
[j
];
509 if (strcmp(name
, tskbar
->bar_name
.name
) != 0) {
510 g_free(tskbar
->bar_name
.name
);
511 tskbar
->bar_name
.name
= name
;
512 tskbar
->bar_name
.area
.resize
= 1;
518 for (l
=list
; l
; l
= l
->next
)
523 // Change number of desktops
524 else if (at
== server
.atom
._NET_NUMBER_OF_DESKTOPS
) {
525 if (!taskbar_enabled
) return;
526 server
.nb_desktop
= server_get_number_of_desktop ();
529 for (i
=0 ; i
< nb_panel
; i
++) {
530 init_taskbar_panel(&panel1
[i
]);
531 set_panel_items_order(&panel1
[i
]);
532 visible_taskbar(&panel1
[i
]);
533 panel1
[i
].area
.resize
= 1;
535 task_refresh_tasklist();
540 else if (at
== server
.atom
._NET_CURRENT_DESKTOP
) {
541 if (!taskbar_enabled
) return;
542 int old_desktop
= server
.desktop
;
543 server
.desktop
= server_get_current_desktop ();
544 for (i
=0 ; i
< nb_panel
; i
++) {
545 Panel
*panel
= &panel1
[i
];
546 set_taskbar_state(&panel
->taskbar
[old_desktop
], TASKBAR_NORMAL
);
547 set_taskbar_state(&panel
->taskbar
[server
.desktop
], TASKBAR_ACTIVE
);
548 // check ALLDESKTOP task => resize taskbar
552 if (server
.nb_desktop
> old_desktop
) {
553 tskbar
= &panel
->taskbar
[old_desktop
];
554 l
= tskbar
->area
.list
;
555 if (taskbarname_enabled
) l
= l
->next
;
556 for (; l
; l
= l
->next
) {
558 if (tsk
->desktop
== ALLDESKTOP
) {
559 tsk
->area
.on_screen
= 0;
560 tskbar
->area
.resize
= 1;
565 tskbar
= &panel
->taskbar
[server
.desktop
];
566 l
= tskbar
->area
.list
;
567 if (taskbarname_enabled
) l
= l
->next
;
568 for (; l
; l
= l
->next
) {
570 if (tsk
->desktop
== ALLDESKTOP
) {
571 tsk
->area
.on_screen
= 1;
572 tskbar
->area
.resize
= 1;
578 else if (at
== server
.atom
._NET_CLIENT_LIST
) {
579 task_refresh_tasklist();
583 else if (at
== server
.atom
._NET_ACTIVE_WINDOW
) {
587 else if (at
== server
.atom
._XROOTPMAP_ID
) {
589 for (i
=0 ; i
< nb_panel
; i
++) {
590 set_panel_background(&panel1
[i
]);
596 tsk
= task_get_task (win
);
598 if (at
!= server
.atom
._NET_WM_STATE
)
601 // xfce4 sends _NET_WM_STATE after minimized to tray, so we need to check if window is mapped
602 // if it is mapped and not set as skip_taskbar, we must add it to our task list
603 XWindowAttributes wa
;
604 XGetWindowAttributes(server
.dsp
, win
, &wa
);
605 if (wa
.map_state
== IsViewable
&& !window_is_skip_taskbar(win
)) {
606 if ( (tsk
= add_task(win
)) )
615 //printf("atom root_win = %s, %s\n", XGetAtomName(server.dsp, at), tsk->title);
617 // Window title changed
618 if (at
== server
.atom
._NET_WM_VISIBLE_NAME
|| at
== server
.atom
._NET_WM_NAME
|| at
== server
.atom
.WM_NAME
) {
619 if (get_title(tsk
)) {
620 if (g_tooltip
.mapped
&& (g_tooltip
.area
== (Area
*)tsk
)) {
621 tooltip_copy_text((Area
*)tsk
);
628 else if (at
== server
.atom
._NET_WM_STATE
) {
629 if (window_is_urgent (win
)) {
632 if (window_is_skip_taskbar(win
)) {
637 else if (at
== server
.atom
.WM_STATE
) {
639 int state
= (task_active
&& tsk
->win
== task_active
->win
? TASK_ACTIVE
: TASK_NORMAL
);
640 if (window_is_iconified(win
))
641 state
= TASK_ICONIFIED
;
642 set_task_state(tsk
, state
);
645 // Window icon changed
646 else if (at
== server
.atom
._NET_WM_ICON
) {
650 // Window desktop changed
651 else if (at
== server
.atom
._NET_WM_DESKTOP
) {
652 int desktop
= window_get_desktop (win
);
653 //printf(" Window desktop changed %d, %d\n", tsk->desktop, desktop);
654 // bug in windowmaker : send unecessary 'desktop changed' when focus changed
655 if (desktop
!= tsk
->desktop
) {
657 tsk
= add_task (win
);
662 else if (at
== server
.atom
.WM_HINTS
) {
663 XWMHints
* wmhints
= XGetWMHints(server
.dsp
, win
);
664 if (wmhints
&& wmhints
->flags
& XUrgencyHint
) {
670 if (!server
.got_root_win
) server
.root_win
= RootWindow (server
.dsp
, server
.screen
);
675 void event_expose (XEvent
*e
)
678 panel
= get_panel(e
->xany
.window
);
680 // TODO : one panel_refresh per panel ?
685 void event_configure_notify (Window win
)
687 // change in root window (xrandr)
688 if (win
== server
.root_win
) {
689 signal_pending
= SIGUSR1
;
693 // 'win' is a trayer icon
696 for (l
= systray
.list_icons
; l
; l
= l
->next
) {
697 traywin
= (TrayWindow
*)l
->data
;
698 if (traywin
->tray_id
== win
) {
699 //printf("move tray %d\n", traywin->x);
700 XMoveResizeWindow(server
.dsp
, traywin
->id
, traywin
->x
, traywin
->y
, traywin
->width
, traywin
->height
);
701 XResizeWindow(server
.dsp
, traywin
->tray_id
, traywin
->width
, traywin
->height
);
707 // 'win' move in another monitor
708 if (nb_panel
== 1) return;
709 Task
*tsk
= task_get_task (win
);
712 Panel
*p
= tsk
->area
.panel
;
713 if (p
->monitor
!= window_get_monitor (win
)) {
715 tsk
= add_task (win
);
716 if (win
== window_get_active ()) {
717 set_task_state(tsk
, TASK_ACTIVE
);
725 void dnd_message(XClientMessageEvent
*e
)
727 Panel
*panel
= get_panel(e
->window
);
728 int x
, y
, mapX
, mapY
;
730 x
= (e
->data
.l
[2] >> 16) & 0xFFFF;
731 y
= e
->data
.l
[2] & 0xFFFF;
732 XTranslateCoordinates(server
.dsp
, server
.root_win
, e
->window
, x
, y
, &mapX
, &mapY
, &child
);
733 Task
* task
= click_task(panel
, mapX
, mapY
);
735 if (task
->desktop
!= server
.desktop
)
736 set_desktop (task
->desktop
);
737 window_action(task
, TOGGLE
);
740 // send XdndStatus event to get more XdndPosition events
741 XClientMessageEvent se
;
742 se
.type
= ClientMessage
;
743 se
.window
= e
->data
.l
[0];
744 se
.message_type
= server
.atom
.XdndStatus
;
746 se
.data
.l
[0] = e
->window
; // XID of the target window
747 se
.data
.l
[1] = 0; // bit 0: accept drop bit 1: send XdndPosition events if inside rectangle
748 se
.data
.l
[2] = 0; // Rectangle x,y for which no more XdndPosition events
749 se
.data
.l
[3] = (1 << 16) | 1; // Rectangle w,h for which no more XdndPosition events
750 se
.data
.l
[4] = None
; // None = drop will not be accepted
751 XSendEvent(server
.dsp
, e
->data
.l
[0], False
, NoEventMask
, (XEvent
*)&se
);
755 int main (int argc
, char *argv
[])
758 XClientMessageEvent
*ev
;
763 struct timeval
* timeout
;
772 i
= config_read_file (config_path
);
776 fprintf(stderr
, "usage: tint2 [-c] <config_file>\n");
783 get_snapshot(snapshot_path
);
788 int damage_event
, damage_error
;
789 XDamageQueryExtension(server
.dsp
, &damage_event
, &damage_error
);
790 x11_fd
= ConnectionNumber(server
.dsp
);
791 XSync(server
.dsp
, False
);
793 // sigset_t empty_mask;
794 // sigemptyset(&empty_mask);
800 for (i
=0 ; i
< nb_panel
; i
++) {
803 if (panel
->is_hidden
) {
804 XCopyArea(server
.dsp
, panel
->hidden_pixmap
, panel
->main_win
, server
.gc
, 0, 0, panel
->hidden_width
, panel
->hidden_height
, 0, 0);
805 XSetWindowBackgroundPixmap(server
.dsp
, panel
->main_win
, panel
->hidden_pixmap
);
808 if (panel
->temp_pmap
) XFreePixmap(server
.dsp
, panel
->temp_pmap
);
809 panel
->temp_pmap
= XCreatePixmap(server
.dsp
, server
.root_win
, panel
->area
.width
, panel
->area
.height
, server
.depth
);
811 XCopyArea(server
.dsp
, panel
->temp_pmap
, panel
->main_win
, server
.gc
, 0, 0, panel
->area
.width
, panel
->area
.height
, 0, 0);
816 panel
= (Panel
*)systray
.area
.panel
;
817 if (refresh_systray
&& panel
&& !panel
->is_hidden
) {
819 // tint2 doen't draw systray icons. it just redraw background.
820 XSetWindowBackgroundPixmap (server
.dsp
, panel
->main_win
, panel
->temp_pmap
);
821 // force icon's refresh
822 refresh_systray_icon();
826 // thanks to AngryLlama for the timer
827 // Create a File Description Set containing x11_fd
829 FD_SET (x11_fd
, &fdset
);
830 update_next_timeout();
831 if (next_timeout
.tv_sec
>= 0 && next_timeout
.tv_usec
>= 0)
832 timeout
= &next_timeout
;
836 // Wait for X Event or a Timer
837 if (select(x11_fd
+1, &fdset
, 0, 0, timeout
) > 0) {
838 while (XPending (server
.dsp
)) {
839 XNextEvent(server
.dsp
, &e
);
841 panel
= get_panel(e
.xany
.window
);
842 if (panel
&& panel_autohide
) {
843 if (e
.type
== EnterNotify
)
844 autohide_trigger_show(panel
);
845 else if (e
.type
== LeaveNotify
)
846 autohide_trigger_hide(panel
);
847 if (panel
->is_hidden
) {
848 if (e
.type
== ClientMessage
&& e
.xclient
.message_type
== server
.atom
.XdndPosition
) {
850 autohide_show(panel
);
853 continue; // discard further processing of this event because the panel is not visible yet
855 else if (hidden_dnd
&& e
.type
== ClientMessage
&& e
.xclient
.message_type
== server
.atom
.XdndLeave
) {
857 autohide_hide(panel
);
864 event_button_press (&e
);
868 event_button_release(&e
);
872 unsigned int button_mask
= Button1Mask
| Button2Mask
| Button3Mask
| Button4Mask
| Button5Mask
;
873 if (e
.xmotion
.state
& button_mask
)
874 event_button_motion_notify (&e
);
876 if (!g_tooltip
.enabled
) break;
877 Panel
* panel
= get_panel(e
.xmotion
.window
);
878 Area
* area
= click_area(panel
, e
.xmotion
.x
, e
.xmotion
.y
);
879 if (area
->_get_tooltip_text
)
880 tooltip_trigger_show(area
, panel
, &e
);
882 tooltip_trigger_hide();
887 if (g_tooltip
.enabled
)
888 tooltip_trigger_hide();
896 event_property_notify(&e
);
899 case ConfigureNotify
:
900 event_configure_notify (e
.xconfigure
.window
);
904 if (!systray_enabled
)
906 panel
= (Panel
*)systray
.area
.panel
;
907 if (e
.xany
.window
== panel
->main_win
) // reparented to us
909 // FIXME: 'reparent to us' badly detected => disabled
913 if (e
.xany
.window
== server
.composite_manager
) {
914 // Stop real_transparency
915 signal_pending
= SIGUSR1
;
918 if (e
.xany
.window
== g_tooltip
.window
|| !systray_enabled
)
920 for (it
= systray
.list_icons
; it
; it
= g_slist_next(it
)) {
921 if (((TrayWindow
*)it
->data
)->tray_id
== e
.xany
.window
) {
922 remove_icon((TrayWindow
*)it
->data
);
930 if (ev
->data
.l
[1] == server
.atom
._NET_WM_CM_S0
) {
931 if (ev
->data
.l
[2] == None
)
932 // Stop real_transparency
933 signal_pending
= SIGUSR1
;
935 // Start real_transparency
936 signal_pending
= SIGUSR1
;
938 if (systray_enabled
&& e
.xclient
.message_type
== server
.atom
._NET_SYSTEM_TRAY_OPCODE
&& e
.xclient
.format
== 32 && e
.xclient
.window
== net_sel_win
) {
939 net_message(&e
.xclient
);
941 else if (e
.xclient
.message_type
== server
.atom
.XdndPosition
) {
942 dnd_message(&e
.xclient
);
947 if (e
.type
== XDamageNotify
+damage_event
) {
948 // union needed to avoid strict-aliasing warnings by gcc
949 union { XEvent e
; XDamageNotifyEvent de
; } event_union
= {.e
=e
};
952 XDamageNotifyEvent
* de
= &event_union
.de
;
953 for (l
= systray
.list_icons
; l
; l
= l
->next
) {
954 traywin
= (TrayWindow
*)l
->data
;
955 if ( traywin
->id
== de
->drawable
) {
956 systray_render_icon(traywin
);
965 callback_timeout_expired();
967 if (signal_pending
) {
969 if (signal_pending
== SIGUSR1
) {
971 // SIGUSR1 used when : user's signal, composite manager stop/start or xrandr
972 FD_CLR (x11_fd
, &fdset
); // not sure if needed
976 // SIGINT, SIGTERM, SIGHUP
This page took 0.080065 seconds and 4 git commands to generate.