1 /**************************************************************************
3 * Copyright (C) 2008 Pål Staurland (staura@gmail.com)
4 * Modified (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version 2
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 **************************************************************************/
23 #include <X11/Xutil.h>
24 #include <X11/Xatom.h>
26 #include <cairo-xlib.h>
27 #include <pango/pangocairo.h>
37 // --------------------------------------------------
42 int mouse_scroll_down
;
48 int panel_dock
=0; // default not in the dock
49 int panel_layer
=BOTTOM_LAYER
; // default is bottom layer
54 int panel_autohide
= 0;
55 int panel_autohide_show_timeout
= 0;
56 int panel_autohide_hide_timeout
= 0;
57 int panel_autohide_height
= 5; // for vertical panels this is of course the width
58 int panel_strut_policy
= STRUT_MINIMUM
;
64 // panel's initial config
66 // panels (one panel per monitor)
70 GArray
* backgrounds
= 0;
72 Imlib_Image default_icon
= NULL
;
75 void autohide_hide(void* p
);
76 void autohide_show(void* p
);
84 if (panel_config
.monitor
> (server
.nb_monitor
-1)) {
85 // server.nb_monitor minimum value is 1 (see get_monitors())
86 fprintf(stderr
, "warning : monitor not found. tint2 default to all monitors.\n");
87 panel_config
.monitor
= 0;
98 for (i
=0 ; i
< nb_panel
; i
++) {
99 free_area(&panel1
[i
].area
);
100 if (panel1
[i
].temp_pmap
) {
101 XFreePixmap(server
.dsp
, panel1
[i
].temp_pmap
);
102 panel1
[i
].temp_pmap
= 0;
107 old_nb_panel
= nb_panel
;
108 if (panel_config
.monitor
>= 0)
111 nb_panel
= server
.nb_monitor
;
114 for (i
=nb_panel
; i
< old_nb_panel
; i
++) {
115 if (panel1
[i
].main_win
) {
116 XDestroyWindow(server
.dsp
, panel1
[i
].main_win
);
117 panel1
[i
].main_win
= 0;
121 // alloc & init new panel
123 if (nb_panel
!= old_nb_panel
)
124 new_panel
= realloc(panel1
, nb_panel
* sizeof(Panel
));
127 for (i
=0 ; i
< nb_panel
; i
++) {
128 old_win
= new_panel
[i
].main_win
;
129 memcpy(&new_panel
[i
], &panel_config
, sizeof(Panel
));
130 new_panel
[i
].main_win
= old_win
;
133 fprintf(stderr
, "tint2 : nb monitor %d, nb monitor used %d, nb desktop %d\n", server
.nb_monitor
, nb_panel
, server
.nb_desktop
);
134 for (i
=0 ; i
< nb_panel
; i
++) {
137 if (panel_config
.monitor
< 0)
141 p
->area
.on_screen
= 1;
143 p
->area
._resize
= resize_panel
;
144 p
->g_taskbar
.area
.parent
= p
;
145 p
->g_taskbar
.area
.panel
= p
;
146 p
->g_task
.area
.panel
= p
;
147 init_panel_size_and_position(p
);
151 p
->area
.list
= g_slist_append(p
->area
.list
, &p
->clock
);
153 #ifdef ENABLE_BATTERY
154 if (battery_enabled
) {
155 init_battery_panel(p
);
156 p
->area
.list
= g_slist_append(p
->area
.list
, &p
->battery
);
159 // systray only on first panel
160 if (systray
.area
.on_screen
&& i
== 0) {
161 init_systray_panel(p
);
162 p
->area
.list
= g_slist_append(p
->area
.list
, &systray
);
166 if (i
>= old_nb_panel
) {
167 // new panel : catch some events
168 long event_mask
= ExposureMask
|ButtonPressMask
|ButtonReleaseMask
;
169 if (g_tooltip
.enabled
)
170 event_mask
|= PointerMotionMask
|LeaveWindowMask
;
172 event_mask
|= LeaveWindowMask
|EnterWindowMask
;
173 XSetWindowAttributes att
= { .event_mask
=event_mask
, .colormap
=server
.colormap
, .background_pixel
=0, .border_pixel
=0 };
174 unsigned long mask
= CWEventMask
|CWColormap
|CWBackPixel
|CWBorderPixel
;
175 p
->main_win
= XCreateWindow(server
.dsp
, server
.root_win
, p
->posx
, p
->posy
, p
->area
.width
, p
->area
.height
, 0, server
.depth
, InputOutput
, server
.visual
, mask
, &att
);
179 XMoveResizeWindow(server
.dsp
, p
->main_win
, p
->posx
, p
->posy
, p
->area
.width
, p
->area
.height
);
184 server
.gc
= XCreateGC(server
.dsp
, p
->main_win
, 0, &gcv
);
186 //printf("panel %d : %d, %d, %d, %d\n", i, p->posx, p->posy, p->area.width, p->area.height);
187 set_panel_properties(p
);
188 set_panel_background(p
);
189 if (i
>= old_nb_panel
) {
191 XMapWindow (server
.dsp
, p
->main_win
);
195 add_timeout(panel_autohide_hide_timeout
, 0, autohide_hide
, p
);
202 task_refresh_tasklist();
207 void init_panel_size_and_position(Panel
*panel
)
210 if (panel_horizontal
) {
211 if (panel
->pourcentx
)
212 panel
->area
.width
= (float)server
.monitor
[panel
->monitor
].width
* panel
->area
.width
/ 100;
213 if (panel
->pourcenty
)
214 panel
->area
.height
= (float)server
.monitor
[panel
->monitor
].height
* panel
->area
.height
/ 100;
215 if (panel
->area
.bg
->border
.rounded
> panel
->area
.height
/2) {
216 printf("panel_background_id rounded is too big... please fix your tint2rc\n");
217 g_array_append_val(backgrounds
, *panel
->area
.bg
);
218 panel
->area
.bg
= &g_array_index(backgrounds
, Background
, backgrounds
->len
-1);
219 panel
->area
.bg
->border
.rounded
= panel
->area
.height
/2;
223 int old_panel_height
= panel
->area
.height
;
224 if (panel
->pourcentx
)
225 panel
->area
.height
= (float)server
.monitor
[panel
->monitor
].height
* panel
->area
.width
/ 100;
227 panel
->area
.height
= panel
->area
.width
;
228 if (panel
->pourcenty
)
229 panel
->area
.width
= (float)server
.monitor
[panel
->monitor
].width
* old_panel_height
/ 100;
231 panel
->area
.width
= old_panel_height
;
232 if (panel
->area
.bg
->border
.rounded
> panel
->area
.width
/2) {
233 printf("panel_background_id rounded is too big... please fix your tint2rc\n");
234 g_array_append_val(backgrounds
, *panel
->area
.bg
);
235 panel
->area
.bg
= &g_array_index(backgrounds
, Background
, backgrounds
->len
-1);
236 panel
->area
.bg
->border
.rounded
= panel
->area
.width
/2;
240 // panel position determined here
241 if (panel_position
& LEFT
) {
242 panel
->posx
= server
.monitor
[panel
->monitor
].x
+ panel
->marginx
;
245 if (panel_position
& RIGHT
) {
246 panel
->posx
= server
.monitor
[panel
->monitor
].x
+ server
.monitor
[panel
->monitor
].width
- panel
->area
.width
- panel
->marginx
;
249 if (panel_horizontal
)
250 panel
->posx
= server
.monitor
[panel
->monitor
].x
+ ((server
.monitor
[panel
->monitor
].width
- panel
->area
.width
) / 2);
252 panel
->posx
= server
.monitor
[panel
->monitor
].x
+ panel
->marginx
;
255 if (panel_position
& TOP
) {
256 panel
->posy
= server
.monitor
[panel
->monitor
].y
+ panel
->marginy
;
259 if (panel_position
& BOTTOM
) {
260 panel
->posy
= server
.monitor
[panel
->monitor
].y
+ server
.monitor
[panel
->monitor
].height
- panel
->area
.height
- panel
->marginy
;
263 panel
->posy
= server
.monitor
[panel
->monitor
].y
+ ((server
.monitor
[panel
->monitor
].height
- panel
->area
.height
) / 2);
267 if (panel_autohide
) {
268 int diff
= (panel_horizontal
? panel
->area
.height
: panel
->area
.width
) - panel_autohide_height
;
269 if (panel_horizontal
) {
270 panel
->hidden_width
= panel
->area
.width
;
271 panel
->hidden_height
= panel
->area
.height
- diff
;
274 panel
->hidden_width
= panel
->area
.width
- diff
;
275 panel
->hidden_height
= panel
->area
.height
;
278 // printf("panel : posx %d, posy %d, width %d, height %d\n", panel->posx, panel->posy, panel->area.width, panel->area.height);
293 for (i
=0 ; i
< nb_panel
; i
++) {
299 XFreePixmap(server
.dsp
, p
->temp_pmap
);
302 if (p
->hidden_pixmap
)
303 XFreePixmap(server
.dsp
, p
->hidden_pixmap
);
304 p
->hidden_pixmap
= 0;
306 XDestroyWindow(server
.dsp
, p
->main_win
);
317 if (panel_config
.g_task
.font_desc
) {
318 pango_font_description_free(panel_config
.g_task
.font_desc
);
319 panel_config
.g_task
.font_desc
= 0;
324 void resize_panel(void *obj
)
326 Panel
*panel
= (Panel
*)obj
;
328 if (panel_horizontal
) {
329 int taskbar_width
, modulo_width
= 0;
331 taskbar_width
= panel
->area
.width
- (2 * panel
->area
.paddingxlr
) - (2 * panel
->area
.bg
->border
.width
);
332 if (panel
->clock
.area
.on_screen
&& panel
->clock
.area
.width
)
333 taskbar_width
-= (panel
->clock
.area
.width
+ panel
->area
.paddingx
);
334 #ifdef ENABLE_BATTERY
335 if (panel
->battery
.area
.on_screen
&& panel
->battery
.area
.width
)
336 taskbar_width
-= (panel
->battery
.area
.width
+ panel
->area
.paddingx
);
338 // TODO : systray only on first panel. search better implementation !
339 if (systray
.area
.on_screen
&& systray
.area
.width
&& panel
== &panel1
[0])
340 taskbar_width
-= (systray
.area
.width
+ panel
->area
.paddingx
);
342 if (panel_mode
== MULTI_DESKTOP
) {
343 int width
= taskbar_width
- ((panel
->nb_desktop
-1) * panel
->area
.paddingx
);
344 taskbar_width
= width
/ panel
->nb_desktop
;
345 modulo_width
= width
% panel
->nb_desktop
;
348 // change posx and width for all taskbar
350 posx
= panel
->area
.bg
->border
.width
+ panel
->area
.paddingxlr
;
351 for (i
=0 ; i
< panel
->nb_desktop
; i
++) {
352 panel
->taskbar
[i
].area
.posx
= posx
;
353 panel
->taskbar
[i
].area
.width
= taskbar_width
;
354 panel
->taskbar
[i
].area
.resize
= 1;
356 panel
->taskbar
[i
].area
.width
++;
359 //printf("taskbar %d : posx %d, width, %d, posy %d\n", i, posx, panel->taskbar[i].area.width, posx + panel->taskbar[i].area.width);
360 if (panel_mode
== MULTI_DESKTOP
)
361 posx
+= panel
->taskbar
[i
].area
.width
+ panel
->area
.paddingx
;
365 int taskbar_height
, modulo_height
= 0;
368 taskbar_height
= panel
->area
.height
- (2 * panel
->area
.paddingxlr
) - (2 * panel
->area
.bg
->border
.width
);
369 if (panel
->clock
.area
.on_screen
&& panel
->clock
.area
.height
)
370 taskbar_height
-= (panel
->clock
.area
.height
+ panel
->area
.paddingx
);
371 #ifdef ENABLE_BATTERY
372 if (panel
->battery
.area
.on_screen
&& panel
->battery
.area
.height
)
373 taskbar_height
-= (panel
->battery
.area
.height
+ panel
->area
.paddingx
);
375 // TODO : systray only on first panel. search better implementation !
376 if (systray
.area
.on_screen
&& systray
.area
.height
&& panel
== &panel1
[0])
377 taskbar_height
-= (systray
.area
.height
+ panel
->area
.paddingx
);
379 posy
= panel
->area
.height
- panel
->area
.bg
->border
.width
- panel
->area
.paddingxlr
- taskbar_height
;
380 if (panel_mode
== MULTI_DESKTOP
) {
381 int height
= taskbar_height
- ((panel
->nb_desktop
-1) * panel
->area
.paddingx
);
382 taskbar_height
= height
/ panel
->nb_desktop
;
383 modulo_height
= height
% panel
->nb_desktop
;
386 // change posy and height for all taskbar
387 for (i
=0 ; i
< panel
->nb_desktop
; i
++) {
388 panel
->taskbar
[i
].area
.posy
= posy
;
389 panel
->taskbar
[i
].area
.height
= taskbar_height
;
390 panel
->taskbar
[i
].area
.resize
= 1;
392 panel
->taskbar
[i
].area
.height
++;
395 if (panel_mode
== MULTI_DESKTOP
)
396 posy
+= panel
->taskbar
[i
].area
.height
+ panel
->area
.paddingx
;
402 void visible_object()
407 for (i
=0 ; i
< nb_panel
; i
++) {
411 for (j
=0 ; j
< panel
->nb_desktop
; j
++) {
412 taskbar
= &panel
->taskbar
[j
];
413 if (panel_mode
!= MULTI_DESKTOP
&& taskbar
->desktop
!= server
.desktop
) {
414 // SINGLE_DESKTOP and not current desktop
415 taskbar
->area
.on_screen
= 0;
418 taskbar
->area
.on_screen
= 1;
425 void update_strut(Panel
* p
)
428 unsigned int d1
, screen_width
, screen_height
;
431 XGetGeometry(server
.dsp
, server
.root_win
, &d2
, &d3
, &d3
, &screen_width
, &screen_height
, &d1
, &d1
);
432 Monitor monitor
= server
.monitor
[p
->monitor
];
433 long struts
[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
434 if (panel_horizontal
) {
435 int height
= p
->area
.height
+ p
->marginy
;
436 if (panel_autohide
&& (panel_strut_policy
== STRUT_MINIMUM
|| (panel_strut_policy
== STRUT_FOLLOW_SIZE
&& p
->is_hidden
)) )
437 height
= p
->hidden_height
;
438 if (panel_position
& TOP
) {
439 struts
[2] = height
+ monitor
.y
;
441 // p->area.width - 1 allowed full screen on monitor 2
442 struts
[9] = p
->posx
+ p
->area
.width
- 1;
445 struts
[3] = height
+ screen_height
- monitor
.y
- monitor
.height
;
446 struts
[10] = p
->posx
;
447 // p->area.width - 1 allowed full screen on monitor 2
448 struts
[11] = p
->posx
+ p
->area
.width
- 1;
452 int width
= p
->area
.width
+ p
->marginx
;
453 if (panel_autohide
&& (panel_strut_policy
== STRUT_MINIMUM
|| (panel_strut_policy
== STRUT_FOLLOW_SIZE
&& p
->is_hidden
)) )
454 width
= p
->hidden_width
;
455 if (panel_position
& LEFT
) {
456 struts
[0] = width
+ monitor
.x
;
458 // p->area.width - 1 allowed full screen on monitor 2
459 struts
[5] = p
->posy
+ p
->area
.height
- 1;
462 struts
[1] = width
+ screen_width
- monitor
.x
- monitor
.width
;
464 // p->area.width - 1 allowed full screen on monitor 2
465 struts
[7] = p
->posy
+ p
->area
.height
- 1;
468 // Old specification : fluxbox need _NET_WM_STRUT.
469 XChangeProperty (server
.dsp
, p
->main_win
, server
.atom
._NET_WM_STRUT
, XA_CARDINAL
, 32, PropModeReplace
, (unsigned char *) &struts
, 4);
470 XChangeProperty (server
.dsp
, p
->main_win
, server
.atom
._NET_WM_STRUT_PARTIAL
, XA_CARDINAL
, 32, PropModeReplace
, (unsigned char *) &struts
, 12);
474 void set_panel_properties(Panel
*p
)
476 XStoreName (server
.dsp
, p
->main_win
, "tint2");
479 gchar
*name
= g_locale_to_utf8("tint2", -1, NULL
, &len
, NULL
);
481 XChangeProperty(server
.dsp
, p
->main_win
, server
.atom
._NET_WM_NAME
, server
.atom
.UTF8_STRING
, 8, PropModeReplace
, (unsigned char *) name
, (int) len
);
486 long val
= server
.atom
._NET_WM_WINDOW_TYPE_DOCK
;
487 XChangeProperty (server
.dsp
, p
->main_win
, server
.atom
._NET_WM_WINDOW_TYPE
, XA_ATOM
, 32, PropModeReplace
, (unsigned char *) &val
, 1);
489 // Sticky and below other window
491 XChangeProperty (server
.dsp
, p
->main_win
, server
.atom
._NET_WM_DESKTOP
, XA_CARDINAL
, 32, PropModeReplace
, (unsigned char *) &val
, 1);
493 state
[0] = server
.atom
._NET_WM_STATE_SKIP_PAGER
;
494 state
[1] = server
.atom
._NET_WM_STATE_SKIP_TASKBAR
;
495 state
[2] = server
.atom
._NET_WM_STATE_STICKY
;
496 state
[3] = panel_layer
== BOTTOM_LAYER
? server
.atom
._NET_WM_STATE_BELOW
: server
.atom
._NET_WM_STATE_ABOVE
;
497 int nb_atoms
= panel_layer
== NORMAL_LAYER
? 3 : 4;
498 XChangeProperty (server
.dsp
, p
->main_win
, server
.atom
._NET_WM_STATE
, XA_ATOM
, 32, PropModeReplace
, (unsigned char *) state
, nb_atoms
);
503 wmhints
.icon_window
= wmhints
.window_group
= p
->main_win
;
504 wmhints
.flags
= StateHint
| IconWindowHint
;
505 wmhints
.initial_state
= WithdrawnState
;
508 wmhints
.flags
= InputHint
;
509 wmhints
.input
= False
;
511 XSetWMHints(server
.dsp
, p
->main_win
, &wmhints
);
514 long prop
[5] = { 2, 0, 0, 0, 0 };
515 XChangeProperty(server
.dsp
, p
->main_win
, server
.atom
._MOTIF_WM_HINTS
, server
.atom
._MOTIF_WM_HINTS
, 32, PropModeReplace
, (unsigned char *) prop
, 5);
517 // XdndAware - Register for Xdnd events
519 XChangeProperty(server
.dsp
, p
->main_win
, server
.atom
.XdndAware
, XA_ATOM
, 32, PropModeReplace
, (unsigned char*)&version
, 1);
523 // Fixed position and non-resizable window
524 // Allow panel move and resize when tint2 reload config file
525 int minwidth
= panel_autohide
? p
->hidden_width
: p
->area
.width
;
526 int minheight
= panel_autohide
? p
->hidden_height
: p
->area
.height
;
527 XSizeHints size_hints
;
528 size_hints
.flags
= PPosition
|PMinSize
|PMaxSize
;
529 size_hints
.min_width
= minwidth
;
530 size_hints
.max_width
= p
->area
.width
;
531 size_hints
.min_height
= minheight
;
532 size_hints
.max_height
= p
->area
.height
;
533 XSetWMNormalHints(server
.dsp
, p
->main_win
, &size_hints
);
536 XClassHint
* classhint
= XAllocClassHint();
537 classhint
->res_name
= "tint2";
538 classhint
->res_class
= "Tint2";
539 XSetClassHint(server
.dsp
, p
->main_win
, classhint
);
544 void set_panel_background(Panel
*p
)
546 if (p
->area
.pix
) XFreePixmap (server
.dsp
, p
->area
.pix
);
547 p
->area
.pix
= XCreatePixmap (server
.dsp
, server
.root_win
, p
->area
.width
, p
->area
.height
, server
.depth
);
549 if (real_transparency
) {
550 clear_pixmap(p
->area
.pix
, 0, 0, p
->area
.width
, p
->area
.height
);
554 // copy background (server.root_pmap) in panel.area.pix
557 XTranslateCoordinates(server
.dsp
, p
->main_win
, server
.root_win
, 0, 0, &x
, &y
, &dummy
);
558 XSetTSOrigin(server
.dsp
, server
.gc
, -x
, -y
) ;
559 XFillRectangle(server
.dsp
, p
->area
.pix
, server
.gc
, 0, 0, p
->area
.width
, p
->area
.height
);
562 // draw background panel
565 cs
= cairo_xlib_surface_create (server
.dsp
, p
->area
.pix
, server
.visual
, p
->area
.width
, p
->area
.height
);
566 c
= cairo_create (cs
);
567 draw_background(&p
->area
, c
);
569 cairo_surface_destroy (cs
);
571 if (panel_autohide
) {
572 if (p
->hidden_pixmap
) XFreePixmap(server
.dsp
, p
->hidden_pixmap
);
573 p
->hidden_pixmap
= XCreatePixmap(server
.dsp
, server
.root_win
, p
->hidden_width
, p
->hidden_height
, server
.depth
);
575 if (panel_horizontal
&& panel_position
& BOTTOM
)
576 yoff
= p
->area
.height
-p
->hidden_height
;
577 else if (!panel_horizontal
&& panel_position
& RIGHT
)
578 xoff
= p
->area
.width
-p
->hidden_width
;
579 XCopyArea(server
.dsp
, p
->area
.pix
, p
->hidden_pixmap
, server
.gc
, xoff
, yoff
, p
->hidden_width
, p
->hidden_height
, 0, 0);
582 // redraw panel's object
585 for (l0
= p
->area
.list
; l0
; l0
= l0
->next
) {
592 Panel
*get_panel(Window win
)
595 for (i
=0 ; i
< nb_panel
; i
++) {
596 if (panel1
[i
].main_win
== win
) {
604 Taskbar
*click_taskbar (Panel
*panel
, int x
, int y
)
609 if (panel_horizontal
) {
610 for (i
=0; i
< panel
->nb_desktop
; i
++) {
611 tskbar
= &panel
->taskbar
[i
];
612 if (tskbar
->area
.on_screen
&& x
>= tskbar
->area
.posx
&& x
<= (tskbar
->area
.posx
+ tskbar
->area
.width
))
617 for (i
=0; i
< panel
->nb_desktop
; i
++) {
618 tskbar
= &panel
->taskbar
[i
];
619 if (tskbar
->area
.on_screen
&& y
>= tskbar
->area
.posy
&& y
<= (tskbar
->area
.posy
+ tskbar
->area
.height
))
627 Task
*click_task (Panel
*panel
, int x
, int y
)
632 if ( (tskbar
= click_taskbar(panel
, x
, y
)) ) {
633 if (panel_horizontal
) {
635 for (l0
= tskbar
->area
.list
; l0
; l0
= l0
->next
) {
637 if (tsk
->area
.on_screen
&& x
>= tsk
->area
.posx
&& x
<= (tsk
->area
.posx
+ tsk
->area
.width
)) {
644 for (l0
= tskbar
->area
.list
; l0
; l0
= l0
->next
) {
646 if (tsk
->area
.on_screen
&& y
>= tsk
->area
.posy
&& y
<= (tsk
->area
.posy
+ tsk
->area
.height
)) {
656 int click_padding(Panel
*panel
, int x
, int y
)
658 if (panel_horizontal
) {
659 if (x
< panel
->area
.paddingxlr
|| x
> panel
->area
.width
-panel
->area
.paddingxlr
)
663 if (y
< panel
->area
.paddingxlr
|| y
> panel
->area
.height
-panel
->area
.paddingxlr
)
670 int click_clock(Panel
*panel
, int x
, int y
)
672 Clock clk
= panel
->clock
;
673 if (panel_horizontal
) {
674 if (clk
.area
.on_screen
&& x
>= clk
.area
.posx
&& x
<= (clk
.area
.posx
+ clk
.area
.width
))
677 if (clk
.area
.on_screen
&& y
>= clk
.area
.posy
&& y
<= (clk
.area
.posy
+ clk
.area
.height
))
684 Area
* click_area(Panel
*panel
, int x
, int y
)
686 Area
* result
= &panel
->area
;
687 Area
* new_result
= result
;
690 GSList
* it
= result
->list
;
693 if (panel_horizontal
) {
694 if (a
->on_screen
&& x
>= a
->posx
&& x
<= (a
->posx
+ a
->width
)) {
699 if (a
->on_screen
&& y
>= a
->posy
&& y
<= (a
->posy
+ a
->height
)) {
706 } while (new_result
!= result
);
711 void stop_autohide_timeout(Panel
* p
)
713 if (p
->autohide_timeout
) {
714 stop_timeout(p
->autohide_timeout
);
715 p
->autohide_timeout
= 0;
720 void autohide_show(void* p
)
723 stop_autohide_timeout(panel
);
724 panel
->is_hidden
= 0;
725 if (panel_strut_policy
== STRUT_FOLLOW_SIZE
)
728 XMapSubwindows(server
.dsp
, panel
->main_win
);
729 if (panel_horizontal
) {
730 if (panel_position
& TOP
)
731 XResizeWindow(server
.dsp
, panel
->main_win
, panel
->area
.width
, panel
->area
.height
);
733 XMoveResizeWindow(server
.dsp
, panel
->main_win
, panel
->posx
, panel
->posy
, panel
->area
.width
, panel
->area
.height
);
736 if (panel_position
& LEFT
)
737 XResizeWindow(server
.dsp
, panel
->main_win
, panel
->area
.width
, panel
->area
.height
);
739 XMoveResizeWindow(server
.dsp
, panel
->main_win
, panel
->posx
, panel
->posy
, panel
->area
.width
, panel
->area
.height
);
745 void autohide_hide(void* p
)
748 stop_autohide_timeout(panel
);
749 panel
->is_hidden
= 1;
750 if (panel_strut_policy
== STRUT_FOLLOW_SIZE
)
753 XUnmapSubwindows(server
.dsp
, panel
->main_win
);
754 int diff
= (panel_horizontal
? panel
->area
.height
: panel
->area
.width
) - panel_autohide_height
;
755 if (panel_horizontal
) {
756 if (panel_position
& TOP
)
757 XResizeWindow(server
.dsp
, panel
->main_win
, panel
->hidden_width
, panel
->hidden_height
);
759 XMoveResizeWindow(server
.dsp
, panel
->main_win
, panel
->posx
, panel
->posy
+diff
, panel
->hidden_width
, panel
->hidden_height
);
762 if (panel_position
& LEFT
)
763 XResizeWindow(server
.dsp
, panel
->main_win
, panel
->hidden_width
, panel
->hidden_height
);
765 XMoveResizeWindow(server
.dsp
, panel
->main_win
, panel
->posx
+diff
, panel
->posy
, panel
->hidden_width
, panel
->hidden_height
);
771 void autohide_trigger_show(Panel
* p
)
775 if (p
->autohide_timeout
)
776 change_timeout(p
->autohide_timeout
, panel_autohide_show_timeout
, 0, autohide_show
, p
);
778 p
->autohide_timeout
= add_timeout(panel_autohide_show_timeout
, 0, autohide_show
, p
);
782 void autohide_trigger_hide(Panel
* p
)
790 if (XQueryPointer(server
.dsp
, p
->main_win
, &root
, &child
, &xr
, &yr
, &xw
, &yw
, &mask
))
791 if (child
) return; // mouse over one of the system tray icons
793 if (p
->autohide_timeout
)
794 change_timeout(p
->autohide_timeout
, panel_autohide_hide_timeout
, 0, autohide_hide
, p
);
796 p
->autohide_timeout
= add_timeout(panel_autohide_hide_timeout
, 0, autohide_hide
, p
);