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>
38 // --------------------------------------------------
43 int mouse_scroll_down
;
57 int panel_autohide_show_timeout
;
58 int panel_autohide_hide_timeout
;
59 int panel_autohide_height
;
60 int panel_strut_policy
;
61 char *panel_items_order
;
65 // panel's initial config
67 // panels (one panel per monitor)
73 Imlib_Image default_icon
;
82 panel_position
= CENTER
;
83 panel_items_order
= 0;
85 panel_autohide_show_timeout
= 0;
86 panel_autohide_hide_timeout
= 0;
87 panel_autohide_height
= 5; // for vertical panels this is of course the width
88 panel_strut_policy
= STRUT_FOLLOW_SIZE
;
89 panel_dock
= 0; // default not in the dock
90 panel_layer
= BOTTOM_LAYER
; // default is bottom layer
93 backgrounds
= g_array_new(0, 0, sizeof(Background
));
95 memset(&panel_config
, 0, sizeof(Panel
));
97 // append full transparency background
98 Background transparent_bg
;
99 memset(&transparent_bg
, 0, sizeof(Background
));
100 g_array_append_val(backgrounds
, transparent_bg
);
111 for (i
=0 ; i
< nb_panel
; i
++) {
115 if (p
->temp_pmap
) XFreePixmap(server
.dsp
, p
->temp_pmap
);
116 if (p
->hidden_pixmap
) XFreePixmap(server
.dsp
, p
->hidden_pixmap
);
117 if (p
->main_win
) XDestroyWindow(server
.dsp
, p
->main_win
);
120 if (panel_items_order
) g_free(panel_items_order
);
121 if (panel1
) free(panel1
);
123 g_array_free(backgrounds
, 1);
124 if (panel_config
.g_task
.font_desc
) pango_font_description_free(panel_config
.g_task
.font_desc
);
132 if (panel_config
.monitor
> (server
.nb_monitor
-1)) {
133 // server.nb_monitor minimum value is 1 (see get_monitors())
134 fprintf(stderr
, "warning : monitor not found. tint2 default to all monitors.\n");
135 panel_config
.monitor
= 0;
142 #ifdef ENABLE_BATTERY
147 // number of panels (one monitor or 'all' monitors)
148 if (panel_config
.monitor
>= 0)
151 nb_panel
= server
.nb_monitor
;
153 panel1
= malloc(nb_panel
* sizeof(Panel
));
154 for (i
=0 ; i
< nb_panel
; i
++) {
155 memcpy(&panel1
[i
], &panel_config
, sizeof(Panel
));
158 fprintf(stderr
, "tint2 : nb monitor %d, nb monitor used %d, nb desktop %d\n", server
.nb_monitor
, nb_panel
, server
.nb_desktop
);
159 for (i
=0 ; i
< nb_panel
; i
++) {
162 if (panel_config
.monitor
< 0)
164 if ( p
->area
.bg
== 0 )
165 p
->area
.bg
= &g_array_index(backgrounds
, Background
, 0);
168 p
->area
.on_screen
= 1;
170 p
->area
.size_mode
= SIZE_BY_LAYOUT
;
171 p
->area
._resize
= resize_by_layout
;
172 p
->g_taskbar
.area
.parent
= p
;
173 p
->g_taskbar
.area
.panel
= p
;
174 p
->g_task
.area
.panel
= p
;
175 init_panel_size_and_position(p
);
176 // add childs according to panel_items
177 for (k
=0 ; k
< strlen(panel_items_order
) ; k
++) {
178 if (panel_items_order
[k
] == 'L')
179 init_launcher_panel(p
);
180 if (panel_items_order
[k
] == 'T')
181 init_taskbar_panel(p
);
182 #ifdef ENABLE_BATTERY
183 if (panel_items_order
[k
] == 'B')
184 init_battery_panel(p
);
186 if (panel_items_order
[k
] == 'S') {
187 // TODO : check systray is only on 1 panel
188 init_systray_panel(p
);
191 if (panel_items_order
[k
] == 'C')
194 set_panel_items_order(p
);
197 XSetWindowAttributes att
= { .colormap
=server
.colormap
, .background_pixel
=0, .border_pixel
=0 };
198 unsigned long mask
= CWEventMask
|CWColormap
|CWBackPixel
|CWBorderPixel
;
199 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
);
201 long event_mask
= ExposureMask
|ButtonPressMask
|ButtonReleaseMask
|ButtonMotionMask
;
202 if (g_tooltip
.enabled
)
203 event_mask
|= PointerMotionMask
|LeaveWindowMask
;
205 event_mask
|= LeaveWindowMask
|EnterWindowMask
;
206 XChangeWindowAttributes(server
.dsp
, p
->main_win
, CWEventMask
, &(XSetWindowAttributes
){.event_mask
=event_mask
});
210 server
.gc
= XCreateGC(server
.dsp
, p
->main_win
, 0, &gcv
);
212 //printf("panel %d : %d, %d, %d, %d\n", i, p->posx, p->posy, p->area.width, p->area.height);
213 set_panel_properties(p
);
214 set_panel_background(p
);
215 if (snapshot_path
== 0) {
216 // if we are not in 'snapshot' mode then map new panel
217 XMapWindow (server
.dsp
, p
->main_win
);
221 add_timeout(panel_autohide_hide_timeout
, 0, autohide_hide
, p
);
226 task_refresh_tasklist();
231 void init_panel_size_and_position(Panel
*panel
)
234 if (panel_horizontal
) {
235 if (panel
->pourcentx
)
236 panel
->area
.width
= (float)server
.monitor
[panel
->monitor
].width
* panel
->area
.width
/ 100;
237 if (panel
->pourcenty
)
238 panel
->area
.height
= (float)server
.monitor
[panel
->monitor
].height
* panel
->area
.height
/ 100;
239 if (panel
->area
.bg
->border
.rounded
> panel
->area
.height
/2) {
240 printf("panel_background_id rounded is too big... please fix your tint2rc\n");
241 g_array_append_val(backgrounds
, *panel
->area
.bg
);
242 panel
->area
.bg
= &g_array_index(backgrounds
, Background
, backgrounds
->len
-1);
243 panel
->area
.bg
->border
.rounded
= panel
->area
.height
/2;
247 int old_panel_height
= panel
->area
.height
;
248 if (panel
->pourcentx
)
249 panel
->area
.height
= (float)server
.monitor
[panel
->monitor
].height
* panel
->area
.width
/ 100;
251 panel
->area
.height
= panel
->area
.width
;
252 if (panel
->pourcenty
)
253 panel
->area
.width
= (float)server
.monitor
[panel
->monitor
].width
* old_panel_height
/ 100;
255 panel
->area
.width
= old_panel_height
;
256 if (panel
->area
.bg
->border
.rounded
> panel
->area
.width
/2) {
257 printf("panel_background_id rounded is too big... please fix your tint2rc\n");
258 g_array_append_val(backgrounds
, *panel
->area
.bg
);
259 panel
->area
.bg
= &g_array_index(backgrounds
, Background
, backgrounds
->len
-1);
260 panel
->area
.bg
->border
.rounded
= panel
->area
.width
/2;
264 // panel position determined here
265 if (panel_position
& LEFT
) {
266 panel
->posx
= server
.monitor
[panel
->monitor
].x
+ panel
->marginx
;
269 if (panel_position
& RIGHT
) {
270 panel
->posx
= server
.monitor
[panel
->monitor
].x
+ server
.monitor
[panel
->monitor
].width
- panel
->area
.width
- panel
->marginx
;
273 if (panel_horizontal
)
274 panel
->posx
= server
.monitor
[panel
->monitor
].x
+ ((server
.monitor
[panel
->monitor
].width
- panel
->area
.width
) / 2);
276 panel
->posx
= server
.monitor
[panel
->monitor
].x
+ panel
->marginx
;
279 if (panel_position
& TOP
) {
280 panel
->posy
= server
.monitor
[panel
->monitor
].y
+ panel
->marginy
;
283 if (panel_position
& BOTTOM
) {
284 panel
->posy
= server
.monitor
[panel
->monitor
].y
+ server
.monitor
[panel
->monitor
].height
- panel
->area
.height
- panel
->marginy
;
287 panel
->posy
= server
.monitor
[panel
->monitor
].y
+ ((server
.monitor
[panel
->monitor
].height
- panel
->area
.height
) / 2);
291 // autohide or strut_policy=minimum
292 int diff
= (panel_horizontal
? panel
->area
.height
: panel
->area
.width
) - panel_autohide_height
;
293 if (panel_horizontal
) {
294 panel
->hidden_width
= panel
->area
.width
;
295 panel
->hidden_height
= panel
->area
.height
- diff
;
298 panel
->hidden_width
= panel
->area
.width
- diff
;
299 panel
->hidden_height
= panel
->area
.height
;
301 // printf("panel : posx %d, posy %d, width %d, height %d\n", panel->posx, panel->posy, panel->area.width, panel->area.height);
305 void update_strut(Panel
* p
)
307 if (panel_strut_policy
== STRUT_NONE
) {
308 XDeleteProperty(server
.dsp
, p
->main_win
, server
.atom
._NET_WM_STRUT
);
309 XDeleteProperty(server
.dsp
, p
->main_win
, server
.atom
._NET_WM_STRUT_PARTIAL
);
314 unsigned int d1
, screen_width
, screen_height
;
317 XGetGeometry(server
.dsp
, server
.root_win
, &d2
, &d3
, &d3
, &screen_width
, &screen_height
, &d1
, &d1
);
318 Monitor monitor
= server
.monitor
[p
->monitor
];
319 long struts
[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
320 if (panel_horizontal
) {
321 int height
= p
->area
.height
+ p
->marginy
;
322 if (panel_strut_policy
== STRUT_MINIMUM
|| (panel_strut_policy
== STRUT_FOLLOW_SIZE
&& p
->is_hidden
))
323 height
= p
->hidden_height
;
324 if (panel_position
& TOP
) {
325 struts
[2] = height
+ monitor
.y
;
327 // p->area.width - 1 allowed full screen on monitor 2
328 struts
[9] = p
->posx
+ p
->area
.width
- 1;
331 struts
[3] = height
+ screen_height
- monitor
.y
- monitor
.height
;
332 struts
[10] = p
->posx
;
333 // p->area.width - 1 allowed full screen on monitor 2
334 struts
[11] = p
->posx
+ p
->area
.width
- 1;
338 int width
= p
->area
.width
+ p
->marginx
;
339 if (panel_strut_policy
== STRUT_MINIMUM
|| (panel_strut_policy
== STRUT_FOLLOW_SIZE
&& p
->is_hidden
))
340 width
= p
->hidden_width
;
341 if (panel_position
& LEFT
) {
342 struts
[0] = width
+ monitor
.x
;
344 // p->area.width - 1 allowed full screen on monitor 2
345 struts
[5] = p
->posy
+ p
->area
.height
- 1;
348 struts
[1] = width
+ screen_width
- monitor
.x
- monitor
.width
;
350 // p->area.width - 1 allowed full screen on monitor 2
351 struts
[7] = p
->posy
+ p
->area
.height
- 1;
354 // Old specification : fluxbox need _NET_WM_STRUT.
355 XChangeProperty (server
.dsp
, p
->main_win
, server
.atom
._NET_WM_STRUT
, XA_CARDINAL
, 32, PropModeReplace
, (unsigned char *) &struts
, 4);
356 XChangeProperty (server
.dsp
, p
->main_win
, server
.atom
._NET_WM_STRUT_PARTIAL
, XA_CARDINAL
, 32, PropModeReplace
, (unsigned char *) &struts
, 12);
360 void set_panel_items_order(Panel
*p
)
365 g_slist_free(p
->area
.list
);
369 for (k
=0 ; k
< strlen(panel_items_order
) ; k
++) {
370 if (panel_items_order
[k
] == 'L')
371 p
->area
.list
= g_slist_append(p
->area
.list
, &p
->launcher
);
372 if (panel_items_order
[k
] == 'T') {
373 for (j
=0 ; j
< p
->nb_desktop
; j
++)
374 p
->area
.list
= g_slist_append(p
->area
.list
, &p
->taskbar
[j
]);
376 #ifdef ENABLE_BATTERY
377 if (panel_items_order
[k
] == 'B')
378 p
->area
.list
= g_slist_append(p
->area
.list
, &p
->battery
);
380 if (panel_items_order
[k
] == 'S') {
381 // TODO : check systray is only on 1 panel
382 p
->area
.list
= g_slist_append(p
->area
.list
, &systray
);
384 if (panel_items_order
[k
] == 'C')
385 p
->area
.list
= g_slist_append(p
->area
.list
, &p
->clock
);
387 init_rendering(&p
->area
, 0);
391 void set_panel_properties(Panel
*p
)
393 XStoreName (server
.dsp
, p
->main_win
, "tint2");
396 gchar
*name
= g_locale_to_utf8("tint2", -1, NULL
, &len
, NULL
);
398 XChangeProperty(server
.dsp
, p
->main_win
, server
.atom
._NET_WM_NAME
, server
.atom
.UTF8_STRING
, 8, PropModeReplace
, (unsigned char *) name
, (int) len
);
403 long val
= server
.atom
._NET_WM_WINDOW_TYPE_DOCK
;
404 XChangeProperty (server
.dsp
, p
->main_win
, server
.atom
._NET_WM_WINDOW_TYPE
, XA_ATOM
, 32, PropModeReplace
, (unsigned char *) &val
, 1);
406 // Sticky and below other window
408 XChangeProperty (server
.dsp
, p
->main_win
, server
.atom
._NET_WM_DESKTOP
, XA_CARDINAL
, 32, PropModeReplace
, (unsigned char *) &val
, 1);
410 state
[0] = server
.atom
._NET_WM_STATE_SKIP_PAGER
;
411 state
[1] = server
.atom
._NET_WM_STATE_SKIP_TASKBAR
;
412 state
[2] = server
.atom
._NET_WM_STATE_STICKY
;
413 state
[3] = panel_layer
== BOTTOM_LAYER
? server
.atom
._NET_WM_STATE_BELOW
: server
.atom
._NET_WM_STATE_ABOVE
;
414 int nb_atoms
= panel_layer
== NORMAL_LAYER
? 3 : 4;
415 XChangeProperty (server
.dsp
, p
->main_win
, server
.atom
._NET_WM_STATE
, XA_ATOM
, 32, PropModeReplace
, (unsigned char *) state
, nb_atoms
);
420 wmhints
.icon_window
= wmhints
.window_group
= p
->main_win
;
421 wmhints
.flags
= StateHint
| IconWindowHint
;
422 wmhints
.initial_state
= WithdrawnState
;
425 wmhints
.flags
= InputHint
;
426 wmhints
.input
= False
;
428 XSetWMHints(server
.dsp
, p
->main_win
, &wmhints
);
431 long prop
[5] = { 2, 0, 0, 0, 0 };
432 XChangeProperty(server
.dsp
, p
->main_win
, server
.atom
._MOTIF_WM_HINTS
, server
.atom
._MOTIF_WM_HINTS
, 32, PropModeReplace
, (unsigned char *) prop
, 5);
434 // XdndAware - Register for Xdnd events
436 XChangeProperty(server
.dsp
, p
->main_win
, server
.atom
.XdndAware
, XA_ATOM
, 32, PropModeReplace
, (unsigned char*)&version
, 1);
440 // Fixed position and non-resizable window
441 // Allow panel move and resize when tint2 reload config file
442 int minwidth
= panel_autohide
? p
->hidden_width
: p
->area
.width
;
443 int minheight
= panel_autohide
? p
->hidden_height
: p
->area
.height
;
444 XSizeHints size_hints
;
445 size_hints
.flags
= PPosition
|PMinSize
|PMaxSize
;
446 size_hints
.min_width
= minwidth
;
447 size_hints
.max_width
= p
->area
.width
;
448 size_hints
.min_height
= minheight
;
449 size_hints
.max_height
= p
->area
.height
;
450 XSetWMNormalHints(server
.dsp
, p
->main_win
, &size_hints
);
453 XClassHint
* classhint
= XAllocClassHint();
454 classhint
->res_name
= "tint2";
455 classhint
->res_class
= "Tint2";
456 XSetClassHint(server
.dsp
, p
->main_win
, classhint
);
461 void set_panel_background(Panel
*p
)
463 if (p
->area
.pix
) XFreePixmap (server
.dsp
, p
->area
.pix
);
464 p
->area
.pix
= XCreatePixmap (server
.dsp
, server
.root_win
, p
->area
.width
, p
->area
.height
, server
.depth
);
467 if (panel_horizontal
&& panel_position
& BOTTOM
)
468 yoff
= p
->area
.height
-p
->hidden_height
;
469 else if (!panel_horizontal
&& panel_position
& RIGHT
)
470 xoff
= p
->area
.width
-p
->hidden_width
;
472 if (server
.real_transparency
) {
473 clear_pixmap(p
->area
.pix
, 0, 0, p
->area
.width
, p
->area
.height
);
477 // copy background (server.root_pmap) in panel.area.pix
480 XTranslateCoordinates(server
.dsp
, p
->main_win
, server
.root_win
, 0, 0, &x
, &y
, &dummy
);
481 if (panel_autohide
&& p
->is_hidden
) {
485 XSetTSOrigin(server
.dsp
, server
.gc
, -x
, -y
);
486 XFillRectangle(server
.dsp
, p
->area
.pix
, server
.gc
, 0, 0, p
->area
.width
, p
->area
.height
);
489 // draw background panel
492 cs
= cairo_xlib_surface_create (server
.dsp
, p
->area
.pix
, server
.visual
, p
->area
.width
, p
->area
.height
);
493 c
= cairo_create (cs
);
494 draw_background(&p
->area
, c
);
496 cairo_surface_destroy (cs
);
498 if (panel_autohide
) {
499 if (p
->hidden_pixmap
) XFreePixmap(server
.dsp
, p
->hidden_pixmap
);
500 p
->hidden_pixmap
= XCreatePixmap(server
.dsp
, server
.root_win
, p
->hidden_width
, p
->hidden_height
, server
.depth
);
501 XCopyArea(server
.dsp
, p
->area
.pix
, p
->hidden_pixmap
, server
.gc
, xoff
, yoff
, p
->hidden_width
, p
->hidden_height
, 0, 0);
504 // redraw panel's object
505 //p->area.redraw = 1;
508 for (l0
= p
->area
.list
; l0
; l0
= l0
->next
) {
513 // reset task 'state_pix'
516 for (i
=0 ; i
< p
->nb_desktop
; i
++) {
517 tskbar
= &p
->taskbar
[i
];
518 for (l0
= tskbar
->area
.list
; l0
; l0
= l0
->next
) {
519 set_task_redraw((Task
*)l0
->data
);
525 Panel
*get_panel(Window win
)
528 for (i
=0 ; i
< nb_panel
; i
++) {
529 if (panel1
[i
].main_win
== win
) {
537 Taskbar
*click_taskbar (Panel
*panel
, int x
, int y
)
542 if (panel_horizontal
) {
543 for (i
=0; i
< panel
->nb_desktop
; i
++) {
544 tskbar
= &panel
->taskbar
[i
];
545 if (tskbar
->area
.on_screen
&& x
>= tskbar
->area
.posx
&& x
<= (tskbar
->area
.posx
+ tskbar
->area
.width
))
550 for (i
=0; i
< panel
->nb_desktop
; i
++) {
551 tskbar
= &panel
->taskbar
[i
];
552 if (tskbar
->area
.on_screen
&& y
>= tskbar
->area
.posy
&& y
<= (tskbar
->area
.posy
+ tskbar
->area
.height
))
560 Task
*click_task (Panel
*panel
, int x
, int y
)
565 if ( (tskbar
= click_taskbar(panel
, x
, y
)) ) {
566 if (panel_horizontal
) {
568 for (l0
= tskbar
->area
.list
; l0
; l0
= l0
->next
) {
570 if (tsk
->area
.on_screen
&& x
>= tsk
->area
.posx
&& x
<= (tsk
->area
.posx
+ tsk
->area
.width
)) {
577 for (l0
= tskbar
->area
.list
; l0
; l0
= l0
->next
) {
579 if (tsk
->area
.on_screen
&& y
>= tsk
->area
.posy
&& y
<= (tsk
->area
.posy
+ tsk
->area
.height
)) {
589 Launcher
*click_launcher (Panel
*panel
, int x
, int y
)
591 Launcher
*launcher
= &panel
->launcher
;
593 if (panel_horizontal
) {
594 if (launcher
->area
.on_screen
&& x
>= launcher
->area
.posx
&& x
<= (launcher
->area
.posx
+ launcher
->area
.width
))
598 if (launcher
->area
.on_screen
&& y
>= launcher
->area
.posy
&& y
<= (launcher
->area
.posy
+ launcher
->area
.height
))
605 LauncherIcon
*click_launcher_icon (Panel
*panel
, int x
, int y
)
610 //printf("Click x=%d y=%d\n", x, y);
611 if ( (launcher
= click_launcher(panel
, x
, y
)) ) {
613 for (l0
= launcher
->list_icons
; l0
; l0
= l0
->next
) {
615 if (x
>= (launcher
->area
.posx
+ icon
->x
) && x
<= (launcher
->area
.posx
+ icon
->x
+ icon
->icon_size
) &&
616 y
>= (launcher
->area
.posy
+ icon
->y
) && y
<= (launcher
->area
.posy
+ icon
->y
+ icon
->icon_size
)) {
617 //printf("Hit rect x=%d y=%d xmax=%d ymax=%d\n", launcher->area.posx + icon->x, launcher->area.posy + icon->y, launcher->area.posx + icon->x + icon->width, launcher->area.posy + icon->y + icon->height);
626 int click_padding(Panel
*panel
, int x
, int y
)
628 if (panel_horizontal
) {
629 if (x
< panel
->area
.paddingxlr
|| x
> panel
->area
.width
-panel
->area
.paddingxlr
)
633 if (y
< panel
->area
.paddingxlr
|| y
> panel
->area
.height
-panel
->area
.paddingxlr
)
640 int click_clock(Panel
*panel
, int x
, int y
)
642 Clock clk
= panel
->clock
;
643 if (panel_horizontal
) {
644 if (clk
.area
.on_screen
&& x
>= clk
.area
.posx
&& x
<= (clk
.area
.posx
+ clk
.area
.width
))
647 if (clk
.area
.on_screen
&& y
>= clk
.area
.posy
&& y
<= (clk
.area
.posy
+ clk
.area
.height
))
654 Area
* click_area(Panel
*panel
, int x
, int y
)
656 Area
* result
= &panel
->area
;
657 Area
* new_result
= result
;
660 GSList
* it
= result
->list
;
663 if (panel_horizontal
) {
664 if (a
->on_screen
&& x
>= a
->posx
&& x
<= (a
->posx
+ a
->width
)) {
669 if (a
->on_screen
&& y
>= a
->posy
&& y
<= (a
->posy
+ a
->height
)) {
676 } while (new_result
!= result
);
681 void stop_autohide_timeout(Panel
* p
)
683 if (p
->autohide_timeout
) {
684 stop_timeout(p
->autohide_timeout
);
685 p
->autohide_timeout
= 0;
690 void autohide_show(void* p
)
693 stop_autohide_timeout(panel
);
694 panel
->is_hidden
= 0;
695 if (panel_strut_policy
== STRUT_FOLLOW_SIZE
)
698 XMapSubwindows(server
.dsp
, panel
->main_win
); // systray windows
699 if (panel_horizontal
) {
700 if (panel_position
& TOP
)
701 XResizeWindow(server
.dsp
, panel
->main_win
, panel
->area
.width
, panel
->area
.height
);
703 XMoveResizeWindow(server
.dsp
, panel
->main_win
, panel
->posx
, panel
->posy
, panel
->area
.width
, panel
->area
.height
);
706 if (panel_position
& LEFT
)
707 XResizeWindow(server
.dsp
, panel
->main_win
, panel
->area
.width
, panel
->area
.height
);
709 XMoveResizeWindow(server
.dsp
, panel
->main_win
, panel
->posx
, panel
->posy
, panel
->area
.width
, panel
->area
.height
);
711 refresh_systray
= 1; // ugly hack, because we actually only need to call XSetBackgroundPixmap
716 void autohide_hide(void* p
)
719 stop_autohide_timeout(panel
);
720 panel
->is_hidden
= 1;
721 if (panel_strut_policy
== STRUT_FOLLOW_SIZE
)
724 XUnmapSubwindows(server
.dsp
, panel
->main_win
); // systray windows
725 int diff
= (panel_horizontal
? panel
->area
.height
: panel
->area
.width
) - panel_autohide_height
;
726 //printf("autohide_hide : diff %d, w %d, h %d\n", diff, panel->hidden_width, panel->hidden_height);
727 if (panel_horizontal
) {
728 if (panel_position
& TOP
)
729 XResizeWindow(server
.dsp
, panel
->main_win
, panel
->hidden_width
, panel
->hidden_height
);
731 XMoveResizeWindow(server
.dsp
, panel
->main_win
, panel
->posx
, panel
->posy
+diff
, panel
->hidden_width
, panel
->hidden_height
);
734 if (panel_position
& LEFT
)
735 XResizeWindow(server
.dsp
, panel
->main_win
, panel
->hidden_width
, panel
->hidden_height
);
737 XMoveResizeWindow(server
.dsp
, panel
->main_win
, panel
->posx
+diff
, panel
->posy
, panel
->hidden_width
, panel
->hidden_height
);
743 void autohide_trigger_show(Panel
* p
)
747 if (p
->autohide_timeout
)
748 change_timeout(p
->autohide_timeout
, panel_autohide_show_timeout
, 0, autohide_show
, p
);
750 p
->autohide_timeout
= add_timeout(panel_autohide_show_timeout
, 0, autohide_show
, p
);
754 void autohide_trigger_hide(Panel
* p
)
762 if (XQueryPointer(server
.dsp
, p
->main_win
, &root
, &child
, &xr
, &yr
, &xw
, &yw
, &mask
))
763 if (child
) return; // mouse over one of the system tray icons
765 if (p
->autohide_timeout
)
766 change_timeout(p
->autohide_timeout
, panel_autohide_hide_timeout
, 0, autohide_hide
, p
);
768 p
->autohide_timeout
= add_timeout(panel_autohide_hide_timeout
, 0, autohide_hide
, p
);