aboutsummaryrefslogtreecommitdiffstats
path: root/drv_X11.c
diff options
context:
space:
mode:
authormzuther <mzuther@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2010-07-11 11:17:41 +0000
committermzuther <mzuther@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2010-07-11 11:17:41 +0000
commit6826450c8312ab13b52f13728dd4f6433e8f79fb (patch)
tree9737b774e39e1070a63d80b69778229bad581296 /drv_X11.c
parent204a50d00f7498e73ee625d9703e1720cd9738cd (diff)
downloadlcd4linux-6826450c8312ab13b52f13728dd4f6433e8f79fb.tar.gz
X11 driver: possibility to ignore auto-repeated KeyPress events
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@1125 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
Diffstat (limited to 'drv_X11.c')
-rw-r--r--drv_X11.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/drv_X11.c b/drv_X11.c
index b3f627e..cc54241 100644
--- a/drv_X11.c
+++ b/drv_X11.c
@@ -94,6 +94,8 @@ static GC gc;
static Colormap cm;
static Pixmap pm;
+static int allow_autorepeat = 1; /* consider auto-repeated KeyPress events? */
+
static char myDisplayName[256] = "";
static int opTableEntries = 2;
static XrmOptionDescRec opTable[] = {
@@ -363,6 +365,9 @@ static void drv_X11_timer( __attribute__ ((unused))
&& XCheckTypedWindowEvent(dp, w, ClientMessage, &ev) == 0)
return;
+ /* check whether key has been retriggered by "auto repeat" */
+ unsigned short is_retriggered = 0;
+
switch (ev.type) {
case Expose:
@@ -429,6 +434,19 @@ static void drv_X11_timer( __attribute__ ((unused))
break;
case KeyRelease:
+ /* check whether key has been retriggered by "auto repeat" */
+ if (!allow_autorepeat && XEventsQueued(dp, QueuedAfterReading)) {
+ XEvent nev;
+ XPeekEvent(dp, &nev);
+
+ if (nev.type == KeyPress && nev.xkey.time == ev.xkey.time && nev.xkey.keycode == ev.xkey.keycode) {
+ is_retriggered = 1;
+
+ /* delete retriggered KeyPress event */
+ XNextEvent(dp, &ev);
+ }
+ }
+
key = XLookupKeysym(&ev.xkey, 0);
switch (key) {
case XK_Up:
@@ -451,7 +469,7 @@ static void drv_X11_timer( __attribute__ ((unused))
break;
}
/* only register key release if button is defined on GUI */
- if (btn > 0) {
+ if (!is_retriggered && (btn > 0)) {
if (btn <= buttons) {
debug("key for button %i released", btn);
XClearArea(dp, w, xoffset, yoffset + (btn - 1) * (btnheight + pgap), btnwidth, btnheight - 2,
@@ -572,6 +590,9 @@ static int drv_X11_start(const char *section)
free(s);
}
+ /* consider auto-repeated KeyPress events? */
+ cfg_number(section, "autorepeat", 1, 0, 1, &allow_autorepeat);
+
/* virtual keyboard: number of buttons (0..6) */
if (cfg_number(section, "buttons", 0, 0, 6, &buttons) < 0)
return -1;