From aace4eca254620491dcdacf362c981c11ca1160c Mon Sep 17 00:00:00 2001 From: Matthias Kruk Date: Mon, 24 May 2021 06:41:46 +0900 Subject: [PATCH] workspace: Don't redraw workspace if it doesn't need redrawing The mwm_redraw() function is called to redraw the clients as well as the status bar and other indicators. The current implementation calls monitor_redraw() and workspace_redraw() on all monitors and workspaces, respectively, so these functions must make sure not to redraw anything if it isn't necessary. This commit changes the workspace_redraw() function so it does not redraw the workspace if it was not explicitly requested. --- workspace.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/workspace.c b/workspace.c index 53172b7..cb38d82 100644 --- a/workspace.c +++ b/workspace.c @@ -228,22 +228,24 @@ int workspace_redraw(struct workspace *workspace) return(-EINVAL); } - first = loop_get_iter(&workspace->clients); + if(workspace->needs_redraw) { + first = loop_get_iter(&workspace->clients); - if(first) { - cur = first; + if(first) { + cur = first; - do { - struct client *client; + do { + struct client *client; - client = (struct client*)loop_iter_get_data(cur); - client_redraw(client); + client = (struct client*)loop_iter_get_data(cur); + client_redraw(client); - cur = loop_iter_get_next(cur); - } while(cur != first); - } + cur = loop_iter_get_next(cur); + } while(cur != first); + } - workspace->needs_redraw = 0; + workspace->needs_redraw = 0; + } return(0); } -- 2.47.3