summaryrefslogtreecommitdiff
blob: b3d1ab10b2d85c7417bfe05780e0a7f46a5219a9 (plain)
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
https://bugs.gentoo.org/show_bug.cgi?id=261359
http://developer.berlios.de/bugs/?func=detailbug&bug_id=15326&group_id=2663

diff --git a/panel.cpp b/panel.cpp
index 032574d..075c008 100644
--- a/panel.cpp
+++ b/panel.cpp
@@ -10,6 +10,7 @@
 */
 
 #include <sstream>
+#include <poll.h>
 #include "panel.h"
 
 using namespace std;
@@ -288,16 +289,24 @@ void Panel::EventHandler(const Panel::FieldType& curfield) {
     field=curfield;
     bool loop = true;
     OnExpose();
+
+    struct pollfd x11_pfd = {0};
+    x11_pfd.fd = ConnectionNumber(Dpy);
+    x11_pfd.events = POLLIN;
     while(loop) {
-        XNextEvent(Dpy, &event);
-        switch(event.type) {
-            case Expose:
-                OnExpose();
-                break;
+        if(XPending(Dpy) || poll(&x11_pfd, 1, -1) > 0) {
+            while(XPending(Dpy)) {
+                XNextEvent(Dpy, &event);
+                switch(event.type) {
+                    case Expose:
+                        OnExpose();
+                        break;
 
-            case KeyPress:
-                loop=OnKeyPress(event);
-                break;
+                    case KeyPress:
+                        loop=OnKeyPress(event);
+                        break;
+                }
+            }
         }
     }