# HG changeset patch # User Stiletto # Date 1308022146 -14400 # Node ID ff21639cb978b8b99afc744ad41cf78bf89ca901 # Parent e2e1cbb4654181bb83486cbe9797aa0abbe26864 Pango markup support and fibonacci layout. diff -r e2e1cbb46541 -r ff21639cb978 config.def.h --- a/config.def.h Wed Feb 02 22:33:33 2011 +0300 +++ b/config.def.h Tue Jun 14 07:29:06 2011 +0400 @@ -31,6 +31,7 @@ { "[]=", tile }, /* first entry is default */ { "><>", NULL }, /* no layout function means floating behavior */ { "[M]", monocle }, + { "(@)", spiral }, }; static const int deflayouts[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; @@ -64,6 +65,7 @@ { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, + { MODKEY|ShiftMask, XK_p, setlayout, {.v = &layouts[3]} }, { MODKEY, XK_space, setlayout, {0} }, { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, { MODKEY, XK_0, view, {.ui = ~0 } }, diff -r e2e1cbb46541 -r ff21639cb978 dwm.c --- a/dwm.c Wed Feb 02 22:33:33 2011 +0300 +++ b/dwm.c Tue Jun 14 07:29:06 2011 +0400 @@ -270,6 +270,7 @@ /* configuration, allows nested code to access above variables */ #include "push.h" +#include "layouts/fibonacci.h" #include "config.h" struct Monitor { @@ -298,6 +299,7 @@ }; #include "push.c" +#include "layouts/fibonacci.c" /* compile-time check if all tags fit into an unsigned int bit array. */ struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; }; @@ -805,7 +807,7 @@ memcpy(buf, text, len); if(len < olen) for(i = len; i && i > len - 3; buf[--i] = '.'); - pango_layout_set_text(dc.plo, text, len); + pango_layout_set_markup(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); } @@ -1617,7 +1619,7 @@ int textnw(const char *text, unsigned int len) { PangoRectangle r; - pango_layout_set_text(dc.plo, text, len); + pango_layout_set_markup(dc.plo, text, len); pango_layout_get_extents(dc.plo, &r, 0); return r.width / PANGO_SCALE; } diff -r e2e1cbb46541 -r ff21639cb978 layouts/fibonacci.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/layouts/fibonacci.c Tue Jun 14 07:29:06 2011 +0400 @@ -0,0 +1,66 @@ +void +fibonacci(Monitor *mon, int s) { + unsigned int i, n, nx, ny, nw, nh; + Client *c; + + for(n = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next), n++); + if(n == 0) + return; + + nx = mon->wx; + ny = 0; + nw = mon->ww; + nh = mon->wh; + + for(i = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next)) { + if((i % 2 && nh / 2 > 2 * c->bw) + || (!(i % 2) && nw / 2 > 2 * c->bw)) { + if(i < n - 1) { + if(i % 2) + nh /= 2; + else + nw /= 2; + if((i % 4) == 2 && !s) + nx += nw; + else if((i % 4) == 3 && !s) + ny += nh; + } + if((i % 4) == 0) { + if(s) + ny += nh; + else + ny -= nh; + } + else if((i % 4) == 1) + nx += nw; + else if((i % 4) == 2) + ny += nh; + else if((i % 4) == 3) { + if(s) + nx += nw; + else + nx -= nw; + } + if(i == 0) + { + if(n != 1) + nw = mon->ww * selmon->mfacts[selmon->curtag]; + ny = mon->wy; + } + else if(i == 1) + nw = mon->ww - nw; + i++; + } + resize(c, nx, ny, nw - 2 * c->bw, nh - 2 * c->bw, False); + } +} + +void +dwindle(Monitor *mon) { + fibonacci(mon, 1); +} + +void +spiral(Monitor *mon) { + fibonacci(mon, 0); +} diff -r e2e1cbb46541 -r ff21639cb978 layouts/fibonacci.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/layouts/fibonacci.h Tue Jun 14 07:29:06 2011 +0400 @@ -0,0 +1,8 @@ +void +fibonacci(Monitor *mon, int s); + +void +dwindle(Monitor *mon); + +void +spiral(Monitor *mon);