util: remove off position

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-09-23 17:20:07 +02:00
parent 08b0d71db3
commit 2dfde8c181
8 changed files with 58 additions and 46 deletions

View File

@ -808,9 +808,9 @@ client_unban(client_t *c)
{ {
xcb_map_window(globalconf.connection, c->win); xcb_map_window(globalconf.connection, c->win);
window_state_set(c->win, XCB_WM_STATE_NORMAL); 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); xcb_unmap_window(globalconf.connection, c->titlebar->sw.window);
else else
xcb_map_window(globalconf.connection, c->titlebar->sw.window); xcb_map_window(globalconf.connection, c->titlebar->sw.window);

View File

@ -105,7 +105,7 @@ position_fromstr(const char *pos, ssize_t len)
{ {
switch(a_tokenize(pos, len)) switch(a_tokenize(pos, len))
{ {
case A_TK_TOP: default:
return Top; return Top;
case A_TK_BOTTOM: case A_TK_BOTTOM:
return Bottom; return Bottom;
@ -113,8 +113,6 @@ position_fromstr(const char *pos, ssize_t len)
return Right; return Right;
case A_TK_LEFT: case A_TK_LEFT:
return Left; return Left;
default:
return Off;
} }
} }
@ -131,7 +129,7 @@ position_tostr(position_t p)
case Bottom: return "bottom"; case Bottom: return "bottom";
case Right: return "right"; case Right: return "right";
case Left: return "left"; case Left: return "left";
default: return "off"; default: return NULL;
} }
} }

View File

@ -44,7 +44,6 @@ typedef enum
/** A list of possible position, not sex related */ /** A list of possible position, not sex related */
typedef enum typedef enum
{ {
Off = 0,
Top, Top,
Bottom, Bottom,
Right, Right,

View File

@ -219,6 +219,7 @@ screen_area_get(int screen, wibox_array_t *statusbars,
for(int i = 0; i < statusbars->len; i++) for(int i = 0; i < statusbars->len; i++)
{ {
wibox_t *sb = statusbars->tab[i]; wibox_t *sb = statusbars->tab[i];
if(sb->isvisible)
switch(sb->position) switch(sb->position)
{ {
case Top: case Top:

View File

@ -66,7 +66,7 @@ statusbar_systray_refresh(wibox_t *statusbar)
position_t pos; position_t pos;
int phys_screen = statusbar->sw.ctx.phys_screen; int phys_screen = statusbar->sw.ctx.phys_screen;
if(statusbar->position if(statusbar->isvisible
&& systray->widget->isvisible && systray->widget->isvisible
&& systray->area.width) && systray->area.width)
{ {
@ -123,8 +123,8 @@ statusbar_systray_refresh(wibox_t *statusbar)
else else
{ {
xcb_unmap_window(globalconf.connection, globalconf.screens[phys_screen].systray.window); xcb_unmap_window(globalconf.connection, globalconf.screens[phys_screen].systray.window);
/* hide */ statusbar_systray_kickout(phys_screen);
pos = Off; break;
} }
switch(pos) switch(pos)
@ -200,9 +200,6 @@ statusbar_systray_refresh(wibox_t *statusbar)
config_win_vals_off); config_win_vals_off);
} }
break; break;
default:
statusbar_systray_kickout(phys_screen);
break;
} }
break; break;
} }
@ -216,7 +213,7 @@ statusbar_draw(wibox_t *statusbar)
{ {
statusbar->need_update = false; statusbar->need_update = false;
if(statusbar->position) if(statusbar->isvisible)
{ {
widget_render(statusbar->widgets, &statusbar->sw.ctx, statusbar->sw.gc, widget_render(statusbar->widgets, &statusbar->sw.ctx, statusbar->sw.gc,
statusbar->sw.pixmap, statusbar->sw.pixmap,
@ -270,7 +267,9 @@ statusbar_position_update(wibox_t *statusbar)
area_t area; area_t area;
bool ignore = false; 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); xcb_unmap_window(globalconf.connection, statusbar->sw.window);
/* kick out systray if needed */ /* kick out systray if needed */
@ -344,8 +343,6 @@ statusbar_position_update(wibox_t *statusbar)
break; break;
} }
break; break;
default:
break;
} }
} }
@ -438,7 +435,6 @@ statusbar_position_update(wibox_t *statusbar)
0, statusbar->position, 0, statusbar->position,
&statusbar->colors.fg, &statusbar->colors.bg); &statusbar->colors.fg, &statusbar->colors.bg);
statusbar->need_update = true; statusbar->need_update = true;
xcb_map_window(globalconf.connection, statusbar->sw.window);
} }
/* same window size and position ? */ /* same window size and position ? */
else else
@ -455,8 +451,7 @@ statusbar_position_update(wibox_t *statusbar)
simplewindow_move(&statusbar->sw, statusbar->geometry.x, statusbar->geometry.y); simplewindow_move(&statusbar->sw, statusbar->geometry.x, statusbar->geometry.y);
} }
/* Set need update */ xcb_map_window(globalconf.connection, statusbar->sw.window);
globalconf.screens[statusbar->screen].need_arrange = true;
} }
/** Create a new statusbar (DEPRECATED). /** Create a new statusbar (DEPRECATED).
@ -483,14 +478,14 @@ statusbar_detach(wibox_t *statusbar)
{ {
if(statusbar->screen != SCREEN_UNDEF) if(statusbar->screen != SCREEN_UNDEF)
{ {
position_t p; bool v;
/* save position */ /* save visible state */
p = statusbar->position; v = statusbar->isvisible;
statusbar->position = Off; statusbar->isvisible = false;
statusbar_position_update(statusbar); statusbar_position_update(statusbar);
/* restore position */ /* restore position */
statusbar->position = p; statusbar->isvisible = v;
simplewindow_wipe(&statusbar->sw); simplewindow_wipe(&statusbar->sw);

View File

@ -92,6 +92,8 @@ typedef struct
int refcount; int refcount;
/** Ontop */ /** Ontop */
bool ontop; bool ontop;
/** Visible */
bool isvisible;
/** Wibox type */ /** Wibox type */
wibox_type_t type; wibox_type_t type;
/** Window */ /** Window */

View File

@ -66,7 +66,7 @@ client_getbytitlebarwin(xcb_window_t win)
void void
titlebar_draw(client_t *c) titlebar_draw(client_t *c)
{ {
if(!c || !c->titlebar || !c->titlebar->position) if(!c || !c->titlebar || !c->titlebar->isvisible)
return; return;
widget_render(c->titlebar->widgets, &c->titlebar->sw.ctx, widget_render(c->titlebar->widgets, &c->titlebar->sw.ctx,
@ -203,9 +203,6 @@ titlebar_init(client_t *c)
switch(c->titlebar->position) switch(c->titlebar->position)
{ {
default:
c->titlebar->position = Off;
return;
case Top: case Top:
case Bottom: case Bottom:
if(c->titlebar->geometry.width) if(c->titlebar->geometry.width)

20
wibox.c
View File

@ -100,6 +100,7 @@ luaA_wibox_new(lua_State *L)
w->position = position_fromstr(buf, len); w->position = position_fromstr(buf, len);
w->screen = SCREEN_UNDEF; w->screen = SCREEN_UNDEF;
w->isvisible = true;
for(i = 0; i <= reqs_nbr; i++) for(i = 0; i <= reqs_nbr; i++)
xcolor_init_reply(reqs[i]); xcolor_init_reply(reqs[i]);
@ -139,6 +140,9 @@ luaA_wibox_index(lua_State *L)
case A_TK_GEOMETRY: case A_TK_GEOMETRY:
luaA_pusharea(L, (*wibox)->geometry); luaA_pusharea(L, (*wibox)->geometry);
break; break;
case A_TK_VISIBLE:
lua_pushboolean(L, (*wibox)->isvisible);
break;
case A_TK_CLIENT: case A_TK_CLIENT:
if((c = client_getbytitlebar(*wibox))) if((c = client_getbytitlebar(*wibox)))
return luaA_client_userdata_new(L, c); return luaA_client_userdata_new(L, c);
@ -290,6 +294,22 @@ luaA_wibox_newindex(lua_State *L)
client_stack(); client_stack();
} }
break; 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: default:
switch((*wibox)->type) switch((*wibox)->type)
{ {