dwm-focusadjacenttag-6.0.diff (3740B)
1 diff -up a/config.h b/config.h 2 --- a/config.h 2014-06-23 18:04:29.536917000 +0200 3 +++ b/config.h 2014-06-24 08:15:51.857173332 +0200 4 @@ -74,6 +74,10 @@ static Key keys[] = { 5 { MODKEY, XK_period, focusmon, {.i = +1 } }, 6 { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, 7 { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, 8 + { MODKEY, XK_Left, viewtoleft, {0} }, 9 + { MODKEY, XK_Right, viewtoright, {0} }, 10 + { MODKEY|ShiftMask, XK_Left, tagtoleft, {0} }, 11 + { MODKEY|ShiftMask, XK_Right, tagtoright, {0} }, 12 TAGKEYS( XK_1, 0) 13 TAGKEYS( XK_2, 1) 14 TAGKEYS( XK_3, 2) 15 diff -up a/dwm.1 b/dwm.1 16 --- a/dwm.1 2014-06-23 18:04:29.532917821 +0200 17 +++ b/dwm.1 2014-06-23 21:52:54.095867809 +0200 18 @@ -71,6 +71,18 @@ Send focused window to previous screen, 19 .B Mod1\-Shift\-. 20 Send focused window to next screen, if any. 21 .TP 22 +.B Mod1\-Right 23 +Focus tag on the right, if any. 24 +.TP 25 +.B Mod1\-Left 26 +Focus tag on the left, if any. 27 +.TP 28 +.B Mod1\-Shift\-Right 29 +Send focused window to tag on the right, if any. 30 +.TP 31 +.B Mod1\-Shift\-Left 32 +Send focused window to tag on the left, if any. 33 +.TP 34 .B Mod1\-b 35 Toggles bar on and off. 36 .TP 37 diff -up a/dwm.c b/dwm.c 38 --- a/dwm.c 2014-06-23 18:04:29.532917821 +0200 39 +++ b/dwm.c 2014-06-24 08:17:40.921714154 +0200 40 @@ -226,6 +226,8 @@ static void sigchld(int unused); 41 static void spawn(const Arg *arg); 42 static void tag(const Arg *arg); 43 static void tagmon(const Arg *arg); 44 +static void tagtoleft(const Arg *arg); 45 +static void tagtoright(const Arg *arg); 46 static int textnw(const char *text, unsigned int len); 47 static void tile(Monitor *); 48 static void togglebar(const Arg *arg); 49 @@ -245,6 +247,8 @@ static void updatewindowtype(Client *c); 50 static void updatetitle(Client *c); 51 static void updatewmhints(Client *c); 52 static void view(const Arg *arg); 53 +static void viewtoleft(const Arg *arg); 54 +static void viewtoright(const Arg *arg); 55 static Client *wintoclient(Window w); 56 static Monitor *wintomon(Window w); 57 static int xerror(Display *dpy, XErrorEvent *ee); 58 @@ -1690,6 +1694,28 @@ tagmon(const Arg *arg) { 59 sendmon(selmon->sel, dirtomon(arg->i)); 60 } 61 62 +void 63 +tagtoleft(const Arg *arg) { 64 + if(selmon->sel != NULL 65 + && __builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 66 + && selmon->tagset[selmon->seltags] > 1) { 67 + selmon->sel->tags >>= 1; 68 + focus(NULL); 69 + arrange(selmon); 70 + } 71 +} 72 + 73 +void 74 +tagtoright(const Arg *arg) { 75 + if(selmon->sel != NULL 76 + && __builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 77 + && selmon->tagset[selmon->seltags] & (TAGMASK >> 1)) { 78 + selmon->sel->tags <<= 1; 79 + focus(NULL); 80 + arrange(selmon); 81 + } 82 +} 83 + 84 int 85 textnw(const char *text, unsigned int len) { 86 XRectangle r; 87 @@ -2052,6 +2078,28 @@ view(const Arg *arg) { 88 arrange(selmon); 89 } 90 91 +void 92 +viewtoleft(const Arg *arg) { 93 + if(__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 94 + && selmon->tagset[selmon->seltags] > 1) { 95 + selmon->seltags ^= 1; /* toggle sel tagset */ 96 + selmon->tagset[selmon->seltags] = selmon->tagset[selmon->seltags ^ 1] >> 1; 97 + focus(NULL); 98 + arrange(selmon); 99 + } 100 +} 101 + 102 +void 103 +viewtoright(const Arg *arg) { 104 + if(__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 105 + && selmon->tagset[selmon->seltags] & (TAGMASK >> 1)) { 106 + selmon->seltags ^= 1; /* toggle sel tagset */ 107 + selmon->tagset[selmon->seltags] = selmon->tagset[selmon->seltags ^ 1] << 1; 108 + focus(NULL); 109 + arrange(selmon); 110 + } 111 +} 112 + 113 Client * 114 wintoclient(Window w) { 115 Client *c;