From: Michael Stapelberg Date: Sat, 8 Aug 2009 19:31:42 +0000 (+0200) Subject: Reduce number of configuration requests and thus flickering X-Git-Tag: 3.c~17 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ceb3670d65d5245e4e8032f3d3ee0b281d99635c;p=i3%2Fi3 Reduce number of configuration requests and thus flickering This reduces flickering when opening new windows and especially moving existing windows in tiling mode. Especially noticable on multi-monitor setups. --- diff --git a/include/layout.h b/include/layout.h index 7fbce691..fdaacd72 100644 --- a/include/layout.h +++ b/include/layout.h @@ -46,7 +46,10 @@ void redecorate_window(xcb_connection_t *conn, Client *client); void reposition_client(xcb_connection_t *conn, Client *client); /** - * Pushes the client’s width/height to X11 and resizes the child window + * Pushes the client’s width/height to X11 and resizes the child window. This + * function also updates the client’s position, so if you work on tiling clients + * only, you can use this function instead of separate calls to reposition_client + * and resize_client to reduce flickering. * */ void resize_client(xcb_connection_t *conn, Client *client); diff --git a/src/layout.c b/src/layout.c index 5e63c9c7..3f350d88 100644 --- a/src/layout.c +++ b/src/layout.c @@ -213,16 +213,23 @@ void reposition_client(xcb_connection_t *conn, Client *client) { } /* - * Pushes the client’s width/height to X11 and resizes the child window + * Pushes the client’s width/height to X11 and resizes the child window. This + * function also updates the client’s position, so if you work on tiling clients + * only, you can use this function instead of separate calls to reposition_client + * and resize_client to reduce flickering. * */ void resize_client(xcb_connection_t *conn, Client *client) { i3Font *font = load_font(conn, config.font); + LOG("frame 0x%08x needs to be pushed to %dx%d\n", client->frame, client->rect.x, client->rect.y); LOG("resizing client 0x%08x to %d x %d\n", client->frame, client->rect.width, client->rect.height); xcb_configure_window(conn, client->frame, - XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, - &(client->rect.width)); + XCB_CONFIG_WINDOW_X | + XCB_CONFIG_WINDOW_Y | + XCB_CONFIG_WINDOW_WIDTH | + XCB_CONFIG_WINDOW_HEIGHT, + &(client->rect.x)); /* Adjust the position of the child inside its frame. * The coordinates of the child are relative to its frame, we @@ -317,15 +324,13 @@ void render_container(xcb_connection_t *conn, Container *container) { if (client->force_reconfigure | update_if_necessary(&(client->rect.x), container->x) | update_if_necessary(&(client->rect.y), container->y + - (container->height / num_clients) * current_client)) - reposition_client(conn, client); - - /* TODO: vertical default layout */ - if (client->force_reconfigure | + (container->height / num_clients) * current_client) | update_if_necessary(&(client->rect.width), container->width) | update_if_necessary(&(client->rect.height), container->height / num_clients)) resize_client(conn, client); + /* TODO: vertical default layout */ + client->force_reconfigure = false; current_client++; @@ -392,10 +397,7 @@ void render_container(xcb_connection_t *conn, Container *container) { * Note the bitwise OR instead of logical OR to force evaluation of both statements */ if (client->force_reconfigure | update_if_necessary(&(client->rect.x), container->x) | - update_if_necessary(&(client->rect.y), container->y + (decoration_height * num_clients))) - reposition_client(conn, client); - - if (client->force_reconfigure | + update_if_necessary(&(client->rect.y), container->y + (decoration_height * num_clients)) | update_if_necessary(&(client->rect.width), container->width) | update_if_necessary(&(client->rect.height), container->height - (decoration_height * num_clients))) resize_client(conn, client);