sites

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 274262afb5eaed4649aedf2656e8b6b904e579af
parent 63b4c950ec21c895a48d805912bfd09930d5c806
Author: Shvedov Yury <shved@lvk.cs.msu.su>
Date:   Sun, 16 Feb 2014 20:27:51 +0400

Add taggrid patch

Diffstat:
Adwm.suckless.org/patches/dwm-6.1-taggrid.diff | 212+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adwm.suckless.org/patches/taggrid.md | 57+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adwm.suckless.org/patches/taggrid.png | 0
3 files changed, 269 insertions(+), 0 deletions(-)

diff --git a/dwm.suckless.org/patches/dwm-6.1-taggrid.diff b/dwm.suckless.org/patches/dwm-6.1-taggrid.diff @@ -0,0 +1,212 @@ +diff --git a/config.def.h b/config.def.h +index 875885b..d6670dc 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -16,6 +16,22 @@ static const Bool topbar = True; /* False means bottom bar */ + /* tagging */ + static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; + ++/* grid of tags */ ++#define DRAWCLASSICTAGS 1 << 0 ++#define DRAWTAGGRID 1 << 1 ++ ++#define SWITCHTAG_UP 1 << 0 ++#define SWITCHTAG_DOWN 1 << 1 ++#define SWITCHTAG_LEFT 1 << 2 ++#define SWITCHTAG_RIGHT 1 << 3 ++#define SWITCHTAG_TOGGLETAG 1 << 4 ++#define SWITCHTAG_TAG 1 << 5 ++#define SWITCHTAG_VIEW 1 << 6 ++#define SWITCHTAG_TOGGLEVIEW 1 << 7 ++ ++static const unsigned int drawtagmask = DRAWTAGGRID; /* | DRAWCLASSICTAGS to show classic row of tags */ ++static const int tagrows = 3; ++ + static const Rule rules[] = { + /* xprop(1): + * WM_CLASS(STRING) = instance, class +@@ -89,6 +105,16 @@ static Key keys[] = { + TAGKEYS( XK_8, 7) + TAGKEYS( XK_9, 8) + { MODKEY|ShiftMask, XK_q, quit, {0} }, ++ ++ { MODKEY|ControlMask, XK_Up, switchtag, { .ui = SWITCHTAG_UP | SWITCHTAG_VIEW } }, ++ { MODKEY|ControlMask, XK_Down, switchtag, { .ui = SWITCHTAG_DOWN | SWITCHTAG_VIEW } }, ++ { MODKEY|ControlMask, XK_Right, switchtag, { .ui = SWITCHTAG_RIGHT | SWITCHTAG_VIEW } }, ++ { MODKEY|ControlMask, XK_Left, switchtag, { .ui = SWITCHTAG_LEFT | SWITCHTAG_VIEW } }, ++ ++ { MODKEY|Mod4Mask, XK_Up, switchtag, { .ui = SWITCHTAG_UP | SWITCHTAG_TAG | SWITCHTAG_VIEW } }, ++ { MODKEY|Mod4Mask, XK_Down, switchtag, { .ui = SWITCHTAG_DOWN | SWITCHTAG_TAG | SWITCHTAG_VIEW } }, ++ { MODKEY|Mod4Mask, XK_Right, switchtag, { .ui = SWITCHTAG_RIGHT | SWITCHTAG_TAG | SWITCHTAG_VIEW } }, ++ { MODKEY|Mod4Mask, XK_Left, switchtag, { .ui = SWITCHTAG_LEFT | SWITCHTAG_TAG | SWITCHTAG_VIEW } }, + }; + + /* button definitions */ +diff --git a/dwm.c b/dwm.c +index 1bbb4b3..e211b74 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -163,6 +163,7 @@ static void detachstack(Client *c); + static Monitor *dirtomon(int dir); + static void drawbar(Monitor *m); + static void drawbars(void); ++static void drawtaggrid(Monitor *m, int *x_pos, unsigned int occ); + static void enternotify(XEvent *e); + static void expose(XEvent *e); + static void focus(Client *c); +@@ -205,6 +206,7 @@ static void setup(void); + static void showhide(Client *c); + static void sigchld(int unused); + static void spawn(const Arg *arg); ++static void switchtag(const Arg *arg); + static void tag(const Arg *arg); + static void tagmon(const Arg *arg); + static void tile(Monitor *); +@@ -702,6 +704,7 @@ drawbar(Monitor *m) { + urg |= c->tags; + } + x = 0; ++ if (drawtagmask & DRAWCLASSICTAGS) + for(i = 0; i < LENGTH(tags); i++) { + w = TEXTW(tags[i]); + drw_setscheme(drw, m->tagset[m->seltags] & 1 << i ? &scheme[SchemeSel] : &scheme[SchemeNorm]); +@@ -710,6 +713,9 @@ drawbar(Monitor *m) { + occ & 1 << i, urg & 1 << i); + x += w; + } ++ if (drawtagmask & DRAWTAGGRID) { ++ drawtaggrid(m,&x,occ); ++ } + w = blw = TEXTW(m->ltsymbol); + drw_setscheme(drw, &scheme[SchemeNorm]); + drw_text(drw, x, 0, w, bh, m->ltsymbol, 0); +@@ -748,6 +754,47 @@ drawbars(void) { + for(m = mons; m; m = m->next) + drawbar(m); + } ++void drawtaggrid(Monitor *m, int *x_pos, unsigned int occ) ++{ ++ unsigned int x, y, h, max_x, columns; ++ int invert, i,j, k; ++ ++ h = bh / tagrows; ++ x = max_x = *x_pos; ++ y = 0; ++ columns = LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0); ++ ++ /* Firstly we will fill the borders of squares */ ++ XSetForeground(drw->dpy, drw->gc, scheme[SchemeNorm].bg->rgb); ++ XFillRectangle(dpy, drw->drawable, drw->gc, x, y, h*columns + 1, bh); ++ ++ /* We well draw LENGTH(tags) squares in tagraws raws. */ ++ for(j = 0, i= 0; j < tagrows; j++) { ++ x = *x_pos; ++ for (k = 0; k < columns && i < LENGTH(tags); k++, i++) { ++ invert = m->tagset[m->seltags] & 1 << i ? 0 : 1; ++ ++ /* Select active color for current square */ ++ XSetForeground(drw->dpy, drw->gc, !invert ? scheme[SchemeSel].bg->rgb : ++ scheme[SchemeNorm].fg->rgb); ++ XFillRectangle(dpy, drw->drawable, drw->gc, x+1, y+1, h-1, h-1); ++ ++ /* Mark square if tag has client */ ++ if (occ & 1 << i) { ++ XSetForeground(drw->dpy, drw->gc, !invert ? scheme[SchemeSel].fg->rgb : ++ scheme[SchemeNorm].bg->rgb); ++ XFillRectangle(dpy, drw->drawable, drw->gc, x + 1, y + 1, ++ h / 2, h / 2); ++ } ++ x += h; ++ if (x > max_x) { ++ max_x = x; ++ } ++ } ++ y += h; ++ } ++ *x_pos = max_x + 1; ++} + + void + enternotify(XEvent *e) { +@@ -1582,6 +1629,81 @@ spawn(const Arg *arg) { + exit(EXIT_SUCCESS); + } + } ++void switchtag(const Arg *arg) ++{ ++ unsigned int columns; ++ unsigned int new_tagset = 0; ++ unsigned int pos, i; ++ int col, row; ++ Arg new_arg; ++ ++ columns = LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0); ++ ++ for (i = 0; i < LENGTH(tags); ++i) { ++ if (!(selmon->tagset[selmon->seltags] & 1 << i)) { ++ continue; ++ } ++ pos = i; ++ row = pos / columns; ++ col = pos % columns; ++ if (arg->ui & SWITCHTAG_UP) { /* UP */ ++ row --; ++ if (row < 0) { ++ row = tagrows - 1; ++ } ++ do { ++ pos = row * columns + col; ++ row --; ++ } while (pos >= LENGTH(tags)); ++ } ++ if (arg->ui & SWITCHTAG_DOWN) { /* DOWN */ ++ row ++; ++ if (row >= tagrows) { ++ row = 0; ++ } ++ pos = row * columns + col; ++ if (pos >= LENGTH(tags)) { ++ row = 0; ++ } ++ pos = row * columns + col; ++ } ++ if (arg->ui & SWITCHTAG_LEFT) { /* LEFT */ ++ col --; ++ if (col < 0) { ++ col = columns - 1; ++ } ++ do { ++ pos = row * columns + col; ++ col --; ++ } while (pos >= LENGTH(tags)); ++ } ++ if (arg->ui & SWITCHTAG_RIGHT) { /* RIGHT */ ++ col ++; ++ if (col >= columns) { ++ col = 0; ++ } ++ pos = row * columns + col; ++ if (pos >= LENGTH(tags)) { ++ col = 0; ++ pos = row * columns + col; ++ } ++ } ++ new_tagset |= 1 << pos; ++ } ++ new_arg.ui = new_tagset; ++ if (arg->ui & SWITCHTAG_TOGGLETAG) { ++ toggletag(&new_arg); ++ } ++ if (arg->ui & SWITCHTAG_TAG) { ++ tag(&new_arg); ++ } ++ if (arg->ui & SWITCHTAG_VIEW) { ++ view (&new_arg); ++ } ++ if (arg->ui & SWITCHTAG_TOGGLEVIEW) { ++ toggleview (&new_arg); ++ } ++} + + void + tag(const Arg *arg) { diff --git a/dwm.suckless.org/patches/taggrid.md b/dwm.suckless.org/patches/taggrid.md @@ -0,0 +1,57 @@ +taggrid +===== +Description +----------- +This patch adds an ability to place tags in rows like in many other +window managers like xfce ore OpenBox. + +Applying +-------- +Patch uses drawtagmask flagset to show tags. Two flags can be applied to it: +#define DRAWCLASSICTAGS 1 << 0 +this will make patch to draw classic tags row; +#define DRAWTAGGRID 1 << 1 +this will make patch to draw the grid of tags like this: + +![alt text](taggrid.png) + +The patch defines switchtag function which handle global shortcuts to +navigate in grid. This function accept unsigned int argument which represents +flagset of next flags: + +#define SWITCHTAG_UP 1 << 0 +#define SWITCHTAG_DOWN 1 << 1 +#define SWITCHTAG_LEFT 1 << 2 +#define SWITCHTAG_RIGHT 1 << 3 +this four defines the direction of moving current tags; + +#define SWITCHTAG_TOGGLETAG 1 << 4 +#define SWITCHTAG_TAG 1 << 5 +#define SWITCHTAG_VIEW 1 << 6 +#define SWITCHTAG_TOGGLEVIEW 1 << 7 +this four defines the behaviour of switching. They will make switchtag work +like according functions. + +Example +------- + { MODKEY|ControlMask, XK_Up, switchtag, { .ui = SWITCHTAG_UP | SWITCHTAG_VIEW } }, + { MODKEY|ControlMask, XK_Down, switchtag, { .ui = SWITCHTAG_DOWN | SWITCHTAG_VIEW } }, + { MODKEY|ControlMask, XK_Right, switchtag, { .ui = SWITCHTAG_RIGHT | SWITCHTAG_VIEW } }, + { MODKEY|ControlMask, XK_Left, switchtag, { .ui = SWITCHTAG_LEFT | SWITCHTAG_VIEW } }, +This will simply move set of active tags on specified (UP, DOWN, RIGHT or LEFT) direction by pressing ctrl+alt+ARROW. + + { MODKEY|Mod4Mask, XK_Up, switchtag, { .ui = SWITCHTAG_UP | SWITCHTAG_TAG | SWITCHTAG_VIEW } }, + { MODKEY|Mod4Mask, XK_Down, switchtag, { .ui = SWITCHTAG_DOWN | SWITCHTAG_TAG | SWITCHTAG_VIEW } }, + { MODKEY|Mod4Mask, XK_Right, switchtag, { .ui = SWITCHTAG_RIGHT | SWITCHTAG_TAG | SWITCHTAG_VIEW } }, + { MODKEY|Mod4Mask, XK_Left, switchtag, { .ui = SWITCHTAG_LEFT | SWITCHTAG_TAG | SWITCHTAG_VIEW } }, +This will move active window on specified direction and perform the action, described above. + +Download +-------- + + * [dwm-6.1-taggrid.diff](dwm-6.1-xkb.diff) (2014-02-16) + +Author +------ + + * Yury Shvedov - shved at lvk dot cs dot msu dot su (or mestofel13 at gmail dot com). diff --git a/dwm.suckless.org/patches/taggrid.png b/dwm.suckless.org/patches/taggrid.png Binary files differ.