diff options
author | mzuther <mzuther@3ae390bd-cb1e-0410-b409-cd5a39f66f1f> | 2010-07-11 11:17:41 +0000 |
---|---|---|
committer | mzuther <mzuther@3ae390bd-cb1e-0410-b409-cd5a39f66f1f> | 2010-07-11 11:17:41 +0000 |
commit | 6826450c8312ab13b52f13728dd4f6433e8f79fb (patch) | |
tree | 9737b774e39e1070a63d80b69778229bad581296 | |
parent | 204a50d00f7498e73ee625d9703e1720cd9738cd (diff) | |
download | lcd4linux-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
-rw-r--r-- | drv_X11.c | 23 |
1 files changed, 22 insertions, 1 deletions
@@ -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; |