blob: fbaeb7116c10b48ccf972419ebee4fb8bbbe9c3c (
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
|
diff -aur old/panel.cpp new/panel.cpp
--- old/panel.cpp 2011-04-29 15:15:57.210134850 +0200
+++ new/panel.cpp 2011-04-29 15:16:17.260285407 +0200
@@ -10,6 +10,7 @@
*/
#include <sstream>
+#include <poll.h>
#include "panel.h"
using namespace std;
@@ -288,16 +289,24 @@
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;
-
- case KeyPress:
- loop=OnKeyPress(event);
- 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;
+ }
+ }
}
}
|