diff --git a/client.c b/client.c index 5f16e84f..6e6850bf 100644 --- a/client.c +++ b/client.c @@ -808,9 +808,9 @@ client_unban(client_t *c) { xcb_map_window(globalconf.connection, c->win); window_state_set(c->win, XCB_WM_STATE_NORMAL); - if(c->titlebar && c->titlebar->position) + if(c->titlebar) { - if(c->isfullscreen) + if(c->isfullscreen || !c->titlebar->isvisible) xcb_unmap_window(globalconf.connection, c->titlebar->sw.window); else xcb_map_window(globalconf.connection, c->titlebar->sw.window); diff --git a/common/util.c b/common/util.c index f00d7614..fe653c3c 100644 --- a/common/util.c +++ b/common/util.c @@ -105,7 +105,7 @@ position_fromstr(const char *pos, ssize_t len) { switch(a_tokenize(pos, len)) { - case A_TK_TOP: + default: return Top; case A_TK_BOTTOM: return Bottom; @@ -113,8 +113,6 @@ position_fromstr(const char *pos, ssize_t len) return Right; case A_TK_LEFT: return Left; - default: - return Off; } } @@ -131,7 +129,7 @@ position_tostr(position_t p) case Bottom: return "bottom"; case Right: return "right"; case Left: return "left"; - default: return "off"; + default: return NULL; } } diff --git a/common/util.h b/common/util.h index 9f0a0c9c..50aeffa4 100644 --- a/common/util.h +++ b/common/util.h @@ -44,7 +44,6 @@ typedef enum /** A list of possible position, not sex related */ typedef enum { - Off = 0, Top, Bottom, Right, diff --git a/screen.c b/screen.c index 88861c8a..a25bb171 100644 --- a/screen.c +++ b/screen.c @@ -219,23 +219,24 @@ screen_area_get(int screen, wibox_array_t *statusbars, for(int i = 0; i < statusbars->len; i++) { wibox_t *sb = statusbars->tab[i]; - switch(sb->position) - { - case Top: - top = MAX(top, (uint16_t) (sb->sw.geometry.y - area.y) + sb->sw.geometry.height); - break; - case Bottom: - bottom = MAX(bottom, (uint16_t) (area.y + area.height) - sb->sw.geometry.y); - break; - case Left: - left = MAX(left, (uint16_t) (sb->sw.geometry.x - area.x) + sb->sw.geometry.width); - break; - case Right: - right = MAX(right, (uint16_t) (area.x + area.width) - sb->sw.geometry.x); - break; - default: - break; - } + if(sb->isvisible) + switch(sb->position) + { + case Top: + top = MAX(top, (uint16_t) (sb->sw.geometry.y - area.y) + sb->sw.geometry.height); + break; + case Bottom: + bottom = MAX(bottom, (uint16_t) (area.y + area.height) - sb->sw.geometry.y); + break; + case Left: + left = MAX(left, (uint16_t) (sb->sw.geometry.x - area.x) + sb->sw.geometry.width); + break; + case Right: + right = MAX(right, (uint16_t) (area.x + area.width) - sb->sw.geometry.x); + break; + default: + break; + } } area.x += left; diff --git a/statusbar.c b/statusbar.c index 7e27412a..a4dc0ed4 100644 --- a/statusbar.c +++ b/statusbar.c @@ -66,7 +66,7 @@ statusbar_systray_refresh(wibox_t *statusbar) position_t pos; int phys_screen = statusbar->sw.ctx.phys_screen; - if(statusbar->position + if(statusbar->isvisible && systray->widget->isvisible && systray->area.width) { @@ -123,8 +123,8 @@ statusbar_systray_refresh(wibox_t *statusbar) else { xcb_unmap_window(globalconf.connection, globalconf.screens[phys_screen].systray.window); - /* hide */ - pos = Off; + statusbar_systray_kickout(phys_screen); + break; } switch(pos) @@ -200,9 +200,6 @@ statusbar_systray_refresh(wibox_t *statusbar) config_win_vals_off); } break; - default: - statusbar_systray_kickout(phys_screen); - break; } break; } @@ -216,7 +213,7 @@ statusbar_draw(wibox_t *statusbar) { statusbar->need_update = false; - if(statusbar->position) + if(statusbar->isvisible) { widget_render(statusbar->widgets, &statusbar->sw.ctx, statusbar->sw.gc, statusbar->sw.pixmap, @@ -270,7 +267,9 @@ statusbar_position_update(wibox_t *statusbar) area_t area; bool ignore = false; - if(statusbar->position == Off) + globalconf.screens[statusbar->screen].need_arrange = true; + + if(!statusbar->isvisible) { xcb_unmap_window(globalconf.connection, statusbar->sw.window); /* kick out systray if needed */ @@ -344,8 +343,6 @@ statusbar_position_update(wibox_t *statusbar) break; } break; - default: - break; } } @@ -438,7 +435,6 @@ statusbar_position_update(wibox_t *statusbar) 0, statusbar->position, &statusbar->colors.fg, &statusbar->colors.bg); statusbar->need_update = true; - xcb_map_window(globalconf.connection, statusbar->sw.window); } /* same window size and position ? */ else @@ -455,8 +451,7 @@ statusbar_position_update(wibox_t *statusbar) simplewindow_move(&statusbar->sw, statusbar->geometry.x, statusbar->geometry.y); } - /* Set need update */ - globalconf.screens[statusbar->screen].need_arrange = true; + xcb_map_window(globalconf.connection, statusbar->sw.window); } /** Create a new statusbar (DEPRECATED). @@ -483,14 +478,14 @@ statusbar_detach(wibox_t *statusbar) { if(statusbar->screen != SCREEN_UNDEF) { - position_t p; + bool v; - /* save position */ - p = statusbar->position; - statusbar->position = Off; + /* save visible state */ + v = statusbar->isvisible; + statusbar->isvisible = false; statusbar_position_update(statusbar); /* restore position */ - statusbar->position = p; + statusbar->isvisible = v; simplewindow_wipe(&statusbar->sw); diff --git a/structs.h b/structs.h index 9ad531e5..d9b80f3b 100644 --- a/structs.h +++ b/structs.h @@ -92,6 +92,8 @@ typedef struct int refcount; /** Ontop */ bool ontop; + /** Visible */ + bool isvisible; /** Wibox type */ wibox_type_t type; /** Window */ diff --git a/titlebar.c b/titlebar.c index ed95bfbe..c353e6dc 100644 --- a/titlebar.c +++ b/titlebar.c @@ -66,7 +66,7 @@ client_getbytitlebarwin(xcb_window_t win) void titlebar_draw(client_t *c) { - if(!c || !c->titlebar || !c->titlebar->position) + if(!c || !c->titlebar || !c->titlebar->isvisible) return; widget_render(c->titlebar->widgets, &c->titlebar->sw.ctx, @@ -203,9 +203,6 @@ titlebar_init(client_t *c) switch(c->titlebar->position) { - default: - c->titlebar->position = Off; - return; case Top: case Bottom: if(c->titlebar->geometry.width) diff --git a/wibox.c b/wibox.c index 0f4e63e1..6160066d 100644 --- a/wibox.c +++ b/wibox.c @@ -100,6 +100,7 @@ luaA_wibox_new(lua_State *L) w->position = position_fromstr(buf, len); w->screen = SCREEN_UNDEF; + w->isvisible = true; for(i = 0; i <= reqs_nbr; i++) xcolor_init_reply(reqs[i]); @@ -139,6 +140,9 @@ luaA_wibox_index(lua_State *L) case A_TK_GEOMETRY: luaA_pusharea(L, (*wibox)->geometry); break; + case A_TK_VISIBLE: + lua_pushboolean(L, (*wibox)->isvisible); + break; case A_TK_CLIENT: if((c = client_getbytitlebar(*wibox))) return luaA_client_userdata_new(L, c); @@ -290,6 +294,22 @@ luaA_wibox_newindex(lua_State *L) client_stack(); } break; + case A_TK_VISIBLE: + b = luaA_checkboolean(L, 3); + if(b != (*wibox)->isvisible) + { + (*wibox)->isvisible = b; + switch((*wibox)->type) + { + case WIBOX_TYPE_STATUSBAR: + statusbar_position_update(*wibox); + break; + case WIBOX_TYPE_NONE: + case WIBOX_TYPE_TITLEBAR: + break; + } + } + break; default: switch((*wibox)->type) {