client, titlebar: fix some issues involving titlbars and dialogs.

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Maarten Maathuis 2009-02-02 20:16:57 +01:00 committed by Julien Danjou
parent 88713851ab
commit b8a371864b
4 changed files with 36 additions and 28 deletions

View File

@ -790,8 +790,8 @@ client_resize(client_t *c, area_t geometry, bool hints)
/* This at least doesn't break expectations about events. */
if (c->isbanned)
{
geometry.x = values[0] = - (geometry_internal.width + 2 * c->border);
geometry.y = values[1] = - (geometry_internal.height + 2 * c->border);
geometry_internal.x = values[0] = - (geometry_internal.width + 2 * c->border);
geometry_internal.y = values[1] = - (geometry_internal.height + 2 * c->border);
}
xcb_configure_window(globalconf.connection, c->win,
@ -1248,8 +1248,15 @@ client_setborder(client_t *c, int width)
xcb_configure_window(globalconf.connection, c->win,
XCB_CONFIG_WINDOW_BORDER_WIDTH, &w);
/* Maintain original size of client and also allow titlebar to be properly sized. */
/* Don't forget that geometry is including border size. */
client_resize(c, c->geometry, false);
client_need_arrange(c);
/* Changing border size also affects the size of the titlebar. */
if (c->titlebar)
titlebar_update_geometry(c);
hooks_property(c, "border_width");
}

View File

@ -123,7 +123,11 @@ function add(c, args)
c.titlebar = tb
-- Resize the client so the same amount of space is occupied as before.
c:geometry(old_geom)
-- But not when it's a dialog, because applications remember this new size.
-- And everytime you open the dialog it shrinks further.
if c.type ~= "dialog" then
c:geometry(old_geom)
end
update(c)
update(c, "geometry")

View File

@ -61,6 +61,11 @@ client_getbytitlebarwin(xcb_window_t win)
return NULL;
}
/** Get titlebar area.
* \param c The client
* \param geometry The client geometry including borders, excluding titlebars.
* \param res Pointer to area of titlebar, must be allocated already.
*/
void
titlebar_geometry_compute(client_t *c, area_t geometry, area_t *res)
{
@ -84,7 +89,7 @@ titlebar_geometry_compute(client_t *c, area_t geometry, area_t *res)
break;
}
res->x = geometry.x + x_offset;
res->y = geometry.y;
res->y = geometry.y - c->titlebar->sw.geometry.height;
res->width = width;
res->height = c->titlebar->sw.geometry.height;
break;
@ -102,7 +107,7 @@ titlebar_geometry_compute(client_t *c, area_t geometry, area_t *res)
break;
}
res->x = geometry.x + x_offset;
res->y = geometry.y + geometry.height - c->titlebar->sw.geometry.height;
res->y = geometry.y + geometry.height;
res->width = width;
res->height = c->titlebar->sw.geometry.height;
break;
@ -119,7 +124,7 @@ titlebar_geometry_compute(client_t *c, area_t geometry, area_t *res)
y_offset = (geometry.height - height) / 2;
break;
}
res->x = geometry.x;
res->x = geometry.x - c->titlebar->sw.geometry.width;
res->y = geometry.y + y_offset;
res->width = c->titlebar->sw.geometry.width;
res->height = height;
@ -137,12 +142,18 @@ titlebar_geometry_compute(client_t *c, area_t geometry, area_t *res)
y_offset = (geometry.height - height) / 2;
break;
}
res->x = geometry.x + geometry.width - c->titlebar->sw.geometry.width;
res->x = geometry.x + geometry.width;
res->y = geometry.y + y_offset;
res->width = c->titlebar->sw.geometry.width;
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.
@ -176,6 +187,8 @@ titlebar_client_attach(client_t *c, wibox_t *t)
if(c && t)
{
area_t wingeom;
/* Get geometry prior to any titlebar changes. */
area_t curgeom = titlebar_geometry_remove(c->titlebar, 0, c->geometry);
/* check if titlebar is already on a client */
titlebar_client_detach(client_getbytitlebar(t));
@ -200,7 +213,8 @@ titlebar_client_attach(client_t *c, wibox_t *t)
break;
}
titlebar_geometry_compute(c, c->geometry, &wingeom);
/* Client geometry without titlebar, but including borders, since that is always consistent. */
titlebar_geometry_compute(c, curgeom, &wingeom);
simplewindow_init(&t->sw, c->phys_screen,
wingeom, 0, t->sw.orientation,
@ -209,9 +223,6 @@ titlebar_client_attach(client_t *c, wibox_t *t)
t->need_update = true;
/* This may seem useless, but it's the cleanest way to avoid seeing titlebars for banned clients. */
titlebar_update_geometry(c);
if(t->isvisible)
xcb_map_window(globalconf.connection, t->sw.window);

View File

@ -127,23 +127,9 @@ titlebar_update_geometry(client_t *c)
if(!c->titlebar)
return;
titlebar_geometry_compute(c, c->geometry, &geom);
/* Can't actually move titlebar right now, but we will resize it. */
if(c->isbanned)
{
area_t moved_geom = geom;
/* Make sure it stays outside the viewport. */
moved_geom.x = - geom.width;
moved_geom.y = - geom.height;
wibox_moveresize(c->titlebar, moved_geom);
/* Store the real geometry. */
c->titlebar->sw.geometry = geom;
}
else
wibox_moveresize(c->titlebar, geom);
/* 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);
}
#endif