Browse files

first commit

  • Loading branch information...
0 parents commit cd30c6f7419ecc09e8a789891a4551baf07f3829 O K committed Apr 5, 2011
Showing with 1,123 additions and 0 deletions.
  1. +247 −0 01-dwm-5.8.2-pango.diff
  2. +278 −0 02-dwm-5.8.2-pertag2.diff
  3. +81 −0 03-dwm-5.8.2-scratchpad-stay.diff
  4. +45 −0 04-dwm-5.8.2-uselessgaps.diff
  5. +47 −0 PKGBUILD
  6. +195 −0 config.h
  7. +38 −0 cycle.c
  8. +28 −0 dwm.install
  9. +45 −0 nbstack.c
  10. +61 −0 pidgin-grid.c
  11. +58 −0 push.c
247 01-dwm-5.8.2-pango.diff
@@ -0,0 +1,247 @@
+diff -aur dwm-5.7.2.orig/config.def.h dwm-5.7.2.patched/config.def.h
+--- dwm-5.7.2.orig/config.def.h 2009-09-27 21:20:23.000000000 +0200
++++ dwm-5.7.2.patched/config.def.h 2009-12-27 16:46:01.751122177 +0100
+@@ -1,7 +1,7 @@
+ /* See LICENSE file for copyright and license details. */
+
+ /* appearance */
+-static const char font[] = "-*-terminus-medium-r-*-*-16-*-*-*-*-*-*-*";
++static const char font[] = "Sans 8"
+ static const char normbordercolor[] = "#cccccc";
+ static const char normbgcolor[] = "#cccccc";
+ static const char normfgcolor[] = "#000000";
+diff -aur dwm-5.7.2.orig/config.mk dwm-5.7.2.patched/config.mk
+--- dwm-5.7.2.orig/config.mk 2009-09-27 21:20:23.000000000 +0200
++++ dwm-5.7.2.patched/config.mk 2009-12-27 16:26:27.572088085 +0100
+@@ -15,8 +15,8 @@
+ XINERAMAFLAGS = -DXINERAMA
+
+ # includes and libs
+-INCS = -I. -I/usr/include -I${X11INC}
+-LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 ${XINERAMALIBS}
++INCS = -I. -I/usr/include -I${X11INC} `pkg-config --cflags xft pango pangoxft`
++LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 ${XINERAMALIBS} `pkg-config --libs xft pango pangoxft`
+
+ # flags
+ CPPFLAGS = -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
+diff -aur dwm-5.7.2.orig/dwm.c dwm-5.7.2.patched/dwm.c
+--- dwm-5.7.2.orig/dwm.c 2009-09-27 21:20:23.000000000 +0200
++++ dwm-5.7.2.patched/dwm.c 2009-12-27 16:51:01.258589745 +0100
+@@ -36,6 +36,10 @@
+ #include <X11/Xlib.h>
+ #include <X11/Xproto.h>
+ #include <X11/Xutil.h>
++#include <X11/Xft/Xft.h>
++#include <pango/pango.h>
++#include <pango/pangoxft.h>
++#include <pango/pango-font.h>
+ #ifdef XINERAMA
+ #include <X11/extensions/Xinerama.h>
+ #endif /* XINERAMA */
+@@ -46,8 +50,12 @@
+ #define INRECT(X,Y,RX,RY,RW,RH) ((X) >= (RX) && (X) < (RX) + (RW) && (Y) >= (RY) && (Y) < (RY) + (RH))
+ #define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
+ #define LENGTH(X) (sizeof X / sizeof X[0])
+-#define MAX(A, B) ((A) > (B) ? (A) : (B))
++#ifndef MAX
++#define MAX(A, B) ((A) > (B) ? (A) : (B))
++#endif
++#ifndef MIN
+ #define MIN(A, B) ((A) < (B) ? (A) : (B))
++#endif
+ #define MOUSEMASK (BUTTONMASK|PointerMotionMask)
+ #define WIDTH(X) ((X)->w + 2 * (X)->bw)
+ #define HEIGHT(X) ((X)->h + 2 * (X)->bw)
+@@ -99,12 +107,19 @@
+ unsigned long sel[ColLast];
+ Drawable drawable;
+ GC gc;
++
++ XftColor xftnorm[ColLast];
++ XftColor xftsel[ColLast];
++ XftDraw *xftdrawable;
++
++ PangoContext *pgc;
++ PangoLayout *plo;
++ PangoFontDescription *pfd;
++
+ struct {
+ int ascent;
+ int descent;
+ int height;
+- XFontSet set;
+- XFontStruct *xfont;
+ } font;
+ } DC; /* draw context */
+
+@@ -180,7 +195,7 @@
+ static void focusin(XEvent *e);
+ static void focusmon(const Arg *arg);
+ static void focusstack(const Arg *arg);
+-static unsigned long getcolor(const char *colstr);
++//static unsigned long getcolor(const char *colstr);
+ static Bool getrootptr(int *x, int *y);
+ static long getstate(Window w);
+ static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
+@@ -477,10 +492,6 @@
+ for(m = mons; m; m = m->next)
+ while(m->stack)
+ unmanage(m->stack, False);
+- if(dc.font.set)
+- XFreeFontSet(dpy, dc.font.set);
+- else
+- XFreeFont(dpy, dc.font.xfont);
+ XUngrabKey(dpy, AnyKey, AnyModifier, root);
+ XFreePixmap(dpy, dc.drawable);
+ XFreeGC(dpy, dc.gc);
+@@ -550,6 +561,7 @@
+ if(dc.drawable != 0)
+ XFreePixmap(dpy, dc.drawable);
+ dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
++ XftDrawChange(dc.xftdrawable, dc.drawable);
+ updatebars();
+ for(m = mons; m; m = m->next)
+ XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh);
+@@ -767,7 +779,7 @@
+ return;
+ olen = strlen(text);
+ h = dc.font.ascent + dc.font.descent;
+- y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent;
++ y = dc.y;
+ x = dc.x + (h / 2);
+ /* shorten text if necessary */
+ for(len = MIN(olen, sizeof buf); len && textnw(text, len) > dc.w - h; len--);
+@@ -776,11 +788,8 @@
+ memcpy(buf, text, len);
+ if(len < olen)
+ for(i = len; i && i > len - 3; buf[--i] = '.');
+- XSetForeground(dpy, dc.gc, col[invert ? ColBG : ColFG]);
+- if(dc.font.set)
+- XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len);
+- else
+- XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
++ pango_layout_set_text(dc.plo, text, len);
++ pango_xft_render_layout(dc.xftdrawable, (col==dc.norm?dc.xftnorm:dc.xftsel)+(invert?ColBG:ColFG), dc.plo, x * PANGO_SCALE, y * PANGO_SCALE);
+ }
+
+ void
+@@ -880,13 +889,13 @@
+ }
+
+ unsigned long
+-getcolor(const char *colstr) {
++getcolor(const char *colstr, XftColor *color) {
+ Colormap cmap = DefaultColormap(dpy, screen);
+- XColor color;
++ Visual *vis = DefaultVisual(dpy, screen);
+
+- if(!XAllocNamedColor(dpy, cmap, colstr, &color, &color))
++ if(!XftColorAllocName(dpy,vis,cmap,colstr, color))
+ die("error, cannot allocate color '%s'\n", colstr);
+- return color.pixel;
++ return color->pixel;
+ }
+
+ Bool
+@@ -983,37 +992,19 @@
+
+ void
+ initfont(const char *fontstr) {
+- char *def, **missing;
+- int i, n;
++ PangoFontMetrics *metrics;
+
+- missing = NULL;
+- dc.font.set = XCreateFontSet(dpy, fontstr, &missing, &n, &def);
+- if(missing) {
+- while(n--)
+- fprintf(stderr, "dwm: missing fontset: %s\n", missing[n]);
+- XFreeStringList(missing);
+- }
+- if(dc.font.set) {
+- XFontSetExtents *font_extents;
+- XFontStruct **xfonts;
+- char **font_names;
+-
+- dc.font.ascent = dc.font.descent = 0;
+- font_extents = XExtentsOfFontSet(dc.font.set);
+- n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names);
+- for(i = 0, dc.font.ascent = 0, dc.font.descent = 0; i < n; i++) {
+- dc.font.ascent = MAX(dc.font.ascent, (*xfonts)->ascent);
+- dc.font.descent = MAX(dc.font.descent,(*xfonts)->descent);
+- xfonts++;
+- }
+- }
+- else {
+- if(!(dc.font.xfont = XLoadQueryFont(dpy, fontstr))
+- && !(dc.font.xfont = XLoadQueryFont(dpy, "fixed")))
+- die("error, cannot load font: '%s'\n", fontstr);
+- dc.font.ascent = dc.font.xfont->ascent;
+- dc.font.descent = dc.font.xfont->descent;
+- }
++ dc.pgc = pango_xft_get_context(dpy, screen);
++ dc.pfd = pango_font_description_from_string(fontstr);
++
++ metrics = pango_context_get_metrics(dc.pgc, dc.pfd, pango_language_from_string(setlocale(LC_CTYPE, "")));
++ dc.font.ascent = pango_font_metrics_get_ascent(metrics) / PANGO_SCALE;
++ dc.font.descent = pango_font_metrics_get_descent(metrics) / PANGO_SCALE;
++
++ pango_font_metrics_unref(metrics);
++
++ dc.plo = pango_layout_new(dc.pgc);
++ pango_layout_set_font_description(dc.plo, dc.pfd);
+ dc.font.height = dc.font.ascent + dc.font.descent;
+ }
+
+@@ -1497,19 +1488,24 @@
+ cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
+ cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
+ cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
++
+ /* init appearance */
+- dc.norm[ColBorder] = getcolor(normbordercolor);
+- dc.norm[ColBG] = getcolor(normbgcolor);
+- dc.norm[ColFG] = getcolor(normfgcolor);
+- dc.sel[ColBorder] = getcolor(selbordercolor);
+- dc.sel[ColBG] = getcolor(selbgcolor);
+- dc.sel[ColFG] = getcolor(selfgcolor);
++ dc.norm[ColBorder] = getcolor(normbordercolor, dc.xftnorm+ColBorder);
++ dc.norm[ColBG] = getcolor(normbgcolor, dc.xftnorm+ColBG);
++ dc.norm[ColFG] = getcolor(normfgcolor, dc.xftnorm+ColFG);
++ dc.sel[ColBorder] = getcolor(selbordercolor, dc.xftsel+ColBorder);
++ dc.sel[ColBG] = getcolor(selbgcolor, dc.xftsel+ColBG);
++ dc.sel[ColFG] = getcolor(selfgcolor, dc.xftsel+ColFG);
++
+ dc.drawable = XCreatePixmap(dpy, root, DisplayWidth(dpy, screen), bh, DefaultDepth(dpy, screen));
+ dc.gc = XCreateGC(dpy, root, 0, NULL);
+ XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
+- if(!dc.font.set)
+- XSetFont(dpy, dc.gc, dc.font.xfont->fid);
+- /* init bars */
++
++ dc.xftdrawable = XftDrawCreate(dpy, dc.drawable, DefaultVisual(dpy,screen), DefaultColormap(dpy,screen));
++ if(!dc.xftdrawable)
++ printf("error, cannot create drawable\n");
++
++ /* init bar */
+ updatebars();
+ updatestatus();
+ /* EWMH support per view */
+@@ -1579,13 +1575,10 @@
+
+ int
+ textnw(const char *text, unsigned int len) {
+- XRectangle r;
+-
+- if(dc.font.set) {
+- XmbTextExtents(dc.font.set, text, len, NULL, &r);
+- return r.width;
+- }
+- return XTextWidth(dc.font.xfont, text, len);
++ PangoRectangle r;
++ pango_layout_set_text(dc.plo, text, len);
++ pango_layout_get_extents(dc.plo, &r, 0);
++ return r.width / PANGO_SCALE;
+ }
+
+ void
278 02-dwm-5.8.2-pertag2.diff
@@ -0,0 +1,278 @@
+--- a/dwm.c 2010-03-17 13:06:16.417956450 -0400
++++ b/dwm.c 2010-03-17 13:07:21.574604722 -0400
+@@ -122,7 +122,6 @@
+
+ struct Monitor {
+ char ltsymbol[16];
+- float mfact;
+ int num;
+ int by; /* bar geometry */
+ int mx, my, mw, mh; /* screen size */
+@@ -138,9 +137,21 @@
+ Monitor *next;
+ Window barwin;
+ const Layout *lt[2];
++ int curtag;
++ int prevtag;
++ const Layout **lts;
++ double *mfacts;
++ int *nmasters;
+ };
+
+ typedef struct {
++ const char *name;
++ const Layout *layout;
++ float mfact;
++ int nmaster;
++} Tag;
++
++typedef struct {
+ const char *class;
+ const char *instance;
+ const char *title;
+@@ -208,6 +219,8 @@
+ static void setclientstate(Client *c, long state);
+ static void setlayout(const Arg *arg);
+ static void setmfact(const Arg *arg);
++static void setnmaster(const Arg *arg);
++static void incnmaster(const Arg *arg);
+ static void setup(void);
+ static void showhide(Client *c);
+ static void sigchld(int unused);
+@@ -215,7 +228,7 @@
+ static void tag(const Arg *arg);
+ static void tagmon(const Arg *arg);
+ static int textnw(const char *text, unsigned int len);
+-static void tile(Monitor *);
++static void ntile(Monitor *);
+ static void togglebar(const Arg *arg);
+ static void togglefloating(const Arg *arg);
+ static void toggletag(const Arg *arg);
+@@ -430,7 +443,7 @@
+ if(ev->window == selmon->barwin) {
+ i = x = 0;
+ do {
+- x += TEXTW(tags[i]);
++ x += TEXTW(tags[i].name);
+ } while(ev->x >= x && ++i < LENGTH(tags));
+ if(i < LENGTH(tags)) {
+ click = ClkTagBar;
+@@ -505,6 +518,9 @@
+ }
+ XUnmapWindow(dpy, mon->barwin);
+ XDestroyWindow(dpy, mon->barwin);
++ free(mon->mfacts);
++ free(mon->nmasters);
++ free(mon->lts);
+ free(mon);
+ }
+
+@@ -603,19 +619,32 @@
+ XSync(dpy, False);
+ }
+
++/* TODO Check how many times createmon is called */
+ Monitor *
+ createmon(void) {
+ Monitor *m;
++ int i, numtags = LENGTH(tags) + 1;
+
+ if(!(m = (Monitor *)calloc(1, sizeof(Monitor))))
+ die("fatal: could not malloc() %u bytes\n", sizeof(Monitor));
++ if(!(m->mfacts = calloc(sizeof(double), numtags)))
++ die("fatal: could not malloc() %u bytes\n", sizeof(double) * numtags);
++ if(!(m->nmasters = calloc(sizeof(int), numtags)))
++ die("fatal: could not malloc() %u bytes\n", sizeof(int) * numtags);
++ if(!(m->lts = calloc(sizeof(Layout *), numtags)))
++ die("fatal: could not malloc() %u bytes\n", sizeof(Layout *) * numtags);
+ m->tagset[0] = m->tagset[1] = 1;
+- m->mfact = mfact;
+ m->showbar = showbar;
+ m->topbar = topbar;
+- m->lt[0] = &layouts[0];
++ m->curtag = m->prevtag = 1;
++ for(i = 1; i < numtags; i++) {
++ m->mfacts[i] = tags[i - 1].mfact < 0 ? mfact : tags[i - 1].mfact;
++ m->nmasters[i] = tags[i - 1].nmaster < 0 ? nmaster : tags[i - 1].nmaster;
++ m->lts[i] = tags[i - 1].layout;
++ }
++ m->lt[0] = m->lts[m->curtag];
+ m->lt[1] = &layouts[1 % LENGTH(layouts)];
+- strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
++ strncpy(m->ltsymbol, m->lt[0]->symbol, sizeof m->ltsymbol);
+ return m;
+ }
+
+@@ -690,9 +719,9 @@
+ }
+ dc.x = 0;
+ for(i = 0; i < LENGTH(tags); i++) {
+- dc.w = TEXTW(tags[i]);
++ dc.w = TEXTW(tags[i].name);
+ col = m->tagset[m->seltags] & 1 << i ? dc.sel : dc.norm;
+- drawtext(tags[i], col, urg & 1 << i);
++ drawtext(tags[i].name, col, urg & 1 << i);
+ drawsquare(m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
+ occ & 1 << i, urg & 1 << i, col);
+ dc.x += dc.w;
+@@ -1450,7 +1479,7 @@
+ 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);
+@@ -1458,6 +1487,25 @@
+ drawbar(selmon);
+ }
+
++static void
++incnmaster(const Arg *arg) {
++ int i;
++
++ if(!arg || !selmon->lt[selmon->sellt]->arrange)
++ return;
++ i = selmon->nmasters[selmon->curtag] + arg->i;
++ selmon->nmasters[selmon->curtag] = i < 0 ? 0 : i;
++ arrange(selmon);
++}
++
++static void
++setnmaster(const Arg *arg) {
++ if(!arg || !selmon->lt[selmon->sellt]->arrange)
++ return;
++ selmon->nmasters[selmon->curtag] = arg->i > 0 ? arg->i : 0;
++ arrange(selmon);
++}
++
+ /* arg > 1.0 will set mfact absolutly */
+ void
+ setmfact(const Arg *arg) {
+@@ -1465,10 +1513,10 @@
+
+ if(!arg || !selmon->lt[selmon->sellt]->arrange)
+ return;
+- f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
++ f = arg->f < 1.0 ? arg->f + selmon->mfacts[selmon->curtag] : arg->f - 1.0;
+ if(f < 0.1 || f > 0.9)
+ return;
+- selmon->mfact = f;
++ selmon->mfacts[selmon->curtag] = f;
+ arrange(selmon);
+ }
+
+@@ -1589,30 +1637,46 @@
+ }
+
+ void
+-tile(Monitor *m) {
+- int x, y, h, w, mw;
++ntile(Monitor *m) {
++ int x, y, h, w, mw, nmax, nm;
+ unsigned int i, n;
+ Client *c;
+
++ snprintf(m->ltsymbol, sizeof m->ltsymbol, "[]=", m->nmasters[m->curtag]);
+ for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
+- if(n == 0)
+- return;
+- /* 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)
++ nmax = m->nmasters[m->curtag];
++ nm = nmax == 1 ? 1 : MIN(n / 2, nmax);
++ if(nm > n)
++ nm = n;
++ /* master */
++ if(nm > 0) {
++ mw = selmon->mfacts[selmon->curtag] * m->ww;
++ h = m->wh / nm;
++ if(h < bh)
++ h = m->wh;
++ y = m->wy;
++ for(i = 0; i < nm; i++, c = nexttiled(c->next)) {
++ resize(c, m->wx, y, (n == nm ? m->ww : mw) - 2 * c->bw,
++ ((i + 1 == nm) ? m->wy + m->wh - y : h) - 2 * c->bw, False);
++ if(h != m->wh)
++ y = c->y + HEIGHT(c);
++ }
++ n -= nm;
++ } else
++ mw = 0;
++ if(n == 0)
+ return;
+ /* tile stack */
+- x = (m->wx + mw > c->x + c->w) ? c->x + c->w + 2 * c->bw : m->wx + mw;
++ x = m->wx + mw;
+ y = m->wy;
+- w = (m->wx + mw > c->x + c->w) ? m->wx + m->ww - x : m->ww - mw;
++ w = 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);
++ for(i = 0; c; c = nexttiled(c->next), i++) {
++ resize(c, x, y, w - 2 * c->bw,
++ ((i + 1 == n) ? m->wy + m->wh - y : h) - 2 * c->bw, False);
+ if(h != m->wh)
+ y = c->y + HEIGHT(c);
+ }
+@@ -1640,12 +1704,24 @@
+ 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];
+ arrange(selmon);
+ }
+ }
+@@ -1912,11 +1988,26 @@
+
+ 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];
+ arrange(selmon);
+ }
+
81 03-dwm-5.8.2-scratchpad-stay.diff
@@ -0,0 +1,81 @@
+diff -up dwm-5.8.2/dwm.c dwm-5.8.2-scratchpad/dwm.c
+--- dwm-5.8.2/dwm.c 2011-03-07 03:14:18.814185556 +0000
++++ dwm-5.8.2-scratchpad/dwm.c 2011-03-07 03:22:24.516075923 +0000
+@@ -248,6 +248,7 @@ static int textnw(const char *text, unsi
+ static void ntile(Monitor *);
+ static void togglebar(const Arg *arg);
+ static void togglefloating(const Arg *arg);
++static void togglescratch(const Arg *arg);
+ static void toggletag(const Arg *arg);
+ static void toggleview(const Arg *arg);
+ static void unfocus(Client *c, Bool setfocus);
+@@ -303,6 +304,8 @@ static Window root;
+ /* configuration, allows nested code to access above variables */
+ #include "config.h"
+
++static unsigned int scratchpadtag = 1 << LENGTH(tags); /* This tag specially for you, Scratchpad. */
++
+ /* compile-time check if all tags fit into an unsigned int bit array. */
+ struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
+
+@@ -1191,6 +1194,15 @@ manage(Window w, XWindowAttributes *wa)
+ && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my);
+ c->bw = borderpx;
+ }
++ if(strcmp(c->name, scratchpadname) == 0) {
++ c->tags = scratchpadtag;
++ c->isfloating = True;
++ c->x = (c->mon->mw - c->w) - 10;
++ c->y = 25;
++ c->mon->tagset[c->mon->seltags] |= c->tags;
++ } else { /* make sure non-scratchpads stay out of scratchpadtag */
++ c->tags &= TAGMASK;
++ }
+ wc.border_width = c->bw;
+ XConfigureWindow(dpy, w, CWBorderWidth, &wc);
+ XSetWindowBorder(dpy, w, dc.colors[0][ColBorder]);
+@@ -1771,6 +1783,25 @@ togglefloating(const Arg *arg) {
+ }
+
+ void
++togglescratch(const Arg *arg) {
++ Client *c = NULL;
++ unsigned int found = 0;
++ /* check if a scratchpad is already there in scratchpadtag */
++ for(c = selmon->clients; c && !(found = c->tags & scratchpadtag); c = c->next);
++ if(!found) { /* not found: launch it and put it in its tag (see manage()) */
++ spawn(arg);
++ return;
++ }
++ unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchpadtag;
++ if(newtagset) {
++ selmon->tagset[selmon->seltags] = newtagset;
++ arrange(selmon);
++ }
++ focus(c);
++}
++
++
++void
+ toggletag(const Arg *arg) {
+ unsigned int newtags;
+ unsigned int i;
+@@ -2059,8 +2090,9 @@ updatewmhints(Client *c) {
+ void
+ view(const Arg *arg) {
+ unsigned int i;
++ unsigned int stag = selmon->tagset[selmon->seltags] & scratchpadtag;
+
+- if((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
++ if((arg->ui & TAGMASK) == (selmon->tagset[selmon->seltags] & TAGMASK))
+ return;
+ selmon->seltags ^= 1; /* toggle sel tagset */
+ if(arg->ui & TAGMASK) {
+@@ -2077,6 +2109,7 @@ view(const Arg *arg) {
+ selmon->curtag^= selmon->prevtag;
+ selmon->prevtag= selmon->curtag ^ selmon->prevtag;
+ }
++ selmon->tagset[selmon->seltags] |= stag;
+ selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag];
+ arrange(selmon);
+ }
45 04-dwm-5.8.2-uselessgaps.diff
@@ -0,0 +1,45 @@
+diff -r 23b71491e149 config.def.h
+--- a/config.def.h Thu Dec 02 10:16:47 2010 +0000
++++ b/config.def.h Fri Jan 07 08:50:42 2011 +0100
+@@ -9,6 +9,7 @@
+ static const char selbgcolor[] = "#0066ff";
+ static const char selfgcolor[] = "#ffffff";
+ static const unsigned int borderpx = 1; /* border pixel of windows */
++static const unsigned int gappx = 6; /* gap pixel between windows */
+ static const unsigned int snap = 32; /* snap pixel */
+ static const Bool showbar = True; /* False means no bar */
+ static const Bool topbar = True; /* False means bottom bar */
+diff -r 23b71491e149 dwm.c
+--- a/dwm.c Thu Dec 02 10:16:47 2010 +0000
++++ b/dwm.c Fri Jan 07 08:50:42 2011 +0100
+@@ -273,6 +273,8 @@
+ static DC dc;
+ static Monitor *mons = NULL, *selmon = NULL;
+ static Window root;
++static int globalborder ;
++static int globalborder ;
+
+ /* configuration, allows nested code to access above variables */
+ #include "config.h"
+@@ -1329,11 +1331,17 @@
+ void
+ resizeclient(Client *c, int x, int y, int w, int h) {
+ XWindowChanges wc;
++
++ if(c->isfloating || selmon->lt[selmon->sellt]->arrange == NULL) { globalborder = 0 ; }
++ else {
++ if (selmon->lt[selmon->sellt]->arrange == monocle) { globalborder = 0 - borderpx ; }
++ else { globalborder = gappx ; }
++ }
+
+- c->oldx = c->x; c->x = wc.x = x;
+- c->oldy = c->y; c->y = wc.y = y;
+- c->oldw = c->w; c->w = wc.width = w;
+- c->oldh = c->h; c->h = wc.height = h;
++ c->oldx = c->x; c->x = wc.x = x + globalborder ;
++ c->oldy = c->y; c->y = wc.y = y + globalborder ;
++ c->oldw = c->w; c->w = wc.width = w - 2 * globalborder ;
++ c->oldh = c->h; c->h = wc.height = h - 2 * globalborder ;
+ wc.border_width = c->bw;
+ XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
+ configure(c);
47 PKGBUILD
@@ -0,0 +1,47 @@
+# $Id: PKGBUILD 3138 2009-09-28 09:21:30Z spupykin $
+# Maintainer: Patrice Peterson <runiq at archlinux dot us>
+# Contributor: Sergej Pupykin <pupykin.s+arch at gmail dot com>
+# Contributor: Dag Odenhall <dag.odenhall at gmail dot com>
+# Contributor: Grigorios Bouzakis <grbzks at gmail dot com>
+
+pkgname=dwm
+pkgver=5.8.2
+pkgrel=2
+pkgdesc="A dynamic window manager for X"
+url="http://dwm.suckless.org"
+arch=('i686' 'x86_64')
+license=('MIT')
+depends=('libxinerama' 'pango')
+options=(zipman)
+conflicts=('dwm-pango')
+install=dwm.install
+source=(http://dl.suckless.org/dwm/dwm-$pkgver.tar.gz
+ config.h
+ 01-dwm-5.8.2-pango.diff
+ 02-dwm-5.8.2-pertag2.diff
+ 03-dwm-5.8.2-scratchpad-stay.diff
+ 04-dwm-5.8.2-uselessgaps.diff
+ pidgin-grid.c
+ nbstack.c
+ push.c
+ cycle.c)
+
+build() {
+ cd $srcdir/dwm-$pkgver
+
+ patch -Np1 -i ../01-dwm-5.8.2-pango.diff
+ patch < ../02-dwm-5.8.2-pertag2.diff
+ patch -p1 < ../03-dwm-5.8.2-scratchpad-stay.diff
+ patch -p1 < ../04-dwm-5.8.2-uselessgaps.diff
+ cp $srcdir/config.h config.h
+ cp $srcdir/pidgin-grid.c pidgin-grid.c
+ cp $srcdir/nbstack.c nbstack.c
+ cp $srcdir/push.c push.c
+ cp $srcdir/cycle.c cycle.c
+
+ make X11INC=/usr/include/X11 X11LIB=/usr/lib/X11 || return 1
+ make PREFIX=/usr DESTDIR=$pkgdir install || return 1
+
+ install -m644 -D LICENSE $pkgdir/usr/share/licenses/$pkgname/LICENSE && \
+ install -m644 -D README $pkgdir/usr/share/doc/$pkgname/README
+}
195 config.h
@@ -0,0 +1,195 @@
+/* See LICENSE file for copyright and license details. */
+#include <X11/XF86keysym.h>
+
+/* appearance */
+static const char font[] = "envy code r 9";
+static const char normbordercolor[] = "#212121";
+static const char normbgcolor[] = "#121212";
+static const char normfgcolor[] = "#696969";
+static const char selbordercolor[] = "#696969";
+static const char selbgcolor[] = "#121212";
+static const char selfgcolor[] = "#e0e0e0";
+static const char urgbordercolor[] = "#bf4d80";
+static const char urgbgcolor[] = "#121212";
+static const char urgfgcolor[] = "#bf4d80";
+static const unsigned int borderpx = 1; /* border pixel of windows */
+static const unsigned int snap = 10; /* snap pixel */
+static const unsigned int gappx = 2;
+static const Bool showbar = True; /* False means no bar */
+static const Bool topbar = True; /* False means bottom bar */
+static const char scratchpadname[] = "Scratchpad";
+
+/* layout(s) */
+static const float mfact = 0.60; /* factor of master area size [0.05..0.95] */
+static const Bool resizehints = False; /* True means respect size hints in tiled resizals */
+static const int nmaster = 1; /* default number of clients in the master area */
+
+#include "pidgin-grid.c"
+#include "nbstack.c"
+static const Layout layouts[] = {
+ /* symbol arrange function */
+ { "[]=", ntile },
+ { "TTT", nbstack },
+ { "><>", NULL }, /* no layout function means floating behavior */
+ { "[ ]", monocle },
+ { "###", pidgin },
+
+};
+
+/* tagging */
+static const Tag tags[] = {
+ /* name layout mfact nmaster */
+ { "term", &layouts[0], -1, -1 },
+ { "web", &layouts[3], -1, -1 },
+ { "im", &layouts[4], 0.29, -1 },
+ { "misc", &layouts[2], -1, -1 },
+ { "gimp", &layouts[0], 0.21, -1 },
+};
+
+static const Rule rules[] = {
+ /* class instance title tags mask isfloating monitor */
+ { NULL, NULL, "tmux", 1 << 0, False, -1 },
+ { "Keepassx", NULL, NULL, 1 << 1, True, -1 },
+ { "Opera", NULL, NULL, 1 << 1, False, -1 },
+ { "Transmission-gtk", NULL, NULL, 1 << 1, False, -1 },
+ { "Pidgin", NULL, NULL, 1 << 2, False, -1 },
+ { "Skype", NULL, NULL, 1 << 2, True, -1 },
+ { "FBReader", NULL, NULL, 1 << 3, True, -1 },
+ { "Xsane", NULL, NULL, 1 << 3, True, -1 },
+ { "Gimp", NULL, NULL, 1 << 4, False, -1 },
+ { "Audacious", NULL, NULL, 0, True, -1 },
+ { "Galculator", NULL, NULL, 0, True, -1 },
+ { "Lxappearance", NULL, NULL, 0, True, -1 },
+ { "MPlayer", NULL, NULL, 0, True, -1 },
+ { "Nitrogen", NULL, NULL, 0, True, -1 },
+ { "Thunar", NULL, NULL, 0, True, -1 },
+ { "Vlc", NULL, NULL, 0, True, -1 },
+ { "Zenity", NULL, NULL, 0, True, -1 },
+ { NULL, NULL, "shutdown-dialog.py", 0, True, -1 },
+};
+
+/* key definitions */
+#define MODKEY Mod1Mask
+#define TAGKEYS(KEY,TAG) \
+ { MODKEY, KEY, view, {.ui = 1 << TAG} }, \
+ { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
+ { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
+ { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} },
+
+/* helper for spawning shell commands in the pre dwm-5.0 fashion */
+#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
+
+/* commands */
+static const char *dmenucmd[] = { "dmenu-launch", NULL };
+static const char *termcmd[] = { "urxvtc", NULL };
+static const char *logoutcmd[] = { "sudo", "killall", "X", NULL };
+static const char *scratchpadcmd[] = { "urxvtc", "-title", scratchpadname, "-geometry", "70x9+400+10", NULL };
+static const char *monitorcmd[] = { "/home/ok/Scripts/monitor.sh", NULL };
+static const char *screenoffcmd[] = { "xset", "dpms", "force", "off", NULL };
+static const char *voltogglecmd[] = { "amixer", "-q", "set", "Master", "toggle", NULL };
+static const char *voldowncmd[] = { "amixer", "-q", "set", "Master", "2dB-", NULL };
+static const char *volupcmd[] = { "amixer", "-q", "set", "Master", "2dB+", NULL };
+static const char *shutdowncmd[] = { "/home/ok/Scripts/shutdown-dialog.py", NULL };
+static const char *tmuxcmd[] = { "urxvtc", "-title", "tmux", "-e", "tmux", "-f", "/home/ok/.tmux/conf", NULL };
+static const char *mccmd[] = { "urxvtc", "-e", "/home/ok/Scripts/mc.sh", NULL };
+static const char *operacmd[] = { "/home/ok/Scripts/opera.sh", NULL };
+static const char *pcmanfmcmd[] = { "pcmanfm", "/home/ok", NULL };
+static const char *pidgincmd[] = { "pidgin", NULL };
+static const char *wificmd[] = { "urxvtc", "-e", "sudo", "wifi-select", "wlan0", NULL };
+static const char *zimcmd[] = { "zim", NULL };
+static const char *newscmd[] = { "urxvtc", "-e", "newsbeuter", NULL };
+static const char *htopcmd[] = { "urxvtc", "-e", "htop", NULL };
+static const char *mpdcmd[] = { "urxvtc", "-e", "/home/ok/Scripts/music.sh", NULL };
+static const char *mpdplaycmd[] = { "mpc", "play", NULL };
+static const char *mpdpausecmd[] = { "mpc", "pause", NULL };
+static const char *mpdnextcmd[] = { "mpc", "next", NULL };
+static const char *mpdprevcmd[] = { "mpc", "prev", NULL };
+static const char *mpdstopcmd[] = { "mpc", "stop", NULL };
+static const char *reloadcmd[] = { "/home/ok/Scripts/dwm-reload.sh", NULL };
+static const char *stardictcmd[] = { "stardict", NULL };
+static const char *menucmd[] = { "9menu", "-popup", "-teleport", "-file", "/home/ok/.config/9menu/9menurc", "-bg", normbgcolor, "-fg", normfgcolor, "-font", "-*-*-*-*-*-*-*-*-*-*-*-*-*-4", NULL };
+static const char *exitmenucmd[] = { "killall", "9menu", NULL };
+
+#include "push.c"
+#include "cycle.c"
+static Key keys[] = {
+ /* modifier key function argument */
+ { 0, XK_Menu, spawn, {.v = dmenucmd } },
+ { 0, XF86XK_Display, spawn, {.v = monitorcmd } },
+ { 0, XF86XK_Launch1, spawn, {.v = screenoffcmd } },
+ { 0, XF86XK_AudioMute, spawn, {.v = voltogglecmd } },
+ { 0, XF86XK_AudioLowerVolume, spawn, {.v = voldowncmd } },
+ { 0, XF86XK_AudioRaiseVolume, spawn, {.v = volupcmd } },
+ { 0, XF86XK_PowerOff, spawn, {.v = shutdowncmd } },
+ { Mod4Mask, XK_t, spawn, {.v = tmuxcmd } },
+ { Mod4Mask, XK_m, spawn, {.v = mccmd } },
+ { Mod4Mask, XK_o, spawn, {.v = operacmd } },
+ { Mod4Mask, XK_p, spawn, {.v = pcmanfmcmd } },
+ { Mod4Mask, XK_w, spawn, {.v = wificmd } },
+ { Mod4Mask, XK_n, spawn, {.v = zimcmd } },
+ { Mod4Mask, XK_i, spawn, {.v = pidgincmd } },
+ { Mod4Mask, XK_r, spawn, {.v = newscmd } },
+ { MODKEY|ControlMask, XK_Delete, spawn, {.v = htopcmd } },
+ { Mod4Mask, XK_h, spawn, {.v = mpdcmd } },
+ { Mod4Mask, XK_s, spawn, {.v = stardictcmd } },
+ { Mod4Mask, XK_Up, spawn, {.v = mpdplaycmd } },
+ { Mod4Mask, XK_Down, spawn, {.v = mpdpausecmd } },
+ { Mod4Mask, XK_Right, spawn, {.v = mpdnextcmd } },
+ { Mod4Mask, XK_Left, spawn, {.v = mpdprevcmd } },
+ { Mod4Mask, XK_Escape, spawn, {.v = mpdstopcmd } },
+ { MODKEY, XK_Return, spawn, {.v = termcmd } },
+ { MODKEY|ShiftMask, XK_e, spawn, {.v = logoutcmd } },
+ { 0, XK_F12, togglescratch, {.v = scratchpadcmd} },
+ { MODKEY|ShiftMask, XK_r, spawn, {.v = reloadcmd} },
+ { MODKEY, XK_Down, focusstack, {.i = +1 } },
+ { MODKEY, XK_Up, focusstack, {.i = -1 } },
+ { MODKEY, XK_Left, setmfact, {.f = -0.01} },
+ { MODKEY, XK_Right, setmfact, {.f = +0.01} },
+ { MODKEY|ShiftMask, XK_Return, zoom, {0} },
+ { Mod1Mask, XK_Tab, view, {0} },
+ { Mod1Mask, XK_F4, killclient, {0} },
+ { MODKEY|ShiftMask, XK_Left, incnmaster, {.i = +1 } },
+ { MODKEY|ShiftMask, XK_Right, incnmaster, {.i = -1 } },
+ { MODKEY|ShiftMask, XK_Down, pushdown, {0} },
+ { MODKEY|ShiftMask, XK_Up, pushup, {0} },
+ { MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
+ { MODKEY, XK_b, setlayout, {.v = &layouts[1]} },
+ { MODKEY, XK_f, setlayout, {.v = &layouts[2]} },
+ { MODKEY, XK_m, setlayout, {.v = &layouts[3]} },
+ { MODKEY, XK_g, setlayout, {.v = &layouts[4]} },
+ { MODKEY, XK_space, setlayout, {0} },
+ { MODKEY|ShiftMask, XK_space, togglefloating, {0} },
+ { MODKEY, XK_eacute, view, {.ui = ~0 } },
+ { MODKEY|ShiftMask, XK_eacute, tag, {.ui = ~0 } },
+ { MODKEY|ControlMask, XK_Left, cycle, {.i = -1 } },
+ { MODKEY|ControlMask, XK_Right, cycle, {.i = +1 } },
+ TAGKEYS( XK_plus, 0)
+ TAGKEYS( XK_ecaron, 1)
+ TAGKEYS( XK_scaron, 2)
+ TAGKEYS( XK_ccaron, 3)
+ TAGKEYS( XK_rcaron, 4)
+ TAGKEYS( XK_zcaron, 5)
+ TAGKEYS( XK_yacute, 6)
+ TAGKEYS( XK_aacute, 7)
+ TAGKEYS( XK_iacute, 8)
+};
+
+/* button definitions */
+/* click can be ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
+static Button buttons[] = {
+ /* click event mask button function argument */
+ { ClkLtSymbol, 0, Button1, setlayout, {0} },
+ { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
+ { ClkWinTitle, 0, Button3, spawn, {.v = menucmd } },
+ { ClkWinTitle, 0, Button1, spawn, {.v = exitmenucmd } },
+ { ClkClientWin, MODKEY, Button1, movemouse, {0} },
+ { ClkClientWin, MODKEY, Button2, togglefloating, {0} },
+ { ClkClientWin, MODKEY, Button3, resizemouse, {0} },
+ { ClkTagBar, 0, Button1, view, {0} },
+ { ClkTagBar, 0, Button3, toggleview, {0} },
+ { ClkTagBar, MODKEY, Button1, tag, {0} },
+ { ClkTagBar, MODKEY, Button3, toggletag, {0} },
+ { ClkRootWin, 0, Button3, spawn, {.v =menucmd } },
+ { ClkRootWin, 0, Button1, spawn, {.v =exitmenucmd } },
+};
+
38 cycle.c
@@ -0,0 +1,38 @@
+static int
+shifttag(int dist)
+{
+ int i, curtags;
+ int seltag = 0;
+ int numtags = LENGTH(tags);
+
+ curtags = selmon->tagset[selmon->seltags];
+ for(i = 0; i < LENGTH(tags); i++) {
+ if((curtags & (1 << i)) != 0) {
+ seltag = i;
+ break;
+ }
+ }
+
+ seltag += dist;
+ if(seltag < 0)
+ seltag = numtags - (-seltag) % numtags;
+ else
+ seltag %= numtags;
+
+ return 1 << seltag;
+}
+
+static void
+cycle(const Arg *arg)
+{
+ const Arg a = { .i = shifttag(arg->i) };
+ view(&a);
+}
+
+static void
+tagcycle(const Arg *arg)
+{
+ const Arg a = { .i = shifttag(arg->i) };
+ tag(&a);
+ view(&a);
+}
28 dwm.install
@@ -0,0 +1,28 @@
+pre_install() {
+ echo "-- Edit config.h in PKGBUILD's directory (generally /var/abs/community/x11/dwm/)"
+ echo "-- and rebuild package if you want to change settings."
+ /bin/true
+}
+
+post_install() {
+ /bin/true
+}
+
+pre_upgrade() {
+ echo "-- Edit config.h in PKGBUILD's directory (generally /var/abs/community/x11/dwm/)"
+ echo "-- and rebuild package if you want to change settings."
+ /bin/true
+}
+
+post_upgrade() {
+ /bin/true
+}
+
+pre_remove() {
+ /bin/true
+}
+
+post_remove() {
+ /bin/true
+}
+
45 nbstack.c
@@ -0,0 +1,45 @@
+static void
+nbstack(Monitor *m) {
+ int x, y, h, w, mh, nmax, nm;
+ unsigned int i, n;
+ Client *c;
+
+ snprintf(m->ltsymbol, sizeof m->ltsymbol, "TTT", m->nmasters[m->curtag]);
+ for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
+ c = nexttiled(m->clients);
+ nmax = m->nmasters[m->curtag];
+ nm = nmax == 1 ? 1 : MIN(n / 2, nmax);
+ if(nm > n)
+ nm = n;
+ /* master */
+ if(nm > 0) {
+ mh = m->mfacts[m->curtag] * m->wh;
+ w = m->ww / nm;
+ if(w < bh)
+ w = m->ww;
+ x = m->wx;
+ for(i = 0; i < nm; i++, c = nexttiled(c->next)) {
+ resize(c, x, m->wy, ((i + 1 == nm) ? m->wx + m->ww - x : w) - 2 * c->bw,
+ (n == nm ? m->wh : mh) - 2 * c->bw, False);
+ if(w != m->ww)
+ x = c->x + WIDTH(c);
+ }
+ n -= nm;
+ } else
+ mh = 0;
+ if(n == 0)
+ return;
+ /* tile stack */
+ x = m->wx;
+ y = m->wy + mh;
+ w = m->ww / n;
+ h = m->wh - mh;
+ if(w < bh)
+ w = m->ww;
+ for(i = 0; c; c = nexttiled(c->next), i++) {
+ resize(c, x, y, ((i + 1 == n) ? m->wx + m->ww - x : w) - 2 * c->bw,
+ h - 2 * c->bw, False);
+ if(w != m->ww)
+ x = c->x + WIDTH(c);
+ }
+}
61 pidgin-grid.c
@@ -0,0 +1,61 @@
+static const char wmname[] = "Seznam kamarádů";
+
+/* layout's mfact is buddy list width as ww % */
+void
+pidgin(Monitor *m) {
+ unsigned int n, cols, rows, cn, rn, i, cx, cy, cw, ch;
+ int wx; /* buddy list width and grid's wx */
+ int ww; /* grid's ww */
+ Client *c;
+ Client *bl = NULL; /* buddy list */
+
+ for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) {
+ if(strstr(c->name, wmname)) {
+ bl = c;
+ }
+ }
+ if(n == 0)
+ return;
+
+ /* buddy list */
+ if(bl) {
+ wx = m->mfacts[m->curtag] * m->ww;
+ ww = m->ww - wx;
+ resize(bl, m->wx, m->wy, wx - 2 * bl->bw, m->wh - 2 * bl->bw, False);
+ if(--n == 0)
+ return;
+ } else {
+ wx = m->wx;
+ ww = m->ww;
+ }
+
+ /* grid dimensions */
+ for(cols = 0; cols <= n/2; cols++)
+ if(cols*cols >= n)
+ break;
+ if(n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */
+ cols = 2;
+ rows = n/cols;
+
+ /* window geometries */
+ cw = cols ? ww / cols : ww;
+ cn = 0; /* current column number */
+ rn = 0; /* current row number */
+ for(i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) {
+ if(c == bl) {
+ --i;
+ continue;
+ }
+ if(i/rows + 1 > cols - n%cols)
+ rows = n/cols + 1;
+ ch = rows ? m->wh / rows : m->wh;
+ cx = wx + cn*cw;
+ cy = m->wy + rn*ch;
+ resize(c, cx, cy, cw - 2 * c->bw, ch - 2 * c->bw, False);
+ rn++;
+ if(rn >= rows) {
+ rn = 0;
+ cn++;
+ }
+ }
+}
58 push.c
@@ -0,0 +1,58 @@
+static Client *
+prevtiled(Client *c) {
+ Client *p, *r;
+
+ for(p = selmon->clients, r = NULL; p && p != c; p = p->next)
+ if(!p->isfloating && ISVISIBLE(p))
+ r = p;
+ return r;
+}
+
+static void
+pushup(const Arg *arg) {
+ Client *sel = selmon->sel;
+ Client *c;
+
+ if(!sel || sel->isfloating)
+ return;
+ if((c = prevtiled(sel))) {
+ /* attach before c */
+ detach(sel);
+ sel->next = c;
+ if(selmon->clients == c)
+ selmon->clients = sel;
+ else {
+ for(c = selmon->clients; c->next != sel->next; c = c->next);
+ c->next = sel;
+ }
+ } else {
+ /* move to the end */
+ for(c = sel; c->next; c = c->next);
+ detach(sel);
+ sel->next = NULL;
+ c->next = sel;
+ }
+ focus(sel);
+ arrange(selmon);
+}
+
+static void
+pushdown(const Arg *arg) {
+ Client *sel = selmon->sel;
+ Client *c;
+
+ if(!sel || sel->isfloating)
+ return;
+ if((c = nexttiled(sel->next))) {
+ /* attach after c */
+ detach(sel);
+ sel->next = c->next;
+ c->next = sel;
+ } else {
+ /* move to the front */
+ detach(sel);
+ attach(sel);
+ }
+ focus(sel);
+ arrange(selmon);
+}

0 comments on commit cd30c6f

Please sign in to comment.