titlebar: correctly ban/unban (FS#443)

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-02-05 17:55:59 +01:00
parent a13f3fe553
commit 2c6dc1048d
3 changed files with 34 additions and 22 deletions

View File

@ -220,21 +220,7 @@ client_ban(client_t *c)
XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y,
request);
/* Do it manually because client geometry remains unchanged. */
if (c->titlebar)
{
simple_window_t *sw = &c->titlebar->sw;
if (sw->window)
{
request[0] = - (sw->geometry.width);
request[1] = - (sw->geometry.height);
/* Move the titlebar to the same place as the window. */
xcb_configure_window(globalconf.connection, sw->window,
XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y,
request);
}
}
titlebar_ban(c->titlebar);
c->isbanned = true;

View File

@ -61,6 +61,28 @@ client_getbytitlebarwin(xcb_window_t win)
return NULL;
}
/** Move a titlebar out of the viewport.
* \param titlebar The titlebar.
*/
void
titlebar_ban(wibox_t *titlebar)
{
/* Do it manually because client geometry remains unchanged. */
if(titlebar)
{
simple_window_t *sw = &titlebar->sw;
if(sw->window)
{
uint32_t request[] = { - sw->geometry.width, - sw->geometry.height };
/* Move the titlebar to the same place as the window. */
xcb_configure_window(globalconf.connection, sw->window,
XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y,
request);
}
}
}
/** Get titlebar area.
* \param c The client
* \param geometry The client geometry including borders, excluding titlebars.
@ -148,12 +170,6 @@ titlebar_geometry_compute(client_t *c, area_t geometry, area_t *res)
res->height = height;
break;
}
/* Move out of visible screen if needed. */
if (c->isbanned) {
res->x = -res->width;
res->y = -res->height;
}
}
/** Detach a wibox titlebar from its client.
@ -223,6 +239,11 @@ titlebar_client_attach(client_t *c, wibox_t *t)
t->need_update = true;
/* Call update geometry. This will move the wibox to the right place,
* which might be the same as `wingeom', but then it will ban the
* titlebar if needed. */
titlebar_update_geometry(c);
if(t->isvisible)
xcb_map_window(globalconf.connection, t->sw.window);

View File

@ -30,7 +30,8 @@ void titlebar_geometry_compute(client_t *, area_t, area_t *);
void titlebar_init(client_t *);
void titlebar_client_detach(client_t *);
void titlebar_client_attach(client_t *, wibox_t *);
void titlebar_set_visible(wibox_t *t, bool visible);
void titlebar_set_visible(wibox_t *, bool);
void titlebar_ban(wibox_t *);
int luaA_titlebar_newindex(lua_State *, wibox_t *, awesome_token_t);
@ -130,6 +131,10 @@ titlebar_update_geometry(client_t *c)
/* Client geometry without titlebar, but including borders, since that is always consistent. */
titlebar_geometry_compute(c, titlebar_geometry_remove(c->titlebar, 0, c->geometry), &geom);
wibox_moveresize(c->titlebar, geom);
/* If the client is banned, move the titlebar out! */
if(c->isbanned)
titlebar_ban(c->titlebar);
}
#endif