1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
From 6c58b480b7b6ce6a28beafc60a096069fbd51532 Mon Sep 17 00:00:00 2001
From: LeelaPakanati <LeelaPakanati.gmail.com>
Date: Fri, 13 Dec 2019 16:56:42 -0500
Subject: [PATCH] Add function handling at keyrelease
---
config.def.h | 6 ++++++
tabbed.c | 30 +++++++++++++++++++++++++++++-
2 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/config.def.h b/config.def.h
index defa426..7bfda30 100644
--- a/config.def.h
+++ b/config.def.h
@@ -64,3 +64,9 @@ static Key keys[] = {
{ 0, XK_F11, fullscreen, { 0 } },
};
+
+static Key keyreleases[] = {
+ /* modifier key function argument */
+ { 0, XK_Shift_L, NULL, { 0 } },
+
+};
diff --git a/tabbed.c b/tabbed.c
index ff3ada0..fe38b9d 100644
--- a/tabbed.c
+++ b/tabbed.c
@@ -113,6 +113,7 @@ static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
static void initfont(const char *fontstr);
static Bool isprotodel(int c);
static void keypress(const XEvent *e);
+static void keyrelease(const XEvent *e);
static void killclient(const Arg *arg);
static void manage(Window win);
static void maprequest(const XEvent *e);
@@ -149,6 +150,7 @@ static void (*handler[LASTEvent]) (const XEvent *) = {
[Expose] = expose,
[FocusIn] = focusin,
[KeyPress] = keypress,
+ [KeyRelease] = keyrelease,
[MapRequest] = maprequest,
[PropertyNotify] = propertynotify,
};
@@ -664,6 +666,22 @@ keypress(const XEvent *e)
}
}
+void
+keyrelease(const XEvent *e)
+{
+ const XKeyEvent *ev = &e->xkey;
+ unsigned int i;
+ KeySym keysym;
+
+ keysym = XkbKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0, 0);
+ for (i = 0; i < LENGTH(keyreleases); i++) {
+ if (keysym == keyreleases[i].keysym &&
+ CLEANMASK(keyreleases[i].mod) == CLEANMASK(ev->state) &&
+ keyreleases[i].func)
+ keyreleases[i].func(&(keyreleases[i].arg));
+ }
+}
+
void
killclient(const Arg *arg)
{
@@ -714,6 +732,16 @@ manage(Window w)
}
}
+ for (i = 0; i < LENGTH(keyreleases); i++) {
+ if ((code = XKeysymToKeycode(dpy, keyreleases[i].keysym))) {
+ for (j = 0; j < LENGTH(modifiers); j++) {
+ XGrabKey(dpy, code, keyreleases[i].mod |
+ modifiers[j], w, True,
+ GrabModeAsync, GrabModeAsync);
+ }
+ }
+ }
+
c = ecalloc(1, sizeof *c);
c->win = w;
@@ -1036,7 +1064,7 @@ setup(void)
XMapRaised(dpy, win);
XSelectInput(dpy, win, SubstructureNotifyMask | FocusChangeMask |
ButtonPressMask | ExposureMask | KeyPressMask |
- PropertyChangeMask | StructureNotifyMask |
+ KeyReleaseMask | PropertyChangeMask | StructureNotifyMask |
SubstructureRedirectMask);
xerrorxlib = XSetErrorHandler(xerror);
--
2.24.0
|