aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBert Münnich <be.muennich@googlemail.com>2012-08-17 16:54:29 +0200
committerBert Münnich <be.muennich@googlemail.com>2012-08-17 16:54:29 +0200
commitfd519ffc40bdd13d8b418b6f95cf28ae6a167d7d (patch)
tree49b470a0f834fdec6922392c7f5c3445da2ade7f
parentc78f55ebb43f5d73033a4709dfd32830a016a7cb (diff)
Disregard obsolete events, fixed issue #64
-rw-r--r--Makefile2
-rw-r--r--main.c14
2 files changed, 12 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 9a8a3ed..23826fb 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-VERSION = git-20120816
+VERSION = git-20120817
PREFIX = /usr/local
MANPREFIX = $(PREFIX)/share/man
diff --git a/main.c b/main.c
index 5f8a0ca..f6d09f5 100644
--- a/main.c
+++ b/main.c
@@ -419,7 +419,8 @@ void run(void) {
int xfd;
fd_set fds;
struct timeval timeout;
- XEvent ev;
+ XEvent ev, nextev;
+ unsigned int qlen;
redraw();
@@ -450,7 +451,13 @@ void run(void) {
select(xfd + 1, &fds, 0, 0, &timeout);
}
- XNextEvent(win.env.dpy, &ev);
+ do {
+ XNextEvent(win.env.dpy, &ev);
+ qlen = XEventsQueued(win.env.dpy, QueuedAlready);
+ if (qlen > 0)
+ XPeekEvent(win.env.dpy, &nextev);
+ } while (qlen > 0 && ev.type == nextev.type);
+
switch (ev.type) {
/* handle events */
case ButtonPress:
@@ -476,7 +483,8 @@ void run(void) {
}
break;
case KeyPress:
- on_keypress(&ev.xkey);
+ if (qlen == 0 || ev.xkey.keycode != nextev.xkey.keycode)
+ on_keypress(&ev.xkey);
break;
case MotionNotify:
if (mode == MODE_IMAGE) {