Browse Source

Fix responding to TERM signals (#15326)

Applied patch #3050.

Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>

git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/slim/trunk@191 7c53e7cc-98ea-0310-8f1f-a0b24da60408
iwamatsu 12 years ago
parent
commit
3598564a95
1 changed files with 17 additions and 8 deletions
  1. 17 8
      panel.cpp

+ 17 - 8
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;
+                }
+            }
         }
     }