mirror of
https://github.com/tiyn/dwm.git
synced 2025-04-19 15:57:45 +02:00
added cyclelayouts patch to master
This commit is contained in:
commit
b5e01d916b
@ -22,11 +22,13 @@ static const char selbordercolor[] = "#555a63";
|
|||||||
static const char selbgcolor[] = "#282828";
|
static const char selbgcolor[] = "#282828";
|
||||||
static const unsigned int baralpha = 0xff;
|
static const unsigned int baralpha = 0xff;
|
||||||
static const unsigned int borderalpha = OPAQUE;
|
static const unsigned int borderalpha = OPAQUE;
|
||||||
|
|
||||||
static const char *colors[][3] = {
|
static const char *colors[][3] = {
|
||||||
/* fg bg border */
|
/* fg bg border */
|
||||||
[SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor },
|
[SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor },
|
||||||
[SchemeSel] = { selfgcolor, selbgcolor, selbordercolor },
|
[SchemeSel] = { selfgcolor, selbgcolor, selbordercolor },
|
||||||
};
|
};
|
||||||
|
|
||||||
static const unsigned int alphas[][3] = {
|
static const unsigned int alphas[][3] = {
|
||||||
/* fg bg border */
|
/* fg bg border */
|
||||||
[SchemeNorm] = { OPAQUE, baralpha, borderalpha },
|
[SchemeNorm] = { OPAQUE, baralpha, borderalpha },
|
||||||
@ -58,6 +60,7 @@ static const Layout layouts[] = {
|
|||||||
{ "B", bstack },
|
{ "B", bstack },
|
||||||
{ "B", bstackhoriz },
|
{ "B", bstackhoriz },
|
||||||
{ "F", NULL }, /* no layout function means floating behavior */
|
{ "F", NULL }, /* no layout function means floating behavior */
|
||||||
|
{ NULL, NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
/* key definitions */
|
/* key definitions */
|
||||||
@ -105,6 +108,7 @@ static Key keys[] = {
|
|||||||
//{ MODKEY|ShiftMask, XK_o, incnmaster, {.i = +1} },
|
//{ MODKEY|ShiftMask, XK_o, incnmaster, {.i = +1} },
|
||||||
//{ MODKEY|ShiftMask, XK_z, incnmaster, {.i = -1} },
|
//{ MODKEY|ShiftMask, XK_z, incnmaster, {.i = -1} },
|
||||||
//{ MODKEY, XK_space, setlayout, {0} },
|
//{ MODKEY, XK_space, setlayout, {0} },
|
||||||
|
|
||||||
TAGKEYS(XK_1, 0)
|
TAGKEYS(XK_1, 0)
|
||||||
TAGKEYS(XK_2, 1)
|
TAGKEYS(XK_2, 1)
|
||||||
TAGKEYS(XK_3, 2)
|
TAGKEYS(XK_3, 2)
|
||||||
@ -121,7 +125,9 @@ static Key keys[] = {
|
|||||||
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
|
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
|
||||||
static Button buttons[] = {
|
static Button buttons[] = {
|
||||||
/* click event mask button function argument */
|
/* click event mask button function argument */
|
||||||
{ ClkLtSymbol, 0, Button1, setlayout, {.v = 0 } },
|
{ ClkLtSymbol, 0, Button1, cyclelayout, {.i = +1} },
|
||||||
|
{ ClkLtSymbol, 0, Button2, setlayout, {.v = &layouts[0]} },
|
||||||
|
{ ClkLtSymbol, 0, Button3, cyclelayout, {.i = -1} },
|
||||||
{ ClkWinTitle, 0, Button2, zoom, {0} },
|
{ ClkWinTitle, 0, Button2, zoom, {0} },
|
||||||
{ ClkStatusText, 0, Button1, sigdwmblocks, {.i = 1} },
|
{ ClkStatusText, 0, Button1, sigdwmblocks, {.i = 1} },
|
||||||
{ ClkStatusText, 0, Button2, sigdwmblocks, {.i = 2} },
|
{ ClkStatusText, 0, Button2, sigdwmblocks, {.i = 2} },
|
||||||
|
8
config.h
8
config.h
@ -22,11 +22,13 @@ static const char selbordercolor[] = "#555a63";
|
|||||||
static const char selbgcolor[] = "#282828";
|
static const char selbgcolor[] = "#282828";
|
||||||
static const unsigned int baralpha = 0xff;
|
static const unsigned int baralpha = 0xff;
|
||||||
static const unsigned int borderalpha = OPAQUE;
|
static const unsigned int borderalpha = OPAQUE;
|
||||||
|
|
||||||
static const char *colors[][3] = {
|
static const char *colors[][3] = {
|
||||||
/* fg bg border */
|
/* fg bg border */
|
||||||
[SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor },
|
[SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor },
|
||||||
[SchemeSel] = { selfgcolor, selbgcolor, selbordercolor },
|
[SchemeSel] = { selfgcolor, selbgcolor, selbordercolor },
|
||||||
};
|
};
|
||||||
|
|
||||||
static const unsigned int alphas[][3] = {
|
static const unsigned int alphas[][3] = {
|
||||||
/* fg bg border */
|
/* fg bg border */
|
||||||
[SchemeNorm] = { OPAQUE, baralpha, borderalpha },
|
[SchemeNorm] = { OPAQUE, baralpha, borderalpha },
|
||||||
@ -58,6 +60,7 @@ static const Layout layouts[] = {
|
|||||||
{ "B", bstack },
|
{ "B", bstack },
|
||||||
{ "B", bstackhoriz },
|
{ "B", bstackhoriz },
|
||||||
{ "F", NULL }, /* no layout function means floating behavior */
|
{ "F", NULL }, /* no layout function means floating behavior */
|
||||||
|
{ NULL, NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
/* key definitions */
|
/* key definitions */
|
||||||
@ -105,6 +108,7 @@ static Key keys[] = {
|
|||||||
//{ MODKEY|ShiftMask, XK_o, incnmaster, {.i = +1} },
|
//{ MODKEY|ShiftMask, XK_o, incnmaster, {.i = +1} },
|
||||||
//{ MODKEY|ShiftMask, XK_z, incnmaster, {.i = -1} },
|
//{ MODKEY|ShiftMask, XK_z, incnmaster, {.i = -1} },
|
||||||
//{ MODKEY, XK_space, setlayout, {0} },
|
//{ MODKEY, XK_space, setlayout, {0} },
|
||||||
|
|
||||||
TAGKEYS(XK_1, 0)
|
TAGKEYS(XK_1, 0)
|
||||||
TAGKEYS(XK_2, 1)
|
TAGKEYS(XK_2, 1)
|
||||||
TAGKEYS(XK_3, 2)
|
TAGKEYS(XK_3, 2)
|
||||||
@ -121,7 +125,9 @@ static Key keys[] = {
|
|||||||
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
|
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
|
||||||
static Button buttons[] = {
|
static Button buttons[] = {
|
||||||
/* click event mask button function argument */
|
/* click event mask button function argument */
|
||||||
{ ClkLtSymbol, 0, Button1, setlayout, {.v = 0 } },
|
{ ClkLtSymbol, 0, Button1, cyclelayout, {.i = +1} },
|
||||||
|
{ ClkLtSymbol, 0, Button2, setlayout, {.v = &layouts[0]} },
|
||||||
|
{ ClkLtSymbol, 0, Button3, cyclelayout, {.i = -1} },
|
||||||
{ ClkWinTitle, 0, Button2, zoom, {0} },
|
{ ClkWinTitle, 0, Button2, zoom, {0} },
|
||||||
{ ClkStatusText, 0, Button1, sigdwmblocks, {.i = 1} },
|
{ ClkStatusText, 0, Button1, sigdwmblocks, {.i = 1} },
|
||||||
{ ClkStatusText, 0, Button2, sigdwmblocks, {.i = 2} },
|
{ ClkStatusText, 0, Button2, sigdwmblocks, {.i = 2} },
|
||||||
|
93
dwm-cyclelayouts-20180524-6.2.diff
Normal file
93
dwm-cyclelayouts-20180524-6.2.diff
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
From a09e766a4342f580582082a92b2de65f33208eb4 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Christopher Drelich <cd@cdrakka.com>
|
||||||
|
Date: Thu, 24 May 2018 00:56:56 -0400
|
||||||
|
Subject: [PATCH] Function to cycle through available layouts.
|
||||||
|
|
||||||
|
MOD-CTRL-, and MOD-CTRL-.
|
||||||
|
cycle backwards and forwards through available layouts.
|
||||||
|
Probably only useful if you have a lot of additional layouts.
|
||||||
|
The NULL, NULL layout should always be the last layout in your list,
|
||||||
|
in order to guarantee consistent behavior.
|
||||||
|
---
|
||||||
|
config.def.h | 3 +++
|
||||||
|
dwm.1 | 6 ++++++
|
||||||
|
dwm.c | 18 ++++++++++++++++++
|
||||||
|
3 files changed, 27 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/config.def.h b/config.def.h
|
||||||
|
index a9ac303..153b880 100644
|
||||||
|
--- a/config.def.h
|
||||||
|
+++ b/config.def.h
|
||||||
|
@@ -41,6 +41,7 @@ static const Layout layouts[] = {
|
||||||
|
{ "[]=", tile }, /* first entry is default */
|
||||||
|
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||||
|
{ "[M]", monocle },
|
||||||
|
+ { NULL, NULL },
|
||||||
|
};
|
||||||
|
|
||||||
|
/* key definitions */
|
||||||
|
@@ -76,6 +77,8 @@ static Key keys[] = {
|
||||||
|
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
||||||
|
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
||||||
|
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
||||||
|
+ { MODKEY|ControlMask, XK_comma, cyclelayout, {.i = -1 } },
|
||||||
|
+ { MODKEY|ControlMask, XK_period, cyclelayout, {.i = +1 } },
|
||||||
|
{ MODKEY, XK_space, setlayout, {0} },
|
||||||
|
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
||||||
|
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
||||||
|
diff --git a/dwm.1 b/dwm.1
|
||||||
|
index 13b3729..165891b 100644
|
||||||
|
--- a/dwm.1
|
||||||
|
+++ b/dwm.1
|
||||||
|
@@ -92,6 +92,12 @@ Sets monocle layout.
|
||||||
|
.B Mod1\-space
|
||||||
|
Toggles between current and previous layout.
|
||||||
|
.TP
|
||||||
|
+.B Mod1\-Control\-,
|
||||||
|
+Cycles backwards in layout list.
|
||||||
|
+.TP
|
||||||
|
+.B Mod1\-Control\-.
|
||||||
|
+Cycles forwards in layout list.
|
||||||
|
+.TP
|
||||||
|
.B Mod1\-j
|
||||||
|
Focus next window.
|
||||||
|
.TP
|
||||||
|
diff --git a/dwm.c b/dwm.c
|
||||||
|
index bb95e26..db73000 100644
|
||||||
|
--- a/dwm.c
|
||||||
|
+++ b/dwm.c
|
||||||
|
@@ -157,6 +157,7 @@ static void configure(Client *c);
|
||||||
|
static void configurenotify(XEvent *e);
|
||||||
|
static void configurerequest(XEvent *e);
|
||||||
|
static Monitor *createmon(void);
|
||||||
|
+static void cyclelayout(const Arg *arg);
|
||||||
|
static void destroynotify(XEvent *e);
|
||||||
|
static void detach(Client *c);
|
||||||
|
static void detachstack(Client *c);
|
||||||
|
@@ -645,6 +646,23 @@ createmon(void)
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
+cyclelayout(const Arg *arg) {
|
||||||
|
+ Layout *l;
|
||||||
|
+ for(l = (Layout *)layouts; l != selmon->lt[selmon->sellt]; l++);
|
||||||
|
+ if(arg->i > 0) {
|
||||||
|
+ if(l->symbol && (l + 1)->symbol)
|
||||||
|
+ setlayout(&((Arg) { .v = (l + 1) }));
|
||||||
|
+ else
|
||||||
|
+ setlayout(&((Arg) { .v = layouts }));
|
||||||
|
+ } else {
|
||||||
|
+ if(l != layouts && (l - 1)->symbol)
|
||||||
|
+ setlayout(&((Arg) { .v = (l - 1) }));
|
||||||
|
+ else
|
||||||
|
+ setlayout(&((Arg) { .v = &layouts[LENGTH(layouts) - 2] }));
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
destroynotify(XEvent *e)
|
||||||
|
{
|
||||||
|
Client *c;
|
||||||
|
--
|
||||||
|
2.7.4
|
||||||
|
|
6
dwm.1
6
dwm.1
@ -92,6 +92,12 @@ Sets monocle layout.
|
|||||||
.B Mod1\-space
|
.B Mod1\-space
|
||||||
Toggles between current and previous layout.
|
Toggles between current and previous layout.
|
||||||
.TP
|
.TP
|
||||||
|
.B Mod1\-Control\-,
|
||||||
|
Cycles backwards in layout list.
|
||||||
|
.TP
|
||||||
|
.B Mod1\-Control\-.
|
||||||
|
Cycles forwards in layout list.
|
||||||
|
.TP
|
||||||
.B Mod1\-j
|
.B Mod1\-j
|
||||||
Focus next window.
|
Focus next window.
|
||||||
.TP
|
.TP
|
||||||
|
18
dwm.c
18
dwm.c
@ -187,6 +187,7 @@ static void configurerequest(XEvent *e);
|
|||||||
static void copyvalidchars(char *text, char *rawtext);
|
static void copyvalidchars(char *text, char *rawtext);
|
||||||
static Monitor *createmon(void);
|
static Monitor *createmon(void);
|
||||||
static void deck(Monitor *m);
|
static void deck(Monitor *m);
|
||||||
|
static void cyclelayout(const Arg *arg);
|
||||||
static void destroynotify(XEvent *e);
|
static void destroynotify(XEvent *e);
|
||||||
static void detach(Client *c);
|
static void detach(Client *c);
|
||||||
static void detachstack(Client *c);
|
static void detachstack(Client *c);
|
||||||
@ -809,6 +810,23 @@ createmon(void)
|
|||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cyclelayout(const Arg *arg) {
|
||||||
|
Layout *l;
|
||||||
|
for(l = (Layout *)layouts; l != selmon->lt[selmon->sellt]; l++);
|
||||||
|
if(arg->i > 0) {
|
||||||
|
if(l->symbol && (l + 1)->symbol)
|
||||||
|
setlayout(&((Arg) { .v = (l + 1) }));
|
||||||
|
else
|
||||||
|
setlayout(&((Arg) { .v = layouts }));
|
||||||
|
} else {
|
||||||
|
if(l != layouts && (l - 1)->symbol)
|
||||||
|
setlayout(&((Arg) { .v = (l - 1) }));
|
||||||
|
else
|
||||||
|
setlayout(&((Arg) { .v = &layouts[LENGTH(layouts) - 2] }));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
destroynotify(XEvent *e)
|
destroynotify(XEvent *e)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user