From 2c6dc1048db23b4d6ddc03f8107ac488dbedb199 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Thu, 5 Feb 2009 17:55:59 +0100 Subject: [PATCH] titlebar: correctly ban/unban (FS#443) Signed-off-by: Julien Danjou --- client.c | 16 +--------------- titlebar.c | 33 +++++++++++++++++++++++++++------ titlebar.h | 7 ++++++- 3 files changed, 34 insertions(+), 22 deletions(-) diff --git a/client.c b/client.c index 9faafa2b..ba4b1cfb 100644 --- a/client.c +++ b/client.c @@ -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; diff --git a/titlebar.c b/titlebar.c index 14424b17..7fa6e972 100644 --- a/titlebar.c +++ b/titlebar.c @@ -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); diff --git a/titlebar.h b/titlebar.h index 1e86d277..691b6950 100644 --- a/titlebar.h +++ b/titlebar.h @@ -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