]> code.delx.au - spectrwm/commitdiff
Fix some workspace switching nits:
authorRyan McBride <mcbride@countersiege.com>
Wed, 21 Jan 2009 08:45:36 +0000 (08:45 +0000)
committerRyan McBride <mcbride@countersiege.com>
Wed, 21 Jan 2009 08:45:36 +0000 (08:45 +0000)
- Don't XMapRaised windows if they need to be moved/resized first.
- Keep focus in the current region if possible.

scrotwm.c

index 621942ec165d0615e1ff8a10bb1cc74d480fee41..50ff0f4f41c6d7d22c0068add897b7cbdab1305e 100644 (file)
--- a/scrotwm.c
+++ b/scrotwm.c
@@ -220,6 +220,7 @@ struct workspace {
        struct layout           *cur_layout;    /* current layout handlers */
        struct ws_win           *focus;         /* may be NULL */
        struct swm_region       *r;             /* may be NULL */
+       struct swm_region       *prev_r;        /* may be NULL */
        struct ws_win_list      winlist;        /* list of windows in ws */
 
        /* stacker state */
@@ -768,26 +769,33 @@ switchws(struct swm_region *r, union arg *args)
 
        other_r = new_ws->r;
        if (!other_r) {
-               /* if the other workspace is hidden, switch windows */
-               /* map new window first to prevent ugly blinking */
-               TAILQ_FOREACH(win, &new_ws->winlist, entry)
-                       XMapRaised(display, win->id);
-
-               TAILQ_FOREACH(win, &old_ws->winlist, entry)
-                       XUnmapWindow(display, win->id);
+               /* 
+                * If the other workspace is hidden and the workspace was
+                * previously mapped here, just swap switch windows.
+                * map new window first to prevent ugly blinking
+                */
+               if (new_ws->restack == 0 && new_ws->prev_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);
+               }
+               old_ws->prev_r = old_ws->r;
                old_ws->r = NULL;
-               old_ws->restack = 1;
        } else {
                other_r->ws = old_ws;
                old_ws->r = other_r;
        }
        this_r->ws = new_ws;
+       new_ws->prev_r = new_ws->r;
        new_ws->r = this_r;
 
        ignore_enter = 1;
        /* set focus */
-       if (new_ws->focus)
+       if (!new_ws->focus)
+               new_ws->focus = TAILQ_FIRST(&new_ws->winlist);
+       if (new_ws->focus )
                focus_win(new_ws->focus);
        stack();
        bar_update();
@@ -1607,8 +1615,12 @@ destroynotify(XEvent *e)
                TAILQ_REMOVE(&ws->winlist, win, entry);
                set_win_state(win, WithdrawnState);
                free(win);
+
+               if (ws->r == NULL)
+                       ws->restack = 1;
+               else
+                       stack();
        }
-       stack();
 }
 
 void