Skip to content

Commit

Permalink
added viewprev() and viewnext() for simple tag navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
Uffke authored and Uffke committed Sep 12, 2011
1 parent 08c51ce commit 04da24e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ static Key keys[] = {
{ MODKEY, XK_period, focusmon, {.i = +1 } },
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
{ MODKEY, XK_Left, viewprev, {0} },
{ MODKEY, XK_Right, viewnext, {0} },
TAGKEYS( XK_1, 0)
TAGKEYS( XK_2, 1)
TAGKEYS( XK_3, 2)
Expand Down
20 changes: 20 additions & 0 deletions src/dwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ static void updatestatus(void);
static void updatetitle(Client *c);
static void updatewmhints(Client *c);
static void view(const Arg *arg);
static void viewnext(void);
static void viewprev(void);
static Client *wintoclient(Window w);
static Monitor *wintomon(Window w);
static int xerror(Display *dpy, XErrorEvent *ee);
Expand Down Expand Up @@ -1975,6 +1977,24 @@ view(const Arg *arg) {
arrange(selmon);
}

void
viewprev(void) {
if ( selmon->tagset[selmon->seltags] & (unsigned int) 1 )
selmon->tagset[selmon->seltags] = ((unsigned int) 1 << (LENGTH(tags) -1));
else
selmon->tagset[selmon->seltags] = selmon->tagset[selmon->seltags] >> 1;
arrange(selmon);
}

void
viewnext(void) {
if ( selmon->tagset[selmon->seltags] & ((unsigned int) 1 << (LENGTH(tags) -1)))
selmon->tagset[selmon->seltags] = (unsigned int) 1;
else
selmon->tagset[selmon->seltags] = selmon->tagset[selmon->seltags] << 1;
arrange(selmon);
}

Client *
wintoclient(Window w) {
Client *c;
Expand Down

0 comments on commit 04da24e

Please sign in to comment.