summaryrefslogtreecommitdiffstats
path: root/dwm.c
diff options
context:
space:
mode:
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c64
1 files changed, 58 insertions, 6 deletions
diff --git a/dwm.c b/dwm.c
index a82e276..d6391f5 100644
--- a/dwm.c
+++ b/dwm.c
@@ -181,6 +181,7 @@ static void grabbuttons(Client *c, int focused);
static void grabkeys(void);
static void incnmaster(const Arg *arg);
static void keypress(XEvent *e);
+static void keyrelease(XEvent *e);
static void killclient(const Arg *arg);
static void manage(Window w, XWindowAttributes *wa);
static void mappingnotify(XEvent *e);
@@ -214,6 +215,7 @@ static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void tile(Monitor *m);
static void togglebar(const Arg *arg);
+static void holdbar(const Arg *arg);
static void togglefloating(const Arg *arg);
static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg);
@@ -221,6 +223,7 @@ static void unfocus(Client *c, int setfocus);
static void unmanage(Client *c, int destroyed);
static void unmapnotify(XEvent *e);
static void updatebarpos(Monitor *m);
+static void updateholdbarpos(Monitor *m);
static void updatebars(void);
static void updateclientlist(void);
static int updategeom(void);
@@ -250,6 +253,7 @@ static int (*xerrorxlib)(Display *, XErrorEvent *);
static unsigned int numlockmask = 0;
static void (*handler[LASTEvent]) (XEvent *) = {
[ButtonPress] = buttonpress,
+ [ButtonRelease] = keyrelease,
[ClientMessage] = clientmessage,
[ConfigureRequest] = configurerequest,
[ConfigureNotify] = configurenotify,
@@ -257,6 +261,7 @@ static void (*handler[LASTEvent]) (XEvent *) = {
[EnterNotify] = enternotify,
[Expose] = expose,
[FocusIn] = focusin,
+ [KeyRelease] = keyrelease,
[KeyPress] = keypress,
[MappingNotify] = mappingnotify,
[MapRequest] = maprequest,
@@ -286,6 +291,54 @@ struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
/* function implementations */
void
+holdbar(const Arg *arg)
+{
+ if (selmon->showbar)
+ return;
+ selmon->showbar = 2;
+ updateholdbarpos(selmon);
+ XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
+}
+
+void
+keyrelease(XEvent *e)
+{
+ if (XEventsQueued(dpy, QueuedAfterReading)) {
+ XEvent ne;
+ XPeekEvent(dpy, &ne);
+
+ if (ne.type == KeyPress && ne.xkey.time == e->xkey.time &&
+ ne.xkey.keycode == e->xkey.keycode) {
+ XNextEvent(dpy, &ne);
+ return;
+ }
+ }
+ if (e->xkey.keycode == XKeysymToKeycode(dpy, HOLDKEY)) {
+ for (Monitor *m = mons; m; m = m->next) {
+ if (m->showbar == 2) {
+ m->showbar = 0;
+ updateholdbarpos(m);
+ XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh);
+ arrange(m);
+ }
+ }
+ }
+}
+
+void
+updateholdbarpos(Monitor *m)
+{
+ m->wy = m->my;
+ m->wh = m->mh;
+ if (m->showbar) {
+ m->by = m->topbar ? m->wy : m->wy + m->wh - bh;
+ m->wy = m->topbar ? m->wy - bh + bh : m->wy;
+ } else {
+ m->by = -bh;
+ }
+}
+
+void
applyrules(Client *c)
{
const char *class, *instance;
@@ -469,7 +522,8 @@ buttonpress(XEvent *e)
}
for (i = 0; i < LENGTH(buttons); i++)
if (click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button
- && CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state))
+ && (CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state)
+ || CLEANMASK(((buttons[i].mask & ~MODKEY) | HOLDMOD)) == CLEANMASK(ev->state)))
buttons[i].func(click == ClkTagBar && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg);
}
@@ -720,9 +774,6 @@ drawbar(Monitor *m)
unsigned int i, occ = 0, urg = 0;
Client *c;
- if (!m->showbar)
- return;
-
/* clear bar from last draw */
drw_setscheme(drw, scheme[SchemeNorm]);
drw_rect(drw, 0, 0, m->ww, bh, lrpad / 2, 1);
@@ -1031,7 +1082,8 @@ keypress(XEvent *e)
keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
for (i = 0; i < LENGTH(keys); i++)
if (keysym == keys[i].keysym
- && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)
+ && (CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)
+ || CLEANMASK(((keys[i].mod & ~MODKEY) | HOLDMOD)) == CLEANMASK(ev->state))
&& keys[i].func)
keys[i].func(&(keys[i].arg));
}
@@ -1740,7 +1792,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);