JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
bring back old tiling behavior where floating windows stay always on top.
authorMarco Peereboom <marco@conformal.com>
Fri, 24 Jun 2011 16:53:40 +0000 (16:53 +0000)
committerMarco Peereboom <marco@conformal.com>
Fri, 24 Jun 2011 16:53:40 +0000 (16:53 +0000)
Add key stroke to toggle this behavior per workspace and add it to the
layout entry in the configuration file.
While here add iconify and uniconify key bindings in config file.

requested by many.

scrotwm.1
scrotwm.c
scrotwm.conf

index 07a3c25..90d4d20 100644 (file)
--- a/scrotwm.1
+++ b/scrotwm.1
@@ -390,6 +390,8 @@ initscr
 iconify
 .It Cm M-S-w
 uniconify
+.It Cm M-S-r
+toggle always_raised
 .El
 .Pp
 The action names and descriptions are listed below:
@@ -495,6 +497,8 @@ above)
 Minimize (unmap) currently focused window.
 .It Cm uniconify
 Maximize (map) window returned by dmenu selection.
+.It Cm always_raise
+When set tiled windows are allowed to obscure floating windows.
 .El
 .Pp
 Custom bindings in the configuration file are specified as follows:
index 3b7bfce..10806c9 100644 (file)
--- a/scrotwm.c
+++ b/scrotwm.c
@@ -343,6 +343,7 @@ struct layout {
 /* define work spaces */
 struct workspace {
        int                     idx;            /* workspace index */
+       int                     always_raise;   /* raise windows on focus */
        struct layout           *cur_layout;    /* current layout handlers */
        struct ws_win           *focus;         /* may be NULL */
        struct ws_win           *focus_prev;    /* may be NULL */
@@ -1959,11 +1960,11 @@ focus_win(struct ws_win *win)
                if (win->java == 0)
                        XSetInputFocus(display, win->id,
                            RevertToParent, CurrentTime);
-               XMapRaised(display, win->id);
                grabbuttons(win, 1);
                XSetWindowBorder(display, win->id,
                    win->ws->r->s->c[SWM_S_COLOR_FOCUS].color);
-               if (win->ws->cur_layout->flags & SWM_L_MAPONFOCUS)
+               if (win->ws->cur_layout->flags & SWM_L_MAPONFOCUS ||
+                   win->ws->always_raise)
                        XMapRaised(display, win->id);
 
                XChangeProperty(display, win->s->root,
@@ -3002,6 +3003,19 @@ send_to_ws(struct swm_region *r, union arg *args)
 }
 
 void
+raise_toggle(struct swm_region *r, union arg *args)
+{
+       if (r && r->ws == NULL)
+               return;
+
+       r->ws->always_raise = !r->ws->always_raise;
+
+       /* bring floaters back to top */
+       if (r->ws->always_raise == 0)
+               stack();
+}
+
+void
 iconify(struct swm_region *r, union arg *args)
 {
        union arg a;
@@ -3486,6 +3500,7 @@ enum keyfuncid {
        kf_spawn_custom,
        kf_iconify,
        kf_uniconify,
+       kf_raise_toggle,
        kf_dumpwins, /* MUST BE LAST */
        kf_invalid
 };
@@ -3562,6 +3577,7 @@ struct keyfunc {
        { "spawn_custom",       dummykeyfunc,   {0} },
        { "iconify",            iconify,        {0} },
        { "uniconify",          uniconify,      {0} },
+       { "raise_toggle",       raise_toggle,   {0} },
        { "dumpwins",           dumpwins,       {0} }, /* MUST BE LAST */
        { "invalid key func",   NULL,           {0} },
 };
@@ -4153,6 +4169,7 @@ setup_keys(void)
        setkeybinding(MODKEY|ShiftMask, XK_i,           kf_spawn_custom,        "initscr");
        setkeybinding(MODKEY,           XK_w,           kf_iconify,     NULL);
        setkeybinding(MODKEY|ShiftMask, XK_w,           kf_uniconify,   NULL);
+       setkeybinding(MODKEY|ShiftMask, XK_r,           kf_raise_toggle,NULL);
 #ifdef SWM_DEBUG
        setkeybinding(MODKEY|ShiftMask, XK_d,           kf_dumpwins,    NULL);
 #endif
@@ -4589,7 +4606,7 @@ setautorun(char *selector, char *value, int flags)
 int
 setlayout(char *selector, char *value, int flags)
 {
-       int                     ws_id, st, i, x, mg, ma, si;
+       int                     ws_id, st, i, x, mg, ma, si, raise;
        char                    s[1024];
        struct workspace        *ws;
 
@@ -4597,9 +4614,11 @@ setlayout(char *selector, char *value, int flags)
                return (0);
 
        bzero(s, sizeof s);
-       if (sscanf(value, "ws[%d]:%d:%d:%d:%1023c",
-           &ws_id, &mg, &ma, &si, s) != 5)
-               errx(1, "invalid layout entry, should be 'ws[<idx>]:<type>'\n");
+       if (sscanf(value, "ws[%d]:%d:%d:%d:%d:%1023c",
+           &ws_id, &mg, &ma, &si, &raise, s) != 6)
+               errx(1, "invalid layout entry, should be 'ws[<idx>]:"
+                   "<master_grow>:<master_add>:<stack_inc>:<always_raise>:"
+                   "<type>'\n");
        ws_id--;
        if (ws_id < 0 || ws_id >= SWM_WS_MAX)
                errx(1, "layout: invalid workspace %d\n", ws_id + 1);
@@ -4611,11 +4630,15 @@ setlayout(char *selector, char *value, int flags)
        else if (!strcasecmp(s, "fullscreen"))
                st = SWM_MAX_STACK;
        else
-               errx(1, "invalid layout entry, should be 'ws[<idx>]:<type>'\n");
+               errx(1, "invalid layout entry, should be 'ws[<idx>]:"
+                   "<master_grow>:<master_add>:<stack_inc>:<always_raise>:"
+                   "<type>'\n");
 
        for (i = 0; i < ScreenCount(display); i++) {
                ws = (struct workspace *)&screens[i].ws;
                ws[ws_id].cur_layout = &layouts[st];
+
+               ws[ws_id].always_raise = raise;
                if (st == SWM_MAX_STACK)
                        continue;
 
index f10abc5..daca5c3 100644 (file)
@@ -46,9 +46,9 @@ dialog_ratio          = 0.6
 # autorun              = ws[2]:xxxterm http://www.openbsd.org
 
 # workspace layout
-# layout               = ws[1]:4:0:0:vertical
-# layout               = ws[2]:0:0:0:horizontal
-# layout               = ws[3]:0:0:0:fullscreen
+# layout               = ws[1]:4:0:0:0:vertical
+# layout               = ws[2]:0:0:0:0:horizontal
+# layout               = ws[3]:0:0:0:0:fullscreen
 
 # mod key, (windows key is Mod4) (apple key on OSX is Mod2)
 # modkey = Mod1
@@ -108,6 +108,9 @@ dialog_ratio                = 0.6
 #bind[version]         = MOD+Shift+v
 #bind[lock]            = MOD+Shift+Delete
 #bind[initscr]         = MOD+Shift+i
+#bind[iconify]         = MOD+w
+#bind[uniconify]       = MOD+Shift+w
+#bind[raise_toggle]    = MOD+Shift+r
 
 # quirks
 # remove with: quirk[class:name] = NONE