dwm-adjacenttag-6.2.diff - sites - public wiki contents of suckless.org
HTML git clone git://git.suckless.org/sites
DIR Log
DIR Files
DIR Refs
---
dwm-adjacenttag-6.2.diff (3431B)
---
1 diff -up a/config.def.h b/config.def.h
2 --- a/config.def.h 2021-10-02 13:57:18.011307099 +0100
3 +++ b/config.def.h 2021-10-02 13:58:07.812080253 +0100
4 @@ -84,6 +84,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_Right, viewnext, {0} },
9 + { MODKEY, XK_Left, viewprev, {0} },
10 + { MODKEY|ShiftMask, XK_Right, tagtonext, {0} },
11 + { MODKEY|ShiftMask, XK_Left, tagtoprev, {0} },
12 TAGKEYS( XK_1, 0)
13 TAGKEYS( XK_2, 1)
14 TAGKEYS( XK_3, 2)
15 diff -up a/dwm.c b/dwm.c
16 --- a/dwm.c 2021-10-02 13:57:18.011307099 +0100
17 +++ b/dwm.c 2021-10-02 14:21:17.063622953 +0100
18 @@ -183,8 +183,10 @@ static void maprequest(XEvent *e);
19 static void monocle(Monitor *m);
20 static void motionnotify(XEvent *e);
21 static void movemouse(const Arg *arg);
22 +static unsigned int nexttag(void);
23 static Client *nexttiled(Client *c);
24 static void pop(Client *);
25 +static unsigned int prevtag(void);
26 static void propertynotify(XEvent *e);
27 static void quit(const Arg *arg);
28 static Monitor *recttomon(int x, int y, int w, int h);
29 @@ -208,6 +210,8 @@ static void sigchld(int unused);
30 static void spawn(const Arg *arg);
31 static void tag(const Arg *arg);
32 static void tagmon(const Arg *arg);
33 +static void tagtonext(const Arg *arg);
34 +static void tagtoprev(const Arg *arg);
35 static void tile(Monitor *);
36 static void togglebar(const Arg *arg);
37 static void togglefloating(const Arg *arg);
38 @@ -227,6 +231,8 @@ static void updatetitle(Client *c);
39 static void updatewindowtype(Client *c);
40 static void updatewmhints(Client *c);
41 static void view(const Arg *arg);
42 +static void viewnext(const Arg *arg);
43 +static void viewprev(const Arg *arg);
44 static Client *wintoclient(Window w);
45 static Monitor *wintomon(Window w);
46 static int xerror(Display *dpy, XErrorEvent *ee);
47 @@ -1192,6 +1198,13 @@ movemouse(const Arg *arg)
48 }
49 }
50
51 +unsigned int
52 +nexttag(void)
53 +{
54 + unsigned int seltag = selmon->tagset[selmon->seltags];
55 + return seltag == (1 << (LENGTH(tags) - 1)) ? 1 : seltag << 1;
56 +}
57 +
58 Client *
59 nexttiled(Client *c)
60 {
61 @@ -1208,6 +1221,13 @@ pop(Client *c)
62 arrange(c->mon);
63 }
64
65 +unsigned int
66 +prevtag(void)
67 +{
68 + unsigned int seltag = selmon->tagset[selmon->seltags];
69 + return seltag == 1 ? (1 << (LENGTH(tags) - 1)) : seltag >> 1;
70 +}
71 +
72 void
73 propertynotify(XEvent *e)
74 {
75 @@ -1671,6 +1691,32 @@ tagmon(const Arg *arg)
76 }
77
78 void
79 +tagtonext(const Arg *arg)
80 +{
81 + unsigned int tmp;
82 +
83 + if (selmon->sel == NULL)
84 + return;
85 +
86 + tmp = nexttag();
87 + tag(&(const Arg){.ui = tmp });
88 + view(&(const Arg){.ui = tmp });
89 +}
90 +
91 +void
92 +tagtoprev(const Arg *arg)
93 +{
94 + unsigned int tmp;
95 +
96 + if (selmon->sel == NULL)
97 + return;
98 +
99 + tmp = prevtag();
100 + tag(&(const Arg){.ui = tmp });
101 + view(&(const Arg){.ui = tmp });
102 +}
103 +
104 +void
105 tile(Monitor *m)
106 {
107 unsigned int i, n, h, mw, my, ty;
108 @@ -2044,6 +2090,18 @@ view(const Arg *arg)
109 arrange(selmon);
110 }
111
112 +void
113 +viewnext(const Arg *arg)
114 +{
115 + view(&(const Arg){.ui = nexttag()});
116 +}
117 +
118 +void
119 +viewprev(const Arg *arg)
120 +{
121 + view(&(const Arg){.ui = prevtag()});
122 +}
123 +
124 Client *
125 wintoclient(Window w)
126 {