Update.
authorFrancois Fleuret <francois@fleuret.org>
Fri, 26 Aug 2016 06:20:26 +0000 (08:20 +0200)
committerFrancois Fleuret <francois@fleuret.org>
Fri, 26 Aug 2016 06:20:26 +0000 (08:20 +0200)
simple_window.cc

index 7fee9c2..2864168 100644 (file)
@@ -156,6 +156,7 @@ int  SimpleWindow::file_descriptor() {
 
 SimpleEvent SimpleWindow::event() {
   SimpleEvent se;
+  KeySym mykey;
 
   if(XPending(_display) > 0) {
 
@@ -186,29 +187,25 @@ SimpleEvent SimpleWindow::event() {
       break;
 
     case KeyPress:
-      KeySym mykey;
+      se.type = SimpleEvent::KEY_PRESS;
       mykey = XkbKeycodeToKeysym(_display,
                                  event.xkey.keycode, 0,
                                  event.xkey.state & ShiftMask ? 1 : 0);
-
-      se.type = SimpleEvent::KEY_PRESS;
       strncpy(se.key, XKeysymToString(mykey), (sizeof(se.key)/sizeof(char) - 1));
-
       break;
 
     case KeyRelease:
-      KeySym mykey;
+      se.type = SimpleEvent::KEY_RELEASE;
       mykey = XkbKeycodeToKeysym(_display,
                                  event.xkey.keycode, 0,
                                  event.xkey.state & ShiftMask ? 1 : 0);
-
-      se.type = SimpleEvent::KEY_RELEASE;
       strncpy(se.key, XKeysymToString(mykey), (sizeof(se.key)/sizeof(char) - 1));
       break;
 
     default:
       se.type = SimpleEvent::UNDEFINED;
       break;
+
     }
   } else se.type = SimpleEvent::NO_EVENT;
   return se;