From 18b655f5e908b7a57709b9dec9f00428ed339839 Mon Sep 17 00:00:00 2001 From: Francois Fleuret Date: Fri, 26 Aug 2016 08:20:26 +0200 Subject: [PATCH] Update. --- simple_window.cc | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/simple_window.cc b/simple_window.cc index 7fee9c2..2864168 100644 --- a/simple_window.cc +++ b/simple_window.cc @@ -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; -- 2.39.5