From 6a26c21e75b818d33cf00653fe79e78d1fdcae1d Mon Sep 17 00:00:00 2001 From: Ryan McBride Date: Thu, 1 Oct 2009 09:51:31 +0000 Subject: [PATCH] Stop annoying flicker when a hidden workspace is mapped into a different region from where it was before (the windows are raised over that old workspace before being restacked in the correct location). Do this by keeping track of where the workspace USED to be, and deferring the XMapRaised() until stack() if the new location does not match the old one. --- scrotwm.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/scrotwm.c b/scrotwm.c index d6a984c..a925fa0 100644 --- a/scrotwm.c +++ b/scrotwm.c @@ -338,6 +338,7 @@ struct workspace { struct ws_win *focus; /* may be NULL */ struct ws_win *focus_prev; /* may be NULL */ struct swm_region *r; /* may be NULL */ + struct swm_region *old_r; /* may be NULL */ struct ws_win_list winlist; /* list of windows in ws */ /* stacker state */ @@ -1217,12 +1218,18 @@ switchws(struct swm_region *r, union arg *args) other_r = new_ws->r; if (other_r == NULL) { /* if the other workspace is hidden, switch windows */ - /* map new window first to prevent ugly blinking */ + if (old_ws->r != NULL) + old_ws->old_r = old_ws->r; old_ws->r = NULL; old_ws->restack = 1; - TAILQ_FOREACH(win, &new_ws->winlist, entry) - XMapRaised(display, win->id); + /* + * Map new windows first if they were here before + * to minimize ugly blinking. + */ + if (new_ws->old_r == this_r) + TAILQ_FOREACH(win, &new_ws->winlist, entry) + XMapRaised(display, win->id); TAILQ_FOREACH(win, &old_ws->winlist, entry) XUnmapWindow(display, win->id); @@ -3735,7 +3742,7 @@ scan_xrandr(int i) /* remove any old regions */ while ((r = TAILQ_FIRST(&screens[i].rl)) != NULL) { - r->ws->r = NULL; + r->ws->old_r = r->ws->r = NULL; XDestroyWindow(display, r->bar_window); TAILQ_REMOVE(&screens[i].rl, r, entry); TAILQ_INSERT_TAIL(&screens[i].orl, r, entry); @@ -3860,6 +3867,7 @@ setup_screens(void) ws->restack = 1; ws->focus = NULL; ws->r = NULL; + ws->old_r = NULL; TAILQ_INIT(&ws->winlist); for (k = 0; layouts[k].l_stack != NULL; k++) -- 1.7.10.4