dwm-layoutscroll-6.2.diff - sites - public wiki contents of suckless.org | |
git clone git://git.suckless.org/sites | |
Log | |
Files | |
Refs | |
--- | |
dwm-layoutscroll-6.2.diff (1989B) | |
--- | |
1 diff --git a/config.def.h b/config.def.h | |
2 index 4c56466..11ee7b5 100644 | |
3 --- a/config.def.h | |
4 +++ b/config.def.h | |
5 @@ -90,6 +90,8 @@ static Key keys[] = { | |
6 { MODKEY, XK_period, focusmon, {.i … | |
7 { MODKEY|ShiftMask, XK_comma, tagmon, {.i … | |
8 { MODKEY|ShiftMask, XK_period, tagmon, {.i … | |
9 + { MODKEY|ShiftMask, XK_h, layoutscroll, {.i … | |
10 + { MODKEY|ShiftMask, XK_l, layoutscroll, {.i … | |
11 TAGKEYS( XK_1, 0) | |
12 TAGKEYS( XK_2, 1) | |
13 TAGKEYS( XK_3, 2) | |
14 diff --git a/dwm.c b/dwm.c | |
15 index 1e37fcf..24effbc 100644 | |
16 --- a/dwm.c | |
17 +++ b/dwm.c | |
18 @@ -148,6 +148,7 @@ struct Monitor { | |
19 Monitor *next; | |
20 Window barwin; | |
21 const Layout *lt[2]; | |
22 + int ltcur; /* current layout */ | |
23 }; | |
24 | |
25 typedef struct { | |
26 @@ -227,6 +228,7 @@ static void sendmon(Client *c, Monitor *m); | |
27 static void setclientstate(Client *c, long state); | |
28 static void setfocus(Client *c); | |
29 static void setfullscreen(Client *c, int fullscreen); | |
30 +static void layoutscroll(const Arg *arg); | |
31 static void setlayout(const Arg *arg); | |
32 static void setmfact(const Arg *arg); | |
33 static void setup(void); | |
34 @@ -725,6 +727,7 @@ createmon(void) | |
35 m->nmaster = nmaster; | |
36 m->showbar = showbar; | |
37 m->topbar = topbar; | |
38 + m->ltcur = 0; | |
39 m->lt[0] = &layouts[0]; | |
40 m->lt[1] = &layouts[1 % LENGTH(layouts)]; | |
41 strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); | |
42 @@ -1667,6 +1670,25 @@ setfullscreen(Client *c, int fullscreen) | |
43 } | |
44 } | |
45 | |
46 +void | |
47 +layoutscroll(const Arg *arg) | |
48 +{ | |
49 + if (!arg || !arg->i) | |
50 + return; | |
51 + int switchto = selmon->ltcur + arg->i; | |
52 + int l = LENGTH(layouts); | |
53 + | |
54 + if (switchto == l) | |
55 + switchto = 0; | |
56 + else if(switchto < 0) | |
57 + switchto = l - 1; | |
58 + | |
59 + selmon->ltcur = switchto; | |
60 + Arg arg2 = {.v= &layouts[switchto] }; | |
61 + setlayout(&arg2); | |
62 + | |
63 +} | |
64 + | |
65 void | |
66 setlayout(const Arg *arg) | |
67 { |