Skip to content

Commit 70e9a9b

Browse files
committed
Cleaned a little bit strut handling. Oddly, this fixed strut ignoring value for xfwm4...
1 parent a8b01d7 commit 70e9a9b

File tree

2 files changed

+34
-15
lines changed

2 files changed

+34
-15
lines changed

ede-panel/Panel.cpp

+26-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* $Id$
33
*
4-
* Copyright (C) 2012 Sanel Zukan
4+
* Copyright (C) 2012-2013 Sanel Zukan
55
*
66
* This program is free software; you can redistribute it and/or
77
* modify it under the terms of the GNU General Public License
@@ -366,6 +366,24 @@ void Panel::do_layout(void) {
366366
}
367367
}
368368

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+
369387
void Panel::show(void) {
370388
if(shown()) return;
371389

@@ -382,9 +400,7 @@ void Panel::show(void) {
382400

383401
void Panel::hide(void) {
384402
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);
388404

389405
/* clear loaded widgets */
390406
mgr.clear(this);
@@ -433,17 +449,13 @@ void Panel::update_size_and_pos(bool create_xid, bool update_strut, int X, int Y
433449
/* position it, this is done after XID was created */
434450
if(vpos == PANEL_POSITION_BOTTOM) {
435451
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);
440454
} else {
441455
/* FIXME: this does not work well with edewm (nor pekwm). kwin do it correctly. */
442456
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);
447459
}
448460
}
449461

@@ -472,14 +484,14 @@ int Panel::handle(int e) {
472484
if(Fl::event_y_root() <= screen_h_half && y() > screen_h_half) {
473485
position(x(), screen_y);
474486
if(width_perc >= 100)
475-
netwm_window_set_strut(fl_xid(this), 0, 0, h(), 0);
487+
set_strut(PANEL_STRUT_TOP);
476488
vpos = PANEL_POSITION_TOP;
477489
}
478490

479491
if(Fl::event_y_root() > screen_h_half && y() < screen_h_half) {
480492
position(x(), screen_h - h());
481493
if(width_perc >= 100)
482-
netwm_window_set_strut(fl_xid(this), 0, 0, 0, h());
494+
set_strut(PANEL_STRUT_BOTTOM);
483495
vpos = PANEL_POSITION_BOTTOM;
484496
}
485497

ede-panel/Panel.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ enum {
3434
PANEL_POSITION_BOTTOM
3535
};
3636

37+
/* combination of what to do with strut data */
38+
enum {
39+
PANEL_STRUT_REMOVE = (1 << 1),
40+
PANEL_STRUT_BOTTOM = (1 << 2),
41+
PANEL_STRUT_TOP = (1 << 3)
42+
};
43+
3744
class Hider;
3845

3946
class Panel : public PanelWindow {
@@ -52,7 +59,7 @@ class Panel : public PanelWindow {
5259
void read_config(void);
5360
void save_config(void);
5461
void do_layout(void);
55-
62+
void set_strut(short state);
5663
public:
5764
Panel();
5865

0 commit comments

Comments
 (0)