mirror of https://github.com/bakkeby/patches
Adding holdbar on top of keypressrelease patch
parent
188a1c8bbd
commit
73b097e032
@ -0,0 +1,91 @@
|
||||
From cd0e2f74816acd0943a2fec865751290383b5987 Mon Sep 17 00:00:00 2001
|
||||
From: bakkeby <bakkeby@gmail.com>
|
||||
Date: Thu, 3 Jun 2021 12:04:33 +0200
|
||||
Subject: [PATCH 2/2] Holdbar patch on top of keypressrelease
|
||||
|
||||
---
|
||||
config.def.h | 4 +++-
|
||||
dwm.c | 22 +++++++++++++++++++++-
|
||||
2 files changed, 24 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 06a6eee..3729e3c 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -44,7 +44,7 @@ static const Layout layouts[] = {
|
||||
};
|
||||
|
||||
/* key definitions */
|
||||
-#define MODKEY Mod1Mask
|
||||
+#define MODKEY Mod4Mask
|
||||
#define TAGKEYS(KEY,TAG) \
|
||||
{ KeyPress, MODKEY, KEY, view, {.ui = 1 << TAG} }, \
|
||||
{ KeyPress, MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
|
||||
@@ -61,6 +61,8 @@ static const char *termcmd[] = { "st", NULL };
|
||||
|
||||
static Key keys[] = {
|
||||
/* type modifier key function argument */
|
||||
+ { KeyPress, 0, XK_Super_L,enablebar, {0} },
|
||||
+ { KeyRelease, MODKEY, XK_Super_L,disablebar, {0} },
|
||||
{ KeyPress, MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
||||
{ KeyPress, MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
|
||||
{ KeyPress, MODKEY, XK_b, togglebar, {0} },
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index 9dcc53e..d7ae4a2 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -162,8 +162,10 @@ static void destroynotify(XEvent *e);
|
||||
static void detach(Client *c);
|
||||
static void detachstack(Client *c);
|
||||
static Monitor *dirtomon(int dir);
|
||||
+static void disablebar(const Arg *arg);
|
||||
static void drawbar(Monitor *m);
|
||||
static void drawbars(void);
|
||||
+static void enablebar(const Arg *arg);
|
||||
static void enternotify(XEvent *e);
|
||||
static void expose(XEvent *e);
|
||||
static void focus(Client *c);
|
||||
@@ -694,6 +696,15 @@ dirtomon(int dir)
|
||||
return m;
|
||||
}
|
||||
|
||||
+void
|
||||
+disablebar(const Arg *arg)
|
||||
+{
|
||||
+ if (selmon->showbar == 2) {
|
||||
+ selmon->showbar = 1;
|
||||
+ togglebar(arg);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void
|
||||
drawbar(Monitor *m)
|
||||
{
|
||||
@@ -753,6 +764,15 @@ drawbars(void)
|
||||
drawbar(m);
|
||||
}
|
||||
|
||||
+void
|
||||
+enablebar(const Arg *arg)
|
||||
+{
|
||||
+ if (!selmon->showbar) {
|
||||
+ togglebar(arg);
|
||||
+ selmon->showbar = 2;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void
|
||||
enternotify(XEvent *e)
|
||||
{
|
||||
@@ -1702,7 +1722,7 @@ tile(Monitor *m)
|
||||
void
|
||||
togglebar(const Arg *arg)
|
||||
{
|
||||
- selmon->showbar = !selmon->showbar;
|
||||
+ selmon->showbar = (selmon->showbar == 2 ? 1 : !selmon->showbar);
|
||||
updatebarpos(selmon);
|
||||
XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
|
||||
arrange(selmon);
|
||||
--
|
||||
2.19.1
|
||||
|
@ -0,0 +1,216 @@
|
||||
From 01f86394d4a01c418820c159125b22a5d1f40237 Mon Sep 17 00:00:00 2001
|
||||
From: bakkeby <bakkeby@gmail.com>
|
||||
Date: Thu, 3 Jun 2021 10:58:27 +0200
|
||||
Subject: [PATCH 1/2] keypressrelease patch
|
||||
|
||||
---
|
||||
config.def.h | 58 ++++++++++++++++++++++++++--------------------------
|
||||
dwm.c | 3 +++
|
||||
2 files changed, 32 insertions(+), 29 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 1c0b587..06a6eee 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -46,10 +46,10 @@ static const Layout layouts[] = {
|
||||
/* key definitions */
|
||||
#define MODKEY Mod1Mask
|
||||
#define TAGKEYS(KEY,TAG) \
|
||||
- { MODKEY, KEY, view, {.ui = 1 << TAG} }, \
|
||||
- { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
|
||||
- { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
|
||||
- { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} },
|
||||
+ { KeyPress, MODKEY, KEY, view, {.ui = 1 << TAG} }, \
|
||||
+ { KeyPress, MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
|
||||
+ { KeyPress, MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
|
||||
+ { KeyPress, MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} },
|
||||
|
||||
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
|
||||
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||
@@ -60,30 +60,30 @@ static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont,
|
||||
static const char *termcmd[] = { "st", NULL };
|
||||
|
||||
static Key keys[] = {
|
||||
- /* modifier key function argument */
|
||||
- { MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
||||
- { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
|
||||
- { MODKEY, XK_b, togglebar, {0} },
|
||||
- { MODKEY, XK_j, focusstack, {.i = +1 } },
|
||||
- { MODKEY, XK_k, focusstack, {.i = -1 } },
|
||||
- { MODKEY, XK_i, incnmaster, {.i = +1 } },
|
||||
- { MODKEY, XK_d, incnmaster, {.i = -1 } },
|
||||
- { MODKEY, XK_h, setmfact, {.f = -0.05} },
|
||||
- { MODKEY, XK_l, setmfact, {.f = +0.05} },
|
||||
- { MODKEY, XK_Return, zoom, {0} },
|
||||
- { MODKEY, XK_Tab, view, {0} },
|
||||
- { MODKEY|ShiftMask, XK_c, killclient, {0} },
|
||||
- { MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
||||
- { MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
||||
- { MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
||||
- { MODKEY, XK_space, setlayout, {0} },
|
||||
- { MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
||||
- { MODKEY, XK_0, view, {.ui = ~0 } },
|
||||
- { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
|
||||
- { MODKEY, XK_comma, focusmon, {.i = -1 } },
|
||||
- { MODKEY, XK_period, focusmon, {.i = +1 } },
|
||||
- { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
|
||||
- { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
|
||||
+ /* type modifier key function argument */
|
||||
+ { KeyPress, MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
||||
+ { KeyPress, MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
|
||||
+ { KeyPress, MODKEY, XK_b, togglebar, {0} },
|
||||
+ { KeyPress, MODKEY, XK_j, focusstack, {.i = +1 } },
|
||||
+ { KeyPress, MODKEY, XK_k, focusstack, {.i = -1 } },
|
||||
+ { KeyPress, MODKEY, XK_i, incnmaster, {.i = +1 } },
|
||||
+ { KeyPress, MODKEY, XK_d, incnmaster, {.i = -1 } },
|
||||
+ { KeyPress, MODKEY, XK_h, setmfact, {.f = -0.05} },
|
||||
+ { KeyPress, MODKEY, XK_l, setmfact, {.f = +0.05} },
|
||||
+ { KeyPress, MODKEY, XK_Return, zoom, {0} },
|
||||
+ { KeyPress, MODKEY, XK_Tab, view, {0} },
|
||||
+ { KeyPress, MODKEY|ShiftMask, XK_c, killclient, {0} },
|
||||
+ { KeyPress, MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
||||
+ { KeyPress, MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
||||
+ { KeyPress, MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
||||
+ { KeyPress, MODKEY, XK_space, setlayout, {0} },
|
||||
+ { KeyPress, MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
||||
+ { KeyPress, MODKEY, XK_0, view, {.ui = ~0 } },
|
||||
+ { KeyPress, MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
|
||||
+ { KeyPress, MODKEY, XK_comma, focusmon, {.i = -1 } },
|
||||
+ { KeyPress, MODKEY, XK_period, focusmon, {.i = +1 } },
|
||||
+ { KeyPress, MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
|
||||
+ { KeyPress, MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
|
||||
TAGKEYS( XK_1, 0)
|
||||
TAGKEYS( XK_2, 1)
|
||||
TAGKEYS( XK_3, 2)
|
||||
@@ -93,7 +93,7 @@ static Key keys[] = {
|
||||
TAGKEYS( XK_7, 6)
|
||||
TAGKEYS( XK_8, 7)
|
||||
TAGKEYS( XK_9, 8)
|
||||
- { MODKEY|ShiftMask, XK_q, quit, {0} },
|
||||
+ { KeyPress, MODKEY|ShiftMask, XK_q, quit, {0} },
|
||||
};
|
||||
|
||||
/* button definitions */
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index 4465af1..9dcc53e 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -100,6 +100,7 @@ struct Client {
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
+ int type;
|
||||
unsigned int mod;
|
||||
KeySym keysym;
|
||||
void (*func)(const Arg *);
|
||||
@@ -253,6 +254,7 @@ static void (*handler[LASTEvent]) (XEvent *) = {
|
||||
[Expose] = expose,
|
||||
[FocusIn] = focusin,
|
||||
[KeyPress] = keypress,
|
||||
+ [KeyRelease] = keypress,
|
||||
[MappingNotify] = mappingnotify,
|
||||
[MapRequest] = maprequest,
|
||||
[MotionNotify] = motionnotify,
|
||||
@@ -993,6 +995,7 @@ keypress(XEvent *e)
|
||||
keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
|
||||
for (i = 0; i < LENGTH(keys); i++)
|
||||
if (keysym == keys[i].keysym
|
||||
+ && ev->type == keys[i].type
|
||||
&& CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)
|
||||
&& keys[i].func)
|
||||
keys[i].func(&(keys[i].arg));
|
||||
--
|
||||
2.19.1
|
||||
|
||||
|
||||
From cd0e2f74816acd0943a2fec865751290383b5987 Mon Sep 17 00:00:00 2001
|
||||
From: bakkeby <bakkeby@gmail.com>
|
||||
Date: Thu, 3 Jun 2021 12:04:33 +0200
|
||||
Subject: [PATCH 2/2] Holdbar patch on top of keypressrelease
|
||||
|
||||
---
|
||||
config.def.h | 4 +++-
|
||||
dwm.c | 22 +++++++++++++++++++++-
|
||||
2 files changed, 24 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 06a6eee..3729e3c 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -44,7 +44,7 @@ static const Layout layouts[] = {
|
||||
};
|
||||
|
||||
/* key definitions */
|
||||
-#define MODKEY Mod1Mask
|
||||
+#define MODKEY Mod4Mask
|
||||
#define TAGKEYS(KEY,TAG) \
|
||||
{ KeyPress, MODKEY, KEY, view, {.ui = 1 << TAG} }, \
|
||||
{ KeyPress, MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
|
||||
@@ -61,6 +61,8 @@ static const char *termcmd[] = { "st", NULL };
|
||||
|
||||
static Key keys[] = {
|
||||
/* type modifier key function argument */
|
||||
+ { KeyPress, 0, XK_Super_L,enablebar, {0} },
|
||||
+ { KeyRelease, MODKEY, XK_Super_L,disablebar, {0} },
|
||||
{ KeyPress, MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
||||
{ KeyPress, MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
|
||||
{ KeyPress, MODKEY, XK_b, togglebar, {0} },
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index 9dcc53e..d7ae4a2 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -162,8 +162,10 @@ static void destroynotify(XEvent *e);
|
||||
static void detach(Client *c);
|
||||
static void detachstack(Client *c);
|
||||
static Monitor *dirtomon(int dir);
|
||||
+static void disablebar(const Arg *arg);
|
||||
static void drawbar(Monitor *m);
|
||||
static void drawbars(void);
|
||||
+static void enablebar(const Arg *arg);
|
||||
static void enternotify(XEvent *e);
|
||||
static void expose(XEvent *e);
|
||||
static void focus(Client *c);
|
||||
@@ -694,6 +696,15 @@ dirtomon(int dir)
|
||||
return m;
|
||||
}
|
||||
|
||||
+void
|
||||
+disablebar(const Arg *arg)
|
||||
+{
|
||||
+ if (selmon->showbar == 2) {
|
||||
+ selmon->showbar = 1;
|
||||
+ togglebar(arg);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void
|
||||
drawbar(Monitor *m)
|
||||
{
|
||||
@@ -753,6 +764,15 @@ drawbars(void)
|
||||
drawbar(m);
|
||||
}
|
||||
|
||||
+void
|
||||
+enablebar(const Arg *arg)
|
||||
+{
|
||||
+ if (!selmon->showbar) {
|
||||
+ togglebar(arg);
|
||||
+ selmon->showbar = 2;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void
|
||||
enternotify(XEvent *e)
|
||||
{
|
||||
@@ -1702,7 +1722,7 @@ tile(Monitor *m)
|
||||
void
|
||||
togglebar(const Arg *arg)
|
||||
{
|
||||
- selmon->showbar = !selmon->showbar;
|
||||
+ selmon->showbar = (selmon->showbar == 2 ? 1 : !selmon->showbar);
|
||||
updatebarpos(selmon);
|
||||
XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
|
||||
arrange(selmon);
|
||||
--
|
||||
2.19.1
|
||||
|
Loading…
Reference in New Issue