changeset: 510:58fb84c48930
tag: tip
user: joten <joten_AT_freenet.de>
date: Mon May 10 21:01:43 2010 +0200
files: dwm.suckless.org/patches/flextile-5.8-100510.diff dwm.suckless.org/patches/flextile.md
description:
Benutzer: joten <joten_AT_freenet.de>
branch 'default'
added dwm.suckless.org/patches/flextile-5.8-100510.diff
added dwm.suckless.org/patches/flextile.md
diff -r 7cface51e8d4 -r 58fb84c48930 dwm.suckless.org/patches/flextile-5.8-100510.diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dwm.suckless.org/patches/flextile-5.8-100510.diff Mon May 10 21:01:43 2010 +0200
_AT_@ -0,0 +1,384 @@
+diff -up ../dwm-5.8-100510/config.def.h ./config.def.h
+--- ../dwm-5.8-100510/config.def.h 2010-05-10 18:33:23.597215039 +0200
++++ ./config.def.h 2010-05-10 18:02:21.014900822 +0200
+_AT_@ -25,6 +25,12 @@ static const Rule rules[] = {
+ /* layout(s) */
+ static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
+ static const Bool resizehints = True; /* True means respect size hints in tiled resizals */
++static const int layoutaxis[] = {
++ 1, /* layout axis: 1 = x, 2 = y; negative values mirror the layout, setting the master area to the right / bottom instead of left / top */
++ 2, /* master axis: 1 = x (from left to right), 2 = y (from top to bottom), 3 = z (monocle) */
++ 2, /* stack axis: 1 = x (from left to right), 2 = y (from top to bottom), 3 = z (monocle) */
++};
++static const unsigned int mastersplit = 1; /* number of tiled clients in the master area */
+
+ static const Layout layouts[] = {
+ /* symbol arrange function */
+_AT_@ -81,6 +87,12 @@ static Key keys[] = {
+ TAGKEYS( XK_8, 7)
+ TAGKEYS( XK_9, 8)
+ { MODKEY|ShiftMask, XK_q, quit, {0} },
++ { MODKEY|ControlMask, XK_t, rotatelayoutaxis, {.i = 0} }, /* 0 = layout axis */
++ { MODKEY|ControlMask, XK_Tab, rotatelayoutaxis, {.i = 1} }, /* 1 = master axis */
++ { MODKEY|ControlMask|ShiftMask, XK_Tab, rotatelayoutaxis, {.i = 2} }, /* 2 = stack axis */
++ { MODKEY|ControlMask, XK_Return, mirrorlayout, {0} },
++ { MODKEY|ControlMask, XK_j, shiftmastersplit, {.i = -1} },
++ { MODKEY|ControlMask, XK_k, shiftmastersplit, {.i = +1} },
+ };
+
+ /* button definitions */
+diff -up ../dwm-5.8-100510/dwm.c ./dwm.c
+--- ../dwm-5.8-100510/dwm.c 2010-05-10 18:33:23.623877306 +0200
++++ ./dwm.c 2010-05-10 18:40:00.117209357 +0200
+_AT_@ -121,26 +121,6 @@ typedef struct {
+ void (*arrange)(Monitor *);
+ } Layout;
+
+-struct Monitor {
+- char ltsymbol[16];
+- float mfact;
+- int num;
+- int by; /* bar geometry */
+- int mx, my, mw, mh; /* screen size */
+- int wx, wy, ww, wh; /* window area */
+- unsigned int seltags;
+- unsigned int sellt;
+- unsigned int tagset[2];
+- Bool showbar;
+- Bool topbar;
+- Client *clients;
+- Client *sel;
+- Client *stack;
+- Monitor *next;
+- Window barwin;
+- const Layout *lt[2];
+-};
+-
+ typedef struct {
+ const char *class;
+ const char *instance;
+_AT_@ -239,6 +219,9 @@ static int xerror(Display *dpy, XErrorEv
+ static int xerrordummy(Display *dpy, XErrorEvent *ee);
+ static int xerrorstart(Display *dpy, XErrorEvent *ee);
+ static void zoom(const Arg *arg);
++static void mirrorlayout(const Arg *arg);
++static void rotatelayoutaxis(const Arg *arg);
++static void shiftmastersplit(const Arg *arg);
+
+ /* variables */
+ static const char broken[] = "broken";
+_AT_@ -276,6 +259,34 @@ static Window root;
+
+ /* compile-time check if all tags fit into an unsigned int bit array. */
+ struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
++struct Monitor {
++ char ltsymbol[16];
++ float mfact;
++ int num;
++ int by; /* bar geometry */
++ int mx, my, mw, mh; /* screen size */
++ int wx, wy, ww, wh; /* window area */
++ unsigned int seltags;
++ unsigned int sellt;
++ unsigned int tagset[2];
++ Bool showbar;
++ Bool topbar;
++ Client *clients;
++ Client *sel;
++ Client *stack;
++ Monitor *next;
++ Window barwin;
++ const Layout *lt[2];
++ int curtag;
++ int prevtag;
++ const Layout *lts[LENGTH(tags) + 1];
++ double mfacts[LENGTH(tags) + 1];
++ Bool showbars[LENGTH(tags) + 1];
++ int ltaxis[3];
++ unsigned int msplit;
++ int ltaxes[LENGTH(tags) + 1][3];
++ unsigned int msplits[LENGTH(tags) + 1];
++};
+
+ /* function implementations */
+ void
+_AT_@ -617,6 +628,10 @@ createmon(void) {
+ m->lt[0] = &layouts[0];
+ m->lt[1] = &layouts[1 % LENGTH(layouts)];
+ strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
++ m->ltaxis[0] = layoutaxis[0];
++ m->ltaxis[1] = layoutaxis[1];
++ m->ltaxis[2] = layoutaxis[2];
++ m->msplit = mastersplit;
+ return m;
+ }
+
+_AT_@ -1467,7 +1482,7 @@ setlayout(const Arg *arg) {
+ if(!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
+ selmon->sellt ^= 1;
+ if(arg && arg->v)
+- selmon->lt[selmon->sellt] = (Layout *)arg->v;
++ selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag] = (Layout *)arg->v;
+ strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
+ if(selmon->sel)
+ arrange(selmon);
+_AT_@ -1485,14 +1500,16 @@ setmfact(const Arg *arg) {
+ f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
+ if(f < 0.1 || f > 0.9)
+ return;
+- selmon->mfact = f;
++ selmon->mfact = selmon->mfacts[selmon->curtag] = f;
+ arrange(selmon);
+ }
+
+ void
+ setup(void) {
+ XSetWindowAttributes wa;
+-
++ Monitor *m;
++ unsigned int i;
++
+ /* clean up any zombies immediately */
+ sigchld(0);
+
+_AT_@ -1526,7 +1543,19 @@ setup(void) {
+ XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
+ if(!dc.font.set)
+ XSetFont(dpy, dc.gc, dc.font.xfont->fid);
+- /* init bars */
++ /* init tags, bars, layouts, axes, msplits and mfacts */
++ for(m = mons; m; m = m->next) {
++ m->curtag = m->prevtag = 1;
++ for(i=0; i < LENGTH(tags) + 1; i++) {
++ m->showbars[i] = m->showbar;
++ m->lts[i] = &layouts[0];
++ m->mfacts[i] = m->mfact;
++ m->ltaxes[i][0] = m->ltaxis[0];
++ m->ltaxes[i][1] = m->ltaxis[1];
++ m->ltaxes[i][2] = m->ltaxis[2];
++ m->msplits[i] = m->msplit;
++ }
++ }
+ updatebars();
+ updatestatus();
+ /* EWMH support per view */
+_AT_@ -1607,37 +1636,132 @@ textnw(const char *text, unsigned int le
+
+ void
+ tile(Monitor *m) {
+- int x, y, h, w, mw;
+- unsigned int i, n;
++ char sym1 = 61, sym2 = 93, sym3 = 61, sym;
++ int x1 = m->wx, y1 = m->wy, h1 = m->wh, w1 = m->ww, X1 = x1 + w1, Y1 = y1 + h1;
++ int x2 = m->wx, y2 = m->wy, h2 = m->wh, w2 = m->ww, X2 = x2 + w2, Y2 = y2 + h2;
++ unsigned int i, n, n1, n2;
+ Client *c;
+
+ for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
++ if(m->msplit > n)
++ m->msplit = (n == 0) ? 1 : n;
++ if(n == 0 && m->ltaxis[1] != 3)
++ return;
++ /* layout symbol */
++ if(abs(m->ltaxis[0]) == m->ltaxis[1]) /* explicitly: ((abs(m->ltaxis[0]) == 1 && m->ltaxis[1] == 1) || (abs(m->ltaxis[0]) == 2 && m->ltaxis[1] == 2)) */
++ sym1 = 124;
++ if(abs(m->ltaxis[0]) == m->ltaxis[2])
++ sym3 = 124;
++ if(m->ltaxis[1] == 3)
++ sym1 = (n == 0) ? 0 : m->msplit;
++ if(m->ltaxis[2] == 3)
++ sym3 = (n == 0) ? 0 : n - m->msplit;
++ if(m->ltaxis[0] < 0) {
++ sym = sym1;
++ sym1 = sym3;
++ sym2 = 91;
++ sym3 = sym;
++ }
++ if(m->msplit == 1) {
++ if(m->ltaxis[0] > 0)
++ sym1 = 91;
++ else
++ sym3 = 93;
++ }
++ if(m->msplit > 1 && m->ltaxis[1] == 3 && m->ltaxis[2] == 3)
++ snprintf(m->ltsymbol, sizeof m->ltsymbol, "%d%c%d", sym1, sym2, sym3);
++ else if((m->msplit > 1 && m->ltaxis[1] == 3 && m->ltaxis[0] > 0) || (m->ltaxis[2] == 3 && m->ltaxis[0] < 0))
++ snprintf(m->ltsymbol, sizeof m->ltsymbol, "%d%c%c", sym1, sym2, sym3);
++ else if((m->ltaxis[2] == 3 && m->ltaxis[0] > 0) || (m->msplit > 1 && m->ltaxis[1] == 3 && m->ltaxis[0] < 0))
++ snprintf(m->ltsymbol, sizeof m->ltsymbol, "%c%c%d", sym1, sym2, sym3);
++ else
++ snprintf(m->ltsymbol, sizeof m->ltsymbol, "%c%c%c", sym1, sym2, sym3);
+ if(n == 0)
+ return;
++ /* master and stack area */
++ if(abs(m->ltaxis[0]) == 1 && n > m->msplit) {
++ w1 *= m->mfact;
++ w2 -= w1;
++ x1 += (m->ltaxis[0] < 0) ? w2 : 0;
++ x2 += (m->ltaxis[0] < 0) ? 0 : w1;
++ X1 = x1 + w1;
++ X2 = x2 + w2;
++ } else if(abs(m->ltaxis[0]) == 2 && n > m->msplit) {
++ h1 *= m->mfact;
++ h2 -= h1;
++ y1 += (m->ltaxis[0] < 0) ? h2 : 0;
++ y2 += (m->ltaxis[0] < 0) ? 0 : h1;
++ Y1 = y1 + h1;
++ Y2 = y2 + h2;
++ }
+ /* master */
+- c = nexttiled(m->clients);
+- mw = m->mfact * m->ww;
+- resize(c, m->wx, m->wy, (n == 1 ? m->ww : mw) - 2 * c->bw, m->wh - 2 * c->bw, False);
+- if(--n == 0)
+- return;
+- /* tile stack */
+- x = (m->wx + mw > c->x + c->w) ? c->x + c->w + 2 * c->bw : m->wx + mw;
+- y = m->wy;
+- w = (m->wx + mw > c->x + c->w) ? m->wx + m->ww - x : m->ww - mw;
+- h = m->wh / n;
+- if(h < bh)
+- h = m->wh;
+- for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
+- resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n)
+- ? m->wy + m->wh - y - 2 * c->bw : h - 2 * c->bw), False);
+- if(h != m->wh)
+- y = c->y + HEIGHT(c);
++ n1 = (m->ltaxis[1] != 1 || w1 / m->msplit < bh) ? 1 : m->msplit;
++ n2 = (m->ltaxis[1] != 2 || h1 / m->msplit < bh) ? 1 : m->msplit;
++ for(i = 0, c = nexttiled(m->clients); i < m->msplit; c = nexttiled(c->next), i++) {
++ resize(c, x1, y1,
++ (m->ltaxis[1] == 1 && i + 1 == m->msplit) ? X1 - x1 - 2 * c->bw : w1 / n1 - 2 * c->bw,
++ (m->ltaxis[1] == 2 && i + 1 == m->msplit) ? Y1 - y1 - 2 * c->bw : h1 / n2 - 2 * c->bw, False);
++ if(n1 > 1)
++ x1 = c->x + WIDTH(c);
++ if(n2 > 1)
++ y1 = c->y + HEIGHT(c);
++ }
++ /* stack */
++ if(n > m->msplit) {
++ n1 = (m->ltaxis[2] != 1 || w2 / (n - m->msplit) < bh) ? 1 : n - m->msplit;
++ n2 = (m->ltaxis[2] != 2 || h2 / (n - m->msplit) < bh) ? 1 : n - m->msplit;
++ for(i = 0; c; c = nexttiled(c->next), i++) {
++ resize(c, x2, y2,
++ (m->ltaxis[2] == 1 && i + 1 == n - m->msplit) ? X2 - x2 - 2 * c->bw : w2 / n1 - 2 * c->bw,
++ (m->ltaxis[2] == 2 && i + 1 == n - m->msplit) ? Y2 - y2 - 2 * c->bw : h2 / n2 - 2 * c->bw, False);
++ if(n1 > 1)
++ x2 = c->x + WIDTH(c);
++ if(n2 > 1)
++ y2 = c->y + HEIGHT(c);
++ }
+ }
+ }
+
+ void
++mirrorlayout(const Arg *arg) {
++ if(!selmon->lt[selmon->sellt]->arrange)
++ return;
++ selmon->ltaxis[0] *= -1;
++ selmon->ltaxes[selmon->curtag][0] = selmon->ltaxis[0];
++ arrange(selmon);
++}
++
++void
++rotatelayoutaxis(const Arg *arg) {
++ if(!selmon->lt[selmon->sellt]->arrange)
++ return;
++ if(arg->i == 0) {
++ if(selmon->ltaxis[0] > 0)
++ selmon->ltaxis[0] = selmon->ltaxis[0] + 1 > 2 ? 1 : selmon->ltaxis[0] + 1;
++ else
++ selmon->ltaxis[0] = selmon->ltaxis[0] - 1 < -2 ? -1 : selmon->ltaxis[0] - 1;
++ } else
++ selmon->ltaxis[arg->i] = selmon->ltaxis[arg->i] + 1 > 3 ? 1 : selmon->ltaxis[arg->i] + 1;
++ selmon->ltaxes[selmon->curtag][arg->i] = selmon->ltaxis[arg->i];
++ arrange(selmon);
++}
++
++void
++shiftmastersplit(const Arg *arg) {
++ unsigned int n;
++ Client *c;
++
++ for(n = 0, c = nexttiled(selmon->clients); c; c = nexttiled(c->next), n++);
++ if(!arg || !selmon->lt[selmon->sellt]->arrange || selmon->msplit + arg->i < 1 || selmon->msplit + arg->i > n)
++ return;
++ selmon->msplit += arg->i;
++ selmon->msplits[selmon->curtag] = selmon->msplit;
++ arrange(selmon);
++}
++
++void
+ togglebar(const Arg *arg) {
+- selmon->showbar = !selmon->showbar;
++ selmon->showbar = selmon->showbars[selmon->curtag] = !selmon->showbar;
+ updatebarpos(selmon);
+ XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
+ arrange(selmon);
+_AT_@ -1657,12 +1781,31 @@ togglefloating(const Arg *arg) {
+ void
+ toggletag(const Arg *arg) {
+ unsigned int newtags;
++ unsigned int i;
+
+ if(!selmon->sel)
+ return;
+ newtags = selmon->sel->tags ^ (arg->ui & TAGMASK);
+ if(newtags) {
+ selmon->sel->tags = newtags;
++ if(newtags == ~0) {
++ selmon->prevtag = selmon->curtag;
++ selmon->curtag = 0;
++ }
++ if(!(newtags & 1 << (selmon->curtag - 1))) {
++ selmon->prevtag = selmon->curtag;
++ for (i=0; !(newtags & 1 << i); i++);
++ selmon->curtag = i + 1;
++ }
++ selmon->sel->tags = newtags;
++ selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag];
++ selmon->mfact = selmon->mfacts[selmon->curtag];
++ if (selmon->showbar != selmon->showbars[selmon->curtag])
++ togglebar(NULL);
++ selmon->ltaxis[0] = selmon->ltaxes[selmon->curtag][0];
++ selmon->ltaxis[1] = selmon->ltaxes[selmon->curtag][1];
++ selmon->ltaxis[2] = selmon->ltaxes[selmon->curtag][2];
++ selmon->msplit = selmon->msplits[selmon->curtag];
+ arrange(selmon);
+ }
+ }
+_AT_@ -1929,11 +2072,33 @@ updatewmhints(Client *c) {
+
+ void
+ view(const Arg *arg) {
++ unsigned int i;
++
+ if((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
+ return;
+ selmon->seltags ^= 1; /* toggle sel tagset */
+- if(arg->ui & TAGMASK)
++ if(arg->ui & TAGMASK) {
+ selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
++ selmon->prevtag = selmon->curtag;
++ if(arg->ui == ~0)
++ selmon->curtag = 0;
++ else {
++ for (i=0; !(arg->ui & 1 << i); i++);
++ selmon->curtag = i + 1;
++ }
++ } else {
++ selmon->prevtag = selmon->curtag ^ selmon->prevtag;
++ selmon->curtag ^= selmon->prevtag;
++ selmon->prevtag = selmon->curtag ^ selmon->prevtag;
++ }
++ selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag];
++ selmon->mfact = selmon->mfacts[selmon->curtag];
++ if(selmon->showbar != selmon->showbars[selmon->curtag])
++ togglebar(NULL);
++ selmon->ltaxis[0] = selmon->ltaxes[selmon->curtag][0];
++ selmon->ltaxis[1] = selmon->ltaxes[selmon->curtag][1];
++ selmon->ltaxis[2] = selmon->ltaxes[selmon->curtag][2];
++ selmon->msplit = selmon->msplits[selmon->curtag];
+ arrange(selmon);
+ }
+
diff -r 7cface51e8d4 -r 58fb84c48930 dwm.suckless.org/patches/flextile.md
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dwm.suckless.org/patches/flextile.md Mon May 10 21:01:43 2010 +0200
_AT_@ -0,0 +1,52 @@
+# FLEXTILE LAYOUT #
+
+## Description ##
+
+This patch replaces the tile layout with a more flexible version. The features include the following:
+ * tile like the original version (left single master, right stack)
+ * left/right/top/bottom n-master, right/left/bottom/top/no stack/deck (deck is like monocle in the stack area)
+ * per-tag configuration
+
+It therefor provides i. a. the following additional possibilities:
+ * tile for left-handed people
+ * compare multiple files with one other each at a time without switching between views
+
+The patch incorporates and expands the following patches:
+ * bottom stack (bstack and bstackhoriz)
+ * nmaster
+ * pertag
+
+
+## Configuration ##
+
+ (1) Download the patch and apply it according to the [general instructions](.).
+ (2) Transfer the changes made by the patch in 'config.def.h' to your 'config.h', if needed.
+ In the 'layout(s)' section:
+ static const int layoutaxis[] = {
+ 1, /* layout axis: 1 = x, 2 = y; negative values mirror the layout, setting the master area to the right / bottom instead of left / top */
+ 2, /* master axis: 1 = x (from left to right), 2 = y (from top to bottom), 3 = z (monocle) */
+ 2, /* stack axis: 1 = x (from left to right), 2 = y (from top to bottom), 3 = z (monocle) */
+ };
+ static const unsigned int mastersplit = 1; /* number of tiled clients in the master area */
+ In the 'keys' array:
+ { MODKEY|ControlMask, XK_t, rotatelayoutaxis, {.i = 0} }, /* 0 = layout axis */
+ { MODKEY|ControlMask, XK_Tab, rotatelayoutaxis, {.i = 1} }, /* 1 = master axis */
+ { MODKEY|ControlMask|ShiftMask, XK_Tab, rotatelayoutaxis, {.i = 2} }, /* 2 = stack axis */
+ { MODKEY|ControlMask, XK_Return, mirrorlayout, {0} },
+ { MODKEY|ControlMask, XK_j, shiftmastersplit, {.i = -1} },
+ { MODKEY|ControlMask, XK_k, shiftmastersplit, {.i = +1} },
+
+
+## Usage ##
+
+With the default configuration (see above) the original tile layout is emulated. You can change the layout by adjusting the four parameters 'layout axis', 'master axis', 'stack axis' and 'master split' (description see above) by pressing the appropriate keys.
+The original tile layout is only available by setting the above parameters, but not as a discrete layout; the 'monocle' layout is still available by pressing 'ALT+m' (in the default configuration).
+
+
+## Download ##
+
+ * [flextile-5.8-100510.diff][1] (13k) (20100510)
+
+
+[1]:
http://dwm.suckless.org/patches/flextile-5.8-100510.diff
+
Received on Mon May 10 2010 - 21:01:39 CEST