From 3b97d1c1a7616177eabcd6e25ae19f245efa28b8 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sat, 10 Oct 2015 17:44:11 +0200 Subject: [PATCH] Apply window gravity for titlebar resizes Signed-off-by: Uli Schlachter --- objects/client.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/objects/client.c b/objects/client.c index 82127376..f14331d0 100644 --- a/objects/client.c +++ b/objects/client.c @@ -1844,27 +1844,43 @@ titlebar_resize(lua_State *L, int cidx, client_t *c, client_titlebar_t bar, int * 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; property_name = "property::titlebar_top"; break; case CLIENT_TITLEBAR_BOTTOM: geometry.height += change; + diff_bottom = change; property_name = "property::titlebar_bottom"; break; case CLIENT_TITLEBAR_RIGHT: geometry.width += change; + diff_right = change; property_name = "property::titlebar_right"; break; case CLIENT_TITLEBAR_LEFT: geometry.width += change; + diff_left = change; property_name = "property::titlebar_left"; 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);