layoutscroll patch
This commit is contained in:
parent
16de98fbf8
commit
127d89b424
|
|
@ -6,6 +6,7 @@
|
||||||
3. [scratchpad](https://dwm.suckless.org/patches/scratchpad/) patch for scratchpad
|
3. [scratchpad](https://dwm.suckless.org/patches/scratchpad/) patch for scratchpad
|
||||||
4. [bar height](https://dwm.suckless.org/patches/bar_height/) for changing bar's height
|
4. [bar height](https://dwm.suckless.org/patches/bar_height/) for changing bar's height
|
||||||
5. [pertag](https://dwm.suckless.org/patches/pertag/) for layout for each tag.
|
5. [pertag](https://dwm.suckless.org/patches/pertag/) for layout for each tag.
|
||||||
6. [swallow](https://dwm.suckless.org/patches/swallow/) patch for swallowing windows (have reversed the patch right now.)
|
6. [layoutscroll](https://dwm.suckless.org/patches/layoutscroll/) for scrolling through layouts with ``mod+shift+tab``
|
||||||
|
7. [swallow](https://dwm.suckless.org/patches/swallow/) patch for swallowing windows (have reversed the patch right now.)
|
||||||
|
|
||||||
### MAKE SURE TO INSTALL ``libxft-bgra`` OR DWM WILL CRASH
|
### MAKE SURE TO INSTALL ``libxft-bgra`` OR DWM WILL CRASH
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,8 @@ static Key keys[] = {
|
||||||
{ MODKEY, XK_period, focusmon, {.i = +1 } },
|
{ MODKEY, XK_period, focusmon, {.i = +1 } },
|
||||||
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
|
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
|
||||||
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
|
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
|
||||||
|
// { MODKEY|ShiftMask, XK_h, layoutscroll, {.i = -1 } },
|
||||||
|
{ MODKEY|ShiftMask, XK_Tab, layoutscroll, {.i = +1 } },
|
||||||
{ MODKEY, XK_minus, setgaps, {.i = -1 } },
|
{ MODKEY, XK_minus, setgaps, {.i = -1 } },
|
||||||
{ MODKEY, XK_equal, setgaps, {.i = +1 } },
|
{ MODKEY, XK_equal, setgaps, {.i = +1 } },
|
||||||
{ MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } },
|
{ MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } },
|
||||||
|
|
|
||||||
2
config.h
2
config.h
|
|
@ -93,6 +93,8 @@ static Key keys[] = {
|
||||||
{ MODKEY, XK_period, focusmon, {.i = +1 } },
|
{ MODKEY, XK_period, focusmon, {.i = +1 } },
|
||||||
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
|
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
|
||||||
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
|
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
|
||||||
|
// { MODKEY|ShiftMask, XK_h, layoutscroll, {.i = -1 } },
|
||||||
|
{ MODKEY|ShiftMask, XK_Tab, layoutscroll, {.i = +1 } },
|
||||||
{ MODKEY, XK_minus, setgaps, {.i = -1 } },
|
{ MODKEY, XK_minus, setgaps, {.i = -1 } },
|
||||||
{ MODKEY, XK_equal, setgaps, {.i = +1 } },
|
{ MODKEY, XK_equal, setgaps, {.i = +1 } },
|
||||||
{ MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } },
|
{ MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } },
|
||||||
|
|
|
||||||
22
dwm.c
22
dwm.c
|
|
@ -148,6 +148,7 @@ struct Monitor {
|
||||||
Monitor *next;
|
Monitor *next;
|
||||||
Window barwin;
|
Window barwin;
|
||||||
const Layout *lt[2];
|
const Layout *lt[2];
|
||||||
|
int ltcur; /* current layout */
|
||||||
Pertag *pertag;
|
Pertag *pertag;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -220,6 +221,7 @@ static void sendmon(Client *c, Monitor *m);
|
||||||
static void setclientstate(Client *c, long state);
|
static void setclientstate(Client *c, long state);
|
||||||
static void setfocus(Client *c);
|
static void setfocus(Client *c);
|
||||||
static void setfullscreen(Client *c, int fullscreen);
|
static void setfullscreen(Client *c, int fullscreen);
|
||||||
|
static void layoutscroll(const Arg *arg);
|
||||||
static void setgaps(const Arg *arg);
|
static void setgaps(const Arg *arg);
|
||||||
static void setlayout(const Arg *arg);
|
static void setlayout(const Arg *arg);
|
||||||
static void setmfact(const Arg *arg);
|
static void setmfact(const Arg *arg);
|
||||||
|
|
@ -675,6 +677,7 @@ createmon(void)
|
||||||
m->nmaster = nmaster;
|
m->nmaster = nmaster;
|
||||||
m->showbar = showbar;
|
m->showbar = showbar;
|
||||||
m->topbar = topbar;
|
m->topbar = topbar;
|
||||||
|
m->ltcur = 0;
|
||||||
m->gappx = gappx;
|
m->gappx = gappx;
|
||||||
m->lt[0] = &layouts[0];
|
m->lt[0] = &layouts[0];
|
||||||
m->lt[1] = &layouts[1 % LENGTH(layouts)];
|
m->lt[1] = &layouts[1 % LENGTH(layouts)];
|
||||||
|
|
@ -1600,6 +1603,25 @@ setgaps(const Arg *arg)
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
layoutscroll(const Arg *arg)
|
||||||
|
{
|
||||||
|
if (!arg || !arg->i)
|
||||||
|
return;
|
||||||
|
int switchto = selmon->ltcur + arg->i;
|
||||||
|
int l = LENGTH(layouts);
|
||||||
|
|
||||||
|
if (switchto == l)
|
||||||
|
switchto = 0;
|
||||||
|
else if(switchto < 0)
|
||||||
|
switchto = l - 1;
|
||||||
|
|
||||||
|
selmon->ltcur = switchto;
|
||||||
|
Arg arg2 = {.v= &layouts[switchto] };
|
||||||
|
setlayout(&arg2);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
setlayout(const Arg *arg)
|
setlayout(const Arg *arg)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,67 @@
|
||||||
|
diff --git a/config.def.h b/config.def.h
|
||||||
|
index 4c56466..11ee7b5 100644
|
||||||
|
--- a/config.def.h
|
||||||
|
+++ b/config.def.h
|
||||||
|
@@ -90,6 +90,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|ShiftMask, XK_h, layoutscroll, {.i = -1 } },
|
||||||
|
+ { MODKEY|ShiftMask, XK_l, layoutscroll, {.i = +1 } },
|
||||||
|
TAGKEYS( XK_1, 0)
|
||||||
|
TAGKEYS( XK_2, 1)
|
||||||
|
TAGKEYS( XK_3, 2)
|
||||||
|
diff --git a/dwm.c b/dwm.c
|
||||||
|
index 1e37fcf..24effbc 100644
|
||||||
|
--- a/dwm.c
|
||||||
|
+++ b/dwm.c
|
||||||
|
@@ -148,6 +148,7 @@ struct Monitor {
|
||||||
|
Monitor *next;
|
||||||
|
Window barwin;
|
||||||
|
const Layout *lt[2];
|
||||||
|
+ int ltcur; /* current layout */
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
@@ -227,6 +228,7 @@ static void sendmon(Client *c, Monitor *m);
|
||||||
|
static void setclientstate(Client *c, long state);
|
||||||
|
static void setfocus(Client *c);
|
||||||
|
static void setfullscreen(Client *c, int fullscreen);
|
||||||
|
+static void layoutscroll(const Arg *arg);
|
||||||
|
static void setlayout(const Arg *arg);
|
||||||
|
static void setmfact(const Arg *arg);
|
||||||
|
static void setup(void);
|
||||||
|
@@ -725,6 +727,7 @@ createmon(void)
|
||||||
|
m->nmaster = nmaster;
|
||||||
|
m->showbar = showbar;
|
||||||
|
m->topbar = topbar;
|
||||||
|
+ m->ltcur = 0;
|
||||||
|
m->lt[0] = &layouts[0];
|
||||||
|
m->lt[1] = &layouts[1 % LENGTH(layouts)];
|
||||||
|
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
|
||||||
|
@@ -1667,6 +1670,25 @@ setfullscreen(Client *c, int fullscreen)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+void
|
||||||
|
+layoutscroll(const Arg *arg)
|
||||||
|
+{
|
||||||
|
+ if (!arg || !arg->i)
|
||||||
|
+ return;
|
||||||
|
+ int switchto = selmon->ltcur + arg->i;
|
||||||
|
+ int l = LENGTH(layouts);
|
||||||
|
+
|
||||||
|
+ if (switchto == l)
|
||||||
|
+ switchto = 0;
|
||||||
|
+ else if(switchto < 0)
|
||||||
|
+ switchto = l - 1;
|
||||||
|
+
|
||||||
|
+ selmon->ltcur = switchto;
|
||||||
|
+ Arg arg2 = {.v= &layouts[switchto] };
|
||||||
|
+ setlayout(&arg2);
|
||||||
|
+
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void
|
||||||
|
setlayout(const Arg *arg)
|
||||||
|
{
|
||||||
Reference in New Issue