client, titlebar: fix some issues involving titlbars and dialogs.
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
88713851ab
commit
b8a371864b
11
client.c
11
client.c
|
@ -790,8 +790,8 @@ client_resize(client_t *c, area_t geometry, bool hints)
|
||||||
/* This at least doesn't break expectations about events. */
|
/* This at least doesn't break expectations about events. */
|
||||||
if (c->isbanned)
|
if (c->isbanned)
|
||||||
{
|
{
|
||||||
geometry.x = values[0] = - (geometry_internal.width + 2 * c->border);
|
geometry_internal.x = values[0] = - (geometry_internal.width + 2 * c->border);
|
||||||
geometry.y = values[1] = - (geometry_internal.height + 2 * c->border);
|
geometry_internal.y = values[1] = - (geometry_internal.height + 2 * c->border);
|
||||||
}
|
}
|
||||||
|
|
||||||
xcb_configure_window(globalconf.connection, c->win,
|
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_configure_window(globalconf.connection, c->win,
|
||||||
XCB_CONFIG_WINDOW_BORDER_WIDTH, &w);
|
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);
|
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");
|
hooks_property(c, "border_width");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,11 @@ function add(c, args)
|
||||||
c.titlebar = tb
|
c.titlebar = tb
|
||||||
|
|
||||||
-- Resize the client so the same amount of space is occupied as before.
|
-- 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)
|
||||||
update(c, "geometry")
|
update(c, "geometry")
|
||||||
|
|
27
titlebar.c
27
titlebar.c
|
@ -61,6 +61,11 @@ client_getbytitlebarwin(xcb_window_t win)
|
||||||
return NULL;
|
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
|
void
|
||||||
titlebar_geometry_compute(client_t *c, area_t geometry, area_t *res)
|
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;
|
break;
|
||||||
}
|
}
|
||||||
res->x = geometry.x + x_offset;
|
res->x = geometry.x + x_offset;
|
||||||
res->y = geometry.y;
|
res->y = geometry.y - c->titlebar->sw.geometry.height;
|
||||||
res->width = width;
|
res->width = width;
|
||||||
res->height = c->titlebar->sw.geometry.height;
|
res->height = c->titlebar->sw.geometry.height;
|
||||||
break;
|
break;
|
||||||
|
@ -102,7 +107,7 @@ titlebar_geometry_compute(client_t *c, area_t geometry, area_t *res)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
res->x = geometry.x + x_offset;
|
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->width = width;
|
||||||
res->height = c->titlebar->sw.geometry.height;
|
res->height = c->titlebar->sw.geometry.height;
|
||||||
break;
|
break;
|
||||||
|
@ -119,7 +124,7 @@ titlebar_geometry_compute(client_t *c, area_t geometry, area_t *res)
|
||||||
y_offset = (geometry.height - height) / 2;
|
y_offset = (geometry.height - height) / 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
res->x = geometry.x;
|
res->x = geometry.x - c->titlebar->sw.geometry.width;
|
||||||
res->y = geometry.y + y_offset;
|
res->y = geometry.y + y_offset;
|
||||||
res->width = c->titlebar->sw.geometry.width;
|
res->width = c->titlebar->sw.geometry.width;
|
||||||
res->height = height;
|
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;
|
y_offset = (geometry.height - height) / 2;
|
||||||
break;
|
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->y = geometry.y + y_offset;
|
||||||
res->width = c->titlebar->sw.geometry.width;
|
res->width = c->titlebar->sw.geometry.width;
|
||||||
res->height = height;
|
res->height = height;
|
||||||
break;
|
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.
|
/** Detach a wibox titlebar from its client.
|
||||||
|
@ -176,6 +187,8 @@ titlebar_client_attach(client_t *c, wibox_t *t)
|
||||||
if(c && t)
|
if(c && t)
|
||||||
{
|
{
|
||||||
area_t wingeom;
|
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 */
|
/* check if titlebar is already on a client */
|
||||||
titlebar_client_detach(client_getbytitlebar(t));
|
titlebar_client_detach(client_getbytitlebar(t));
|
||||||
|
@ -200,7 +213,8 @@ titlebar_client_attach(client_t *c, wibox_t *t)
|
||||||
break;
|
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,
|
simplewindow_init(&t->sw, c->phys_screen,
|
||||||
wingeom, 0, t->sw.orientation,
|
wingeom, 0, t->sw.orientation,
|
||||||
|
@ -209,9 +223,6 @@ titlebar_client_attach(client_t *c, wibox_t *t)
|
||||||
|
|
||||||
t->need_update = true;
|
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)
|
if(t->isvisible)
|
||||||
xcb_map_window(globalconf.connection, t->sw.window);
|
xcb_map_window(globalconf.connection, t->sw.window);
|
||||||
|
|
||||||
|
|
20
titlebar.h
20
titlebar.h
|
@ -127,23 +127,9 @@ titlebar_update_geometry(client_t *c)
|
||||||
if(!c->titlebar)
|
if(!c->titlebar)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
titlebar_geometry_compute(c, c->geometry, &geom);
|
/* Client geometry without titlebar, but including borders, since that is always consistent. */
|
||||||
/* Can't actually move titlebar right now, but we will resize it. */
|
titlebar_geometry_compute(c, titlebar_geometry_remove(c->titlebar, 0, c->geometry), &geom);
|
||||||
if(c->isbanned)
|
wibox_moveresize(c->titlebar, geom);
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue