Refactor event_handle_configurerequest

Before this commit, the code in here first handled clients changing its
x/y position and afterwards it handled resizes. This meant that the
special case of "client resizes without moving itself so we need to
apply gravity" had to have special checks on whether the client moved
itself or not.

Change the code so that resizes are handled first and moves later. This
naturally handles the problem: If the client resizes and moves itself,
the move done for the resize is later overwritten when the move is
handled.

No functional changes are intended.

Signed-off-by: Uli Schlachter <uli.schlachter@informatik.uni-oldenburg.de>
This commit is contained in:
Uli Schlachter 2018-08-20 10:28:21 +02:00
parent 81da3a2ce7
commit 2ebd120223
1 changed files with 11 additions and 16 deletions

27
event.c
View File

@ -343,16 +343,6 @@ event_handle_configurerequest(xcb_configure_request_event_t *ev)
lua_State *L = globalconf_get_lua_State(); lua_State *L = globalconf_get_lua_State();
if(ev->value_mask & XCB_CONFIG_WINDOW_X)
{
geometry.x = ev->x;
xwindow_translate_for_gravity(c->size_hints.win_gravity, deco_left, 0, deco_right, 0, &geometry.x, NULL);
}
if(ev->value_mask & XCB_CONFIG_WINDOW_Y)
{
geometry.y = ev->y;
xwindow_translate_for_gravity(c->size_hints.win_gravity, 0, deco_top, 0, deco_bottom, NULL, &geometry.y);
}
if(ev->value_mask & XCB_CONFIG_WINDOW_WIDTH) if(ev->value_mask & XCB_CONFIG_WINDOW_WIDTH)
{ {
uint16_t old_w = geometry.width; uint16_t old_w = geometry.width;
@ -383,12 +373,17 @@ event_handle_configurerequest(xcb_configure_request_event_t *ev)
/* If the client resizes without moving itself, apply window gravity */ /* If the client resizes without moving itself, apply window gravity */
if(c->size_hints.flags & XCB_ICCCM_SIZE_HINT_P_WIN_GRAVITY) 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_border, diff_border, diff_w, diff_h, &geometry.x, &geometry.y);
xwindow_translate_for_gravity(c->size_hints.win_gravity, diff_border, diff_border, diff_w, diff_h, &diff_x, &diff_y); }
if(!(ev->value_mask & XCB_CONFIG_WINDOW_X)) if(ev->value_mask & XCB_CONFIG_WINDOW_X)
geometry.x += diff_x; {
if(!(ev->value_mask & XCB_CONFIG_WINDOW_Y)) geometry.x = ev->x;
geometry.y += diff_y; xwindow_translate_for_gravity(c->size_hints.win_gravity, deco_left, 0, deco_right, 0, &geometry.x, NULL);
}
if(ev->value_mask & XCB_CONFIG_WINDOW_Y)
{
geometry.y = ev->y;
xwindow_translate_for_gravity(c->size_hints.win_gravity, 0, deco_top, 0, deco_bottom, NULL, &geometry.y);
} }
c->got_configure_request = true; c->got_configure_request = true;