Apply window gravity for titlebar resizes

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2015-10-10 17:44:11 +02:00
parent cd5cd52c20
commit 9c7cc12e5f
1 changed files with 20 additions and 0 deletions

View File

@ -1699,19 +1699,39 @@ titlebar_resize(client_t *c, client_titlebar_t bar, int size)
* titlebars should keep its current size!) */
area_t geometry = c->geometry;
int change = size - c->titlebar[bar].size;
int16_t diff_top = 0, diff_bottom = 0, diff_right = 0, diff_left = 0;
switch (bar) {
case CLIENT_TITLEBAR_TOP:
geometry.height += change;
diff_top = change;
break;
case CLIENT_TITLEBAR_BOTTOM:
geometry.height += change;
diff_bottom = change;
break;
case CLIENT_TITLEBAR_RIGHT:
geometry.width += change;
diff_right = change;
break;
case CLIENT_TITLEBAR_LEFT:
geometry.width += change;
diff_left = change;
break;
default:
fatal("Unknown titlebar kind %d\n", (int) bar);
}
if(c->size_hints.flags & XCB_ICCCM_SIZE_HINT_P_WIN_GRAVITY)
{
int16_t diff_x = 0, diff_y = 0;
xwindow_translate_for_gravity(c->size_hints.win_gravity,
diff_left, diff_top,
diff_right, diff_bottom,
&diff_x, &diff_y);
geometry.x += diff_x;
geometry.y += diff_y;
}
c->titlebar[bar].size = size;
client_resize_do(c, geometry, true, false);
}