From 367c3acbcdbf8f4cbc18a121fbdd310525721878 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sat, 10 Oct 2015 17:41:05 +0200 Subject: [PATCH] Apply window gravity when a window moves itself This just makes us do what ICCCM requires us to do. Tested via metacity's test-gravity.c. Signed-off-by: Uli Schlachter --- event.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/event.c b/event.c index 28a9b6a0..af58d3ac 100644 --- a/event.c +++ b/event.c @@ -311,19 +311,30 @@ event_handle_configurerequest(xcb_configure_request_event_t *ev) if((c = client_getbywin(ev->window))) { area_t geometry = c->geometry; + uint16_t bw = c->border_width; + uint16_t tb_left = c->titlebar[CLIENT_TITLEBAR_LEFT].size; + uint16_t tb_right = c->titlebar[CLIENT_TITLEBAR_RIGHT].size; + uint16_t tb_top = c->titlebar[CLIENT_TITLEBAR_TOP].size; + uint16_t tb_bottom = c->titlebar[CLIENT_TITLEBAR_BOTTOM].size; + uint16_t deco_left = bw + tb_left; + uint16_t deco_right = bw + tb_right; + uint16_t deco_top = bw + tb_top; + uint16_t deco_bottom = bw + tb_bottom; int16_t diff_w = 0, diff_h = 0, diff_border = 0; if(ev->value_mask & XCB_CONFIG_WINDOW_X) { + int16_t diff = 0; geometry.x = ev->x; - /* The ConfigureRequest specifies the position of the outer corner of the client window, we want the frame */ - geometry.x -= c->border_width; + xwindow_translate_for_gravity(c->size_hints.win_gravity, deco_left, 0, deco_right, 0, &diff, NULL); + geometry.x += diff; } if(ev->value_mask & XCB_CONFIG_WINDOW_Y) { + int16_t diff = 0; geometry.y = ev->y; - /* The ConfigureRequest specifies the position of the outer corner of the client window, we want the frame */ - geometry.y -= c->border_width; + xwindow_translate_for_gravity(c->size_hints.win_gravity, 0, deco_top, 0, deco_bottom, NULL, &diff); + geometry.y += diff; } if(ev->value_mask & XCB_CONFIG_WINDOW_WIDTH) {