From baaff93a7349a9da67b4b8f291a62820828f14bd Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Thu, 15 Sep 2016 18:48:56 +0200 Subject: [PATCH] Only configure client geometries once per main loop iteration This should "protect" the user from some stupidities that Lua code might be doing that e.g. makes a client jump to another position and then immediately back to where it was before. Only the last change in a single main loop iteration will actually have any effect. Original idea by Daniel here: https://github.com/awesomeWM/awesome/pull/174 Signed-off-by: Uli Schlachter --- objects/client.c | 76 +++++++++++++++++++++++++++++------------------- objects/client.h | 3 ++ 2 files changed, 49 insertions(+), 30 deletions(-) diff --git a/objects/client.c b/objects/client.c index 054aeb7f..e561aae2 100644 --- a/objects/client.c +++ b/objects/client.c @@ -1135,9 +1135,55 @@ client_border_refresh(void) window_border_refresh((window_t *) *c); } +static void +client_geometry_refresh(void) +{ + client_ignore_enterleave_events(); + foreach(_c, globalconf.clients) + { + client_t *c = *_c; + + /* Compute the client window's and frame window's geometry */ + area_t geometry = c->geometry; + area_t real_geometry = c->geometry; + if (!c->fullscreen) + { + real_geometry.x = c->titlebar[CLIENT_TITLEBAR_LEFT].size; + real_geometry.y = c->titlebar[CLIENT_TITLEBAR_TOP].size; + real_geometry.width -= c->titlebar[CLIENT_TITLEBAR_LEFT].size; + real_geometry.width -= c->titlebar[CLIENT_TITLEBAR_RIGHT].size; + real_geometry.height -= c->titlebar[CLIENT_TITLEBAR_TOP].size; + real_geometry.height -= c->titlebar[CLIENT_TITLEBAR_BOTTOM].size; + } else { + real_geometry.x = 0; + real_geometry.y = 0; + } + + /* Is there anything to do? */ + if (AREA_EQUAL(geometry, c->x11_frame_geometry) + && AREA_EQUAL(real_geometry, c->x11_client_geometry)) + continue; + + xcb_configure_window(globalconf.connection, c->frame_window, + XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, + (uint32_t[]) { geometry.x, geometry.y, geometry.width, geometry.height }); + xcb_configure_window(globalconf.connection, c->window, + XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, + (uint32_t[]) { real_geometry.x, real_geometry.y, real_geometry.width, real_geometry.height }); + + c->x11_frame_geometry = geometry; + c->x11_client_geometry = real_geometry; + + /* ICCCM 4.2.3 says something else, but Java always needs this... */ + client_send_configure(c); + } + client_restore_enterleave_events(); +} + void client_refresh(void) { + client_geometry_refresh(); client_border_refresh(); client_focus_refresh(); } @@ -1517,36 +1563,6 @@ client_resize_do(client_t *c, area_t geometry) area_t old_geometry = c->geometry; c->geometry = geometry; - /* Ignore all spurious enter/leave notify events */ - client_ignore_enterleave_events(); - - /* Configure the client for its new size */ - area_t real_geometry = geometry; - if (!c->fullscreen) - { - real_geometry.x = c->titlebar[CLIENT_TITLEBAR_LEFT].size; - real_geometry.y = c->titlebar[CLIENT_TITLEBAR_TOP].size; - real_geometry.width -= c->titlebar[CLIENT_TITLEBAR_LEFT].size; - real_geometry.width -= c->titlebar[CLIENT_TITLEBAR_RIGHT].size; - real_geometry.height -= c->titlebar[CLIENT_TITLEBAR_TOP].size; - real_geometry.height -= c->titlebar[CLIENT_TITLEBAR_BOTTOM].size; - } else { - real_geometry.x = 0; - real_geometry.y = 0; - } - - xcb_configure_window(globalconf.connection, c->frame_window, - XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, - (uint32_t[]) { geometry.x, geometry.y, geometry.width, geometry.height }); - xcb_configure_window(globalconf.connection, c->window, - XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, - (uint32_t[]) { real_geometry.x, real_geometry.y, real_geometry.width, real_geometry.height }); - - /* ICCCM 4.2.3 says something else, but Java always needs this... */ - client_send_configure(c); - - client_restore_enterleave_events(); - luaA_object_push(L, c); if (!AREA_EQUAL(old_geometry, geometry)) luaA_object_emit_signal(L, -1, "property::geometry", 0); diff --git a/objects/client.h b/objects/client.h index 733a4362..e2dcfc8e 100644 --- a/objects/client.h +++ b/objects/client.h @@ -61,6 +61,9 @@ struct client_t char *class, *instance; /** Window geometry */ area_t geometry; + /** Old window geometry currently configured in X11 */ + area_t x11_client_geometry; + area_t x11_frame_geometry; /** Startup ID */ char *startup_id; /** True if the client is sticky */