From 21c7a69812e40e8015b4c48a3d7e7dc1479d6371 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Fri, 1 Apr 2011 22:40:12 +0200 Subject: [PATCH] optimization: when moving floating windows, render/push only the floatingcon --- include/x.h | 8 ++++++++ src/floating.c | 8 ++++---- src/x.c | 10 ++++++---- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/include/x.h b/include/x.h index 15d37420..827f6f85 100644 --- a/include/x.h +++ b/include/x.h @@ -60,6 +60,14 @@ void x_window_kill(xcb_window_t window); */ void x_draw_decoration(Con *con); +/** + * This function pushes the properties of each node of the layout tree to + * X11 if they have changed (like the map state, position of the window, …). + * It recursively traverses all children of the given node. + * + */ +void x_push_node(Con *con, bool skip_decoration); + /** * Pushes all changes (state of each node, see x_push_node() and the window * stack) to X11. diff --git a/src/floating.c b/src/floating.c index 9d4e1cf8..6cc9a168 100644 --- a/src/floating.c +++ b/src/floating.c @@ -231,10 +231,10 @@ DRAGGING_CB(drag_window_callback) { /* Reposition the client correctly while moving */ con->rect.x = old_rect->x + (new_x - event->root_x); con->rect.y = old_rect->y + (new_y - event->root_y); - /* TODO: don’t re-render the whole tree just because we change - * coordinates of a floating window */ - tree_render(); - x_push_changes(croot); + + render_con(con, false); + x_push_node(con, true); + xcb_flush(conn); } /* diff --git a/src/x.c b/src/x.c index ee9e0a43..9ea87644 100644 --- a/src/x.c +++ b/src/x.c @@ -442,7 +442,7 @@ copy_pixmaps: * It recursively traverses all children of the given node. * */ -static void x_push_node(Con *con) { +void x_push_node(Con *con, bool skip_decoration) { Con *current; con_state *state; Rect rect = con->rect; @@ -582,9 +582,11 @@ static void x_push_node(Con *con) { * in focus order to display the focused client in a stack first when * switching workspaces (reduces flickering). */ TAILQ_FOREACH(current, &(con->focus_head), focused) - x_push_node(current); + x_push_node(current, skip_decoration); - if (con->type != CT_ROOT && con->type != CT_OUTPUT && con->mapped) + if (!skip_decoration && + (con->type != CT_ROOT && con->type != CT_OUTPUT) && + con->mapped) x_draw_decoration(con); } @@ -687,7 +689,7 @@ void x_push_changes(Con *con) { DLOG("Done, EnterNotify re-enabled\n"); DLOG("\n\n PUSHING CHANGES\n\n"); - x_push_node(con); + x_push_node(con, false); xcb_window_t to_focus = focused->frame; if (focused->window != NULL)