JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
Focus the right window when cycling through visible screens.
[spectrwm.git] / scrotwm.c
index e66aff4..e8361a7 100644 (file)
--- a/scrotwm.c
+++ b/scrotwm.c
@@ -96,8 +96,8 @@ static const char     *cvstag = "$scrotwm$";
 
 /* #define SWM_DEBUG */
 #ifdef SWM_DEBUG
-#define DPRINTF(x...)          do { if (swm_debug) fprintf(stderr, x); } while(0)
-#define DNPRINTF(n,x...)       do { if (swm_debug & n) fprintf(stderr, x); } while(0)
+#define DPRINTF(x...)          do { if (swm_debug) fprintf(stderr, x); } while (0)
+#define DNPRINTF(n,x...)       do { if (swm_debug & n) fprintf(stderr, x); } while (0)
 #define        SWM_D_MISC              0x0001
 #define        SWM_D_EVENT             0x0002
 #define        SWM_D_WS                0x0004
@@ -148,6 +148,8 @@ u_int32_t           swm_debug = 0
 #define WIDTH(r)               (r)->g.w
 #define HEIGHT(r)              (r)->g.h
 #define SWM_MAX_FONT_STEPS     (3)
+#define SWM_EV_PROLOGUE(x)     do { XGrabServer(x); } while (0)
+#define SWM_EV_EPILOGUE(x)     do { XUngrabServer(x); XFlush(x); } while (0)
 
 #ifndef SWM_LIB
 #define SWM_LIB                        "/usr/local/lib/libswmhack.so"
@@ -190,6 +192,7 @@ int                 bar_extra = 1;
 int                    bar_extra_running = 0;
 int                    bar_verbose = 1;
 int                    bar_height = 0;
+int                    stack_enabled = 1;
 int                    clock_enabled = 1;
 int                    title_name_enabled = 0;
 int                    title_class_enabled = 0;
@@ -319,12 +322,17 @@ void      new_region(struct swm_screen *, int, int, int, int);
 struct layout {
        void            (*l_stack)(struct workspace *, struct swm_geometry *);
        void            (*l_config)(struct workspace *, int);
+       u_int32_t       flags;
+#define SWM_L_FOCUSPREV                (1<<0)
+#define SWM_L_MAPONFOCUS       (1<<1)
+       char            *name;
 } layouts[] =  {
        /* stack,               configure */
-       { vertical_stack,       vertical_config},
-       { horizontal_stack,     horizontal_config},
-       { max_stack,            NULL},
-       { NULL,                 NULL},
+       { vertical_stack,       vertical_config,        0,      "[|]" },
+       { horizontal_stack,     horizontal_config,      0,      "[-]" },
+       { max_stack,            NULL,
+         SWM_L_FOCUSPREV | SWM_L_MAPONFOCUS,                   "[ ]"},
+       { NULL,                 NULL,                   0},
 };
 
 #define SWM_H_SLICE            (32)
@@ -753,6 +761,7 @@ bar_update(void)
        char                    s[SWM_BAR_MAX];
        char                    loc[SWM_BAR_MAX];
        char                    *b;
+       char                    *stack = "";
 
        if (bar_enabled == 0)
                return;
@@ -785,12 +794,15 @@ bar_update(void)
                        if (r && r->ws)
                                bar_class_name(s, sizeof s, r->ws->focus);
 
-                       snprintf(loc, sizeof loc, "%d:%d    %s %s    %s",
-                           x++, r->ws->idx + 1, s, bar_ext, bar_vertext);
+                       if (stack_enabled)
+                               stack = r->ws->cur_layout->name;
+
+                       snprintf(loc, sizeof loc, "%d:%d %s   %s %s    %s",
+                           x++, r->ws->idx + 1, stack, s, bar_ext,
+                           bar_vertext);
                        bar_print(r, loc);
                }
        }
-       XSync(display, False);
        alarm(bar_delay);
 }
 
@@ -1222,6 +1234,8 @@ focus_win(struct ws_win *win)
                XSetWindowBorder(display, win->id,
                    win->ws->r->s->c[SWM_S_COLOR_FOCUS].color);
                grabbuttons(win, 1);
+               if (win->ws->cur_layout->flags & SWM_L_MAPONFOCUS)
+                       XMapRaised(display, win->id);
                XSetInputFocus(display, win->id,
                    RevertToPointerRoot, CurrentTime);
                XSync(display, False);
@@ -1233,7 +1247,7 @@ switchws(struct swm_region *r, union arg *args)
 {
        int                     wsid = args->id;
        struct swm_region       *this_r, *other_r;
-       struct ws_win           *win, *winfocus = NULL;
+       struct ws_win           *win, *winfocus = NULL, *parent = NULL;
        struct workspace        *new_ws, *old_ws;
 
        this_r = r;
@@ -1269,7 +1283,9 @@ switchws(struct swm_region *r, union arg *args)
                 */
                if (new_ws->old_r == this_r)
                        TAILQ_FOREACH(win, &new_ws->winlist, entry)
-                               XMapRaised(display, win->id);
+                               if (!(win->ws->cur_layout->flags &
+                                   SWM_L_MAPONFOCUS))
+                                       XMapRaised(display, win->id);
 
                TAILQ_FOREACH(win, &old_ws->winlist, entry)
                        unmap_window(win);
@@ -1282,7 +1298,17 @@ switchws(struct swm_region *r, union arg *args)
 
        ignore_enter = 1;
        stack();
-       focus_win(winfocus);
+       if (winfocus) {
+               /* make sure we see the parent window */
+               if (winfocus->transient) {
+                       parent = find_window(winfocus->transient);
+                       if (parent)
+                               focus_win(parent);
+               }
+
+               focus_win(winfocus);
+       }
+       ignore_enter = 0;
        bar_update();
 }
 
@@ -1327,8 +1353,10 @@ cyclews(struct swm_region *r, union arg *args)
 void
 cyclescr(struct swm_region *r, union arg *args)
 {
-       struct swm_region       *rr;
-       int                     i;
+       struct swm_region       *rr = NULL;
+       struct workspace        *ws = NULL;
+       struct ws_win           *winfocus = NULL;
+       int                     i, x, y;
 
        /* do nothing if we don't have more than one screen */
        if (!(ScreenCount(display) > 1 || outputs > 1))
@@ -1349,10 +1377,28 @@ cyclescr(struct swm_region *r, union arg *args)
        default:
                return;
        };
+       if (rr == NULL)
+               return;
+
+       ws = rr->ws;
+       winfocus = ws->focus;
+       if (winfocus == NULL)
+               winfocus = ws->focus_prev;
+       if (winfocus) {
+               /* use window coordinates */
+               x = winfocus->g.x + 1;
+               y = winfocus->g.y + 1;
+       } else {
+               /* use region coordinates */
+               x = rr->g.x + 1;
+               y = rr->g.y + 1 + bar_enabled ? bar_height : 0;
+       }
+
        unfocus_all();
        XSetInputFocus(display, PointerRoot, RevertToPointerRoot, CurrentTime);
-       XWarpPointer(display, None, rr->s[i].root, 0, 0, 0, 0, rr->g.x,
-           rr->g.y + bar_enabled ? bar_height : 0);
+       XWarpPointer(display, None, rr->s[i].root, 0, 0, 0, 0, x, y);
+
+       focus_win(winfocus);
 }
 
 void
@@ -1461,16 +1507,14 @@ focus(struct swm_region *r, union arg *args)
        if (winfocus == winlostfocus || winfocus == NULL)
                return;
 
-       XMapRaised(display, winfocus->id);
        focus_win(winfocus);
-       XSync(display, False);
 }
 
 void
 cycle_layout(struct swm_region *r, union arg *args)
 {
        struct workspace        *ws = r->ws;
-       struct ws_win           *winfocus;
+       struct ws_win           *winfocus, *parent = NULL;
 
        DNPRINTF(SWM_D_EVENT, "cycle_layout: workspace: %d\n", ws->idx);
 
@@ -1482,7 +1526,15 @@ cycle_layout(struct swm_region *r, union arg *args)
 
        ignore_enter = 1;
        stack();
-       focus_win(winfocus);
+       /* make sure we see the parent window */
+       if (winfocus) {
+               if (winfocus->transient)
+                       parent = find_window(winfocus->transient);
+               if (parent)
+                       focus_win(parent);
+               focus_win(winfocus);
+       }
+       ignore_enter = 0;
 }
 
 void
@@ -1875,6 +1927,9 @@ max_stack(struct workspace *ws, struct swm_geometry *g)
 
        DNPRINTF(SWM_D_STACK, "max_stack: workspace: %d\n", ws->idx);
 
+       if (ws == NULL)
+               return;
+
        winno = count_win(ws, 0);
        if (winno == 0 && count_win(ws, 1) == 0)
                return;
@@ -1891,15 +1946,17 @@ max_stack(struct workspace *ws, struct swm_geometry *g)
                        win->g.h = wc.height = gg.h;
                        mask = CWX | CWY | CWWidth | CWHeight | CWBorderWidth;
                        XConfigureWindow(display, win->id, mask, &wc);
+
+                       /* unmap only if we don't have multi screen */
                        if (win != ws->focus)
-                               unmap_window(win);
+                               if (!(ScreenCount(display) > 1 || outputs > 1))
+                                       unmap_window(win);
                }
        }
 
        /* put the last transient on top */
        if (wintrans) {
                stack_floater(wintrans, ws->r);
-               XMapRaised(display, wintrans->id);
                focus_win(wintrans); /* override */
        }
 }
@@ -1908,11 +1965,15 @@ void
 send_to_ws(struct swm_region *r, union arg *args)
 {
        int                     wsid = args->id;
-       struct ws_win           *win = r->ws->focus, *winfocus = NULL;
+       struct ws_win           *win = win, *winfocus = NULL;
        struct workspace        *ws, *nws;
        Atom                    ws_idx_atom = 0;
        unsigned char           ws_idx_str[SWM_PROPLEN];
 
+       if (r && r->ws)
+               win = r->ws->focus;
+       else
+               return;
        if (win == NULL)
                return;
 
@@ -1926,18 +1987,18 @@ send_to_ws(struct swm_region *r, union arg *args)
        if (TAILQ_FIRST(&ws->winlist) == win)
                winfocus = TAILQ_NEXT(win, entry);
        else {
-               winfocus = TAILQ_PREV(ws->focus, ws_win_list, entry);
+               winfocus = TAILQ_PREV(win, ws_win_list, entry);
                if (winfocus == NULL)
                        winfocus = TAILQ_LAST(&ws->winlist, ws_win_list);
        }
-       /* out of windows in ws so focus on nws instead */
+       /* out of windows in ws so focus on nws instead if we multi screen */
        if (winfocus == NULL)
-               winfocus = win;
+               if (ScreenCount(display) > 1 || outputs > 1)
+                       winfocus = win;
 
-       unmap_window(win);
 
+       unmap_window(win);
        TAILQ_REMOVE(&ws->winlist, win, entry);
-
        TAILQ_INSERT_TAIL(&nws->winlist, win, entry);
        win->ws = nws;
 
@@ -1957,7 +2018,8 @@ send_to_ws(struct swm_region *r, union arg *args)
        nws->restack = 1;
 
        stack();
-       focus_win(winfocus);
+       if (winfocus)
+               focus_win(winfocus);
 }
 
 void
@@ -2799,65 +2861,6 @@ grabbuttons(struct ws_win *win, int focused)
                    BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
 }
 
-void
-expose(XEvent *e)
-{
-       DNPRINTF(SWM_D_EVENT, "expose: window: %lu\n", e->xexpose.window);
-}
-
-void
-keypress(XEvent *e)
-{
-       unsigned int            i;
-       KeySym                  keysym;
-       XKeyEvent               *ev = &e->xkey;
-
-       DNPRINTF(SWM_D_EVENT, "keypress: window: %lu\n", ev->window);
-
-       keysym = XKeycodeToKeysym(display, (KeyCode)ev->keycode, 0);
-       for (i = 0; i < keys_length; i++)
-               if (keysym == keys[i].keysym
-                  && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)
-                  && keyfuncs[keys[i].funcid].func) {
-                       if (keys[i].funcid == kf_spawn_custom)
-                               spawn_custom(
-                                   root_to_region(ev->root),
-                                   &(keyfuncs[keys[i].funcid].args),
-                                   keys[i].spawn_name
-                                   );
-                       else
-                               keyfuncs[keys[i].funcid].func(
-                                   root_to_region(ev->root),
-                                   &(keyfuncs[keys[i].funcid].args)
-                                   );
-               }
-}
-
-void
-buttonpress(XEvent *e)
-{
-       XButtonPressedEvent     *ev = &e->xbutton;
-
-       struct ws_win           *win;
-       int                     i, action;
-
-       DNPRINTF(SWM_D_EVENT, "buttonpress: window: %lu\n", ev->window);
-
-       action = root_click;
-       if ((win = find_window(ev->window)) == NULL)
-               return;
-       else {
-               focus_win(win);
-               action = client_click;
-       }
-
-       for (i = 0; i < LENGTH(buttons); i++)
-               if (action == buttons[i].action && buttons[i].func &&
-                   buttons[i].button == ev->button &&
-                   CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state))
-                       buttons[i].func(win, &buttons[i].args);
-}
-
 const char *quirkname[] = {
        "NONE",         /* config string for "no value" */
        "FLOAT",
@@ -2874,8 +2877,10 @@ parsequirks(char *qstr, unsigned long *quirk)
 {
        char                    *cp, *name;
        int                     i;
+
        if (quirk == NULL)
                return (1);
+
        cp = qstr;
        *quirk = 0;
        while ((name = strsep(&cp, SWM_Q_WS)) != NULL) {
@@ -2904,6 +2909,7 @@ void
 setquirk(const char *class, const char *name, const int quirk)
 {
        int                     i, j;
+
        /* find existing */
        for (i = 0; i < quirks_length; i++) {
                if (!strcmp(quirks[i].class, class) &&
@@ -3012,11 +3018,11 @@ setup_quirks(void)
 /* conf file stuff */
 #define SWM_CONF_FILE  "scrotwm.conf"
 
-enum   { SWM_S_BAR_DELAY, SWM_S_BAR_ENABLED, SWM_S_CLOCK_ENABLED,
-         SWM_S_CYCLE_EMPTY, SWM_S_CYCLE_VISIBLE, SWM_S_SS_ENABLED,
-         SWM_S_TERM_WIDTH, SWM_S_TITLE_CLASS_ENABLED, SWM_S_TITLE_NAME_ENABLED,
-         SWM_S_BAR_FONT, SWM_S_BAR_ACTION, SWM_S_SPAWN_TERM, SWM_S_SS_APP,
-         SWM_S_DIALOG_RATIO };
+enum   { SWM_S_BAR_DELAY, SWM_S_BAR_ENABLED, SWM_S_STACK_ENABLED,
+         SWM_S_CLOCK_ENABLED, SWM_S_CYCLE_EMPTY, SWM_S_CYCLE_VISIBLE,
+         SWM_S_SS_ENABLED, SWM_S_TERM_WIDTH, SWM_S_TITLE_CLASS_ENABLED,
+         SWM_S_TITLE_NAME_ENABLED, SWM_S_BAR_FONT, SWM_S_BAR_ACTION,
+         SWM_S_SPAWN_TERM, SWM_S_SS_APP, SWM_S_DIALOG_RATIO };
 
 int
 setconfvalue(char *selector, char *value, int flags)
@@ -3028,6 +3034,9 @@ setconfvalue(char *selector, char *value, int flags)
        case SWM_S_BAR_ENABLED:
                bar_enabled = atoi(value);
                break;
+       case SWM_S_STACK_ENABLED:
+               stack_enabled = atoi(value);
+               break;
        case SWM_S_CLOCK_ENABLED:
                clock_enabled = atoi(value);
                break;
@@ -3122,6 +3131,7 @@ struct config_option configopt[] = {
        { "bar_action",                 setconfvalue,   SWM_S_BAR_ACTION },
        { "bar_delay",                  setconfvalue,   SWM_S_BAR_DELAY },
        { "bind",                       setconfbinding, 0 },
+       { "stack_enabled",              setconfvalue,   SWM_S_STACK_ENABLED },
        { "clock_enabled",              setconfvalue,   SWM_S_CLOCK_ENABLED },
        { "color_focus",                setconfcolor,   SWM_S_COLOR_FOCUS },
        { "color_unfocus",              setconfcolor,   SWM_S_COLOR_UNFOCUS },
@@ -3412,6 +3422,65 @@ unmanage_window(struct ws_win *win)
 }
 
 void
+expose(XEvent *e)
+{
+       DNPRINTF(SWM_D_EVENT, "expose: window: %lu\n", e->xexpose.window);
+}
+
+void
+keypress(XEvent *e)
+{
+       unsigned int            i;
+       KeySym                  keysym;
+       XKeyEvent               *ev = &e->xkey;
+
+       DNPRINTF(SWM_D_EVENT, "keypress: window: %lu\n", ev->window);
+
+       keysym = XKeycodeToKeysym(display, (KeyCode)ev->keycode, 0);
+       for (i = 0; i < keys_length; i++)
+               if (keysym == keys[i].keysym
+                  && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)
+                  && keyfuncs[keys[i].funcid].func) {
+                       if (keys[i].funcid == kf_spawn_custom)
+                               spawn_custom(
+                                   root_to_region(ev->root),
+                                   &(keyfuncs[keys[i].funcid].args),
+                                   keys[i].spawn_name
+                                   );
+                       else
+                               keyfuncs[keys[i].funcid].func(
+                                   root_to_region(ev->root),
+                                   &(keyfuncs[keys[i].funcid].args)
+                                   );
+               }
+}
+
+void
+buttonpress(XEvent *e)
+{
+       XButtonPressedEvent     *ev = &e->xbutton;
+
+       struct ws_win           *win;
+       int                     i, action;
+
+       DNPRINTF(SWM_D_EVENT, "buttonpress: window: %lu\n", ev->window);
+
+       action = root_click;
+       if ((win = find_window(ev->window)) == NULL)
+               return;
+       else {
+               focus_win(win);
+               action = client_click;
+       }
+
+       for (i = 0; i < LENGTH(buttons); i++)
+               if (action == buttons[i].action && buttons[i].func &&
+                   buttons[i].button == ev->button &&
+                   CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state))
+                       buttons[i].func(win, &buttons[i].args);
+}
+
+void
 configurerequest(XEvent *e)
 {
        XConfigureRequestEvent  *ev = &e->xconfigurerequest;
@@ -3501,6 +3570,8 @@ destroynotify(XEvent *e)
 
        DNPRINTF(SWM_D_EVENT, "destroynotify: window %lu\n", ev->window);
 
+       SWM_EV_PROLOGUE(display);
+
        if ((win = find_window(ev->window)) != NULL) {
                /* find a window to focus */
                ws = win->ws;
@@ -3510,20 +3581,33 @@ destroynotify(XEvent *e)
                if (win->transient)
                        winfocus = find_window(win->transient);
                else if (ws->focus == win) {
-                       if (TAILQ_FIRST(wl) == win)
-                               winfocus = TAILQ_NEXT(win, entry);
-                       else {
-                               winfocus = TAILQ_PREV(ws->focus, ws_win_list, entry);
-                               if (winfocus == NULL)
-                                       winfocus = TAILQ_LAST(wl, ws_win_list);
+                       /* if in max_stack try harder */
+                       if (ws->cur_layout->flags & SWM_L_FOCUSPREV)
+                               if (win != ws->focus && win != ws->focus_prev)
+                                       winfocus = ws->focus_prev;
+
+                       /* fallback and normal handling */
+                       if (winfocus == NULL) {
+                               if (TAILQ_FIRST(wl) == win)
+                                       winfocus = TAILQ_NEXT(win, entry);
+                               else {
+                                       winfocus = TAILQ_PREV(ws->focus,
+                                           ws_win_list, entry);
+                                       if (winfocus == NULL)
+                                               winfocus = TAILQ_LAST(wl,
+                                                   ws_win_list);
+                               }
                        }
                }
-
+               ignore_enter = 1;
                unmanage_window(win);
                stack();
                if (winfocus)
                        focus_win(winfocus);
+               ignore_enter = 0;
        }
+
+       SWM_EV_EPILOGUE(display);
 }
 
 void
@@ -3546,8 +3630,11 @@ enternotify(XEvent *e)
        if (QLength(display))
                return;
 
-       if ((win = find_window(ev->window)) != NULL)
+       if ((win = find_window(ev->window)) != NULL) {
+               if (win->ws->focus == win)
+                       return;
                focus_win(win);
+       }
 }
 
 void
@@ -3570,6 +3657,8 @@ mapnotify(XEvent *e)
 
        DNPRINTF(SWM_D_EVENT, "mapnotify: window: %lu\n", ev->window);
 
+       SWM_EV_PROLOGUE(display);
+
        win = find_window(ev->window);
        if (win)
                set_win_state(win, NormalState);
@@ -3577,6 +3666,8 @@ mapnotify(XEvent *e)
        XRefreshKeyboardMapping(ev);
        if (ev->request == MappingKeyboard)
                grabkeys();
+
+       SWM_EV_EPILOGUE(display);
 }
 
 void
@@ -3591,10 +3682,12 @@ maprequest(XEvent *e)
        DNPRINTF(SWM_D_EVENT, "maprequest: window: %lu\n",
            e->xmaprequest.window);
 
+       SWM_EV_PROLOGUE(display);
+
        if (!XGetWindowAttributes(display, ev->window, &wa))
-               return;
+               goto done;
        if (wa.override_redirect)
-               return;
+               goto done;
 
        manage_window(e->xmaprequest.window);
 
@@ -3606,6 +3699,9 @@ maprequest(XEvent *e)
 
        if (win->ws == r->ws)
                focus_win(win);
+
+done:
+       SWM_EV_EPILOGUE(display);
 }
 
 void
@@ -3646,17 +3742,17 @@ propertynotify(XEvent *e)
 void
 unmapnotify(XEvent *e)
 {
-       struct ws_win           *win, *winfocus;
+       struct ws_win           *win, *winfocus = NULL;
        struct workspace        *ws;
 
        DNPRINTF(SWM_D_EVENT, "unmapnotify: window: %lu\n", e->xunmap.window);
 
+       SWM_EV_PROLOGUE(display);
+
        /* determine if we need to help unmanage this window */
        win = find_window(e->xunmap.window);
        if (win == NULL)
-               return;
-       if (win->transient)
-               return;
+               goto done;
 
        if (getstate(e->xunmap.window) == NormalState) {
                /*
@@ -3664,22 +3760,40 @@ unmapnotify(XEvent *e)
                 * longer visible due to the app unmapping it so unmanage it
                 */
 
-               /* find something to focus */
                ws = win->ws;
-               winfocus = TAILQ_PREV(win, ws_win_list, entry);
-               if (TAILQ_FIRST(&ws->winlist) == win)
-                       winfocus = TAILQ_NEXT(win, entry);
-               else {
-                       winfocus = TAILQ_PREV(ws->focus, ws_win_list, entry);
-                       if (winfocus == NULL)
-                               winfocus = TAILQ_LAST(&ws->winlist, ws_win_list);
+               /* if we are max_stack try harder to focus on something */
+               if (ws->cur_layout->flags & SWM_L_FOCUSPREV) {
+                       if (win->transient)
+                               winfocus = find_window(win->transient);
+                       else if (win != ws->focus && win != ws->focus_prev)
+                               winfocus = ws->focus_prev;
+               }
+
+               /* normal and fallback if haven't found anything to focus on */
+               if (winfocus == NULL) {
+                       winfocus = TAILQ_PREV(win, ws_win_list, entry);
+                       if (TAILQ_FIRST(&ws->winlist) == win)
+                               winfocus = TAILQ_NEXT(win, entry);
+                       else {
+                               if (ws->focus)
+                                       winfocus = TAILQ_PREV(ws->focus,
+                                           ws_win_list, entry);
+                               if (winfocus == NULL)
+                                       winfocus = TAILQ_LAST(&ws->winlist,
+                                           ws_win_list);
+                       }
                }
 
                /* trash window and refocus */
                unmanage_window(win);
+               ignore_enter = 1;
                stack();
                focus_win(winfocus);
+               ignore_enter = 0;
        }
+
+done:
+       SWM_EV_EPILOGUE(display);
 }
 
 void
@@ -3862,7 +3976,6 @@ void
 screenchange(XEvent *e) {
        XRRScreenChangeNotifyEvent      *xe = (XRRScreenChangeNotifyEvent *)e;
        struct swm_region               *r;
-       struct ws_win                   *win;
        int                             i;
 
        DNPRINTF(SWM_D_EVENT, "screenchange: %lu\n", xe->root);