1
1
/*
2
2
* $Id$
3
3
*
4
- * Copyright (C) 2012 Sanel Zukan
4
+ * Copyright (C) 2012-2013 Sanel Zukan
5
5
*
6
6
* This program is free software; you can redistribute it and/or
7
7
* modify it under the terms of the GNU General Public License
@@ -366,6 +366,24 @@ void Panel::do_layout(void) {
366
366
}
367
367
}
368
368
369
+ void Panel::set_strut (short state) {
370
+ if (state & PANEL_STRUT_REMOVE)
371
+ netwm_window_remove_strut (fl_xid (this ));
372
+
373
+ /* no other flags */
374
+ if (state == PANEL_STRUT_REMOVE) return ;
375
+
376
+ int sizes[4 ] = {0 , 0 , 0 , 0 };
377
+
378
+ if (state & PANEL_STRUT_BOTTOM)
379
+ sizes[3 ] = h ();
380
+ else
381
+ sizes[2 ] = h ();
382
+
383
+ /* TODO: netwm_window_set_strut_partial() */
384
+ netwm_window_set_strut (fl_xid (this ), sizes[0 ], sizes[1 ], sizes[2 ], sizes[3 ]);
385
+ }
386
+
369
387
void Panel::show (void ) {
370
388
if (shown ()) return ;
371
389
@@ -382,9 +400,7 @@ void Panel::show(void) {
382
400
383
401
void Panel::hide (void ) {
384
402
Fl::remove_handler (x_events);
385
- netwm_window_remove_strut (fl_xid (this ));
386
-
387
- E_DEBUG (" Panel::hide()\n " );
403
+ set_strut (PANEL_STRUT_REMOVE);
388
404
389
405
/* clear loaded widgets */
390
406
mgr.clear (this );
@@ -433,17 +449,13 @@ void Panel::update_size_and_pos(bool create_xid, bool update_strut, int X, int Y
433
449
/* position it, this is done after XID was created */
434
450
if (vpos == PANEL_POSITION_BOTTOM) {
435
451
position (X, screen_h - h ());
436
- if (width_perc >= 100 && update_strut) {
437
- netwm_window_remove_strut (fl_xid (this ));
438
- netwm_window_set_strut (fl_xid (this ), 0 , 0 , 0 , h ());
439
- }
452
+ if (width_perc >= 100 && update_strut)
453
+ set_strut (PANEL_STRUT_REMOVE | PANEL_STRUT_BOTTOM);
440
454
} else {
441
455
/* FIXME: this does not work well with edewm (nor pekwm). kwin do it correctly. */
442
456
position (X, Y);
443
- if (width_perc >= 100 && update_strut) {
444
- netwm_window_remove_strut (fl_xid (this ));
445
- netwm_window_set_strut (fl_xid (this ), 0 , 0 , h (), 0 );
446
- }
457
+ if (width_perc >= 100 && update_strut)
458
+ set_strut (PANEL_STRUT_REMOVE | PANEL_STRUT_TOP);
447
459
}
448
460
}
449
461
@@ -472,14 +484,14 @@ int Panel::handle(int e) {
472
484
if (Fl::event_y_root () <= screen_h_half && y () > screen_h_half) {
473
485
position (x (), screen_y);
474
486
if (width_perc >= 100 )
475
- netwm_window_set_strut ( fl_xid ( this ), 0 , 0 , h (), 0 );
487
+ set_strut (PANEL_STRUT_TOP );
476
488
vpos = PANEL_POSITION_TOP;
477
489
}
478
490
479
491
if (Fl::event_y_root () > screen_h_half && y () < screen_h_half) {
480
492
position (x (), screen_h - h ());
481
493
if (width_perc >= 100 )
482
- netwm_window_set_strut ( fl_xid ( this ), 0 , 0 , 0 , h () );
494
+ set_strut (PANEL_STRUT_BOTTOM );
483
495
vpos = PANEL_POSITION_BOTTOM;
484
496
}
485
497
0 commit comments