-////////////////////////////////////////////////////////////////////////////////
-// This program is free software; you can redistribute it and/or //
-// modify it under the terms of the GNU General Public License //
-// version 2 as published by the Free Software Foundation. //
-// //
-// This program is distributed in the hope that it will be useful, but //
-// WITHOUT ANY WARRANTY; without even the implied warranty of //
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU //
-// General Public License for more details. //
-// //
-// Written and (C) by François Fleuret //
-// Contact <francois.fleuret@epfl.ch> for comments & bug reports //
-////////////////////////////////////////////////////////////////////////////////
+// Written and (C) by Francois Fleuret
+// Contact <francois.fleuret@idiap.ch> for comments & bug reports
+
+#include <string.h>
+#include <stdlib.h>
#include "simple_window.h"
SimpleEvent::SimpleEvent() : type(UNDEFINED) {}
-SimpleWindow::SimpleWindow(char *name, int x, int y, int w, int h) {
+SimpleWindow::SimpleWindow(const char *name, int x, int y, int w, int h) {
_width = w; _height = h;
XDrawArc(_display, _pixmap, _gc, x-r, y-r, 2*r, 2*r, 0, 360*64);
}
-void SimpleWindow::draw_text(char *s, int x, int y) {
+void SimpleWindow::draw_text(const char *s, int x, int y) {
XDrawString(_display, _pixmap, _gc, x, y, s, strlen(s));
}
break;
case KeyPress:
+ KeySym mykey;
+ mykey = XkbKeycodeToKeysym(_display,
+ event.xkey.keycode, 0,
+ event.xkey.state & ShiftMask ? 1 : 0);
+
se.type = SimpleEvent::KEY_PRESS;
- strncpy(se.key,
- XKeysymToString(XKeycodeToKeysym(_display, event.xkey.keycode, 0)),
- (sizeof(se.key)/sizeof(char) - 1));
+ strncpy(se.key, XKeysymToString(mykey), (sizeof(se.key)/sizeof(char) - 1));
+
break;
case KeyRelease:
+ KeySym mykey;
+ mykey = XkbKeycodeToKeysym(_display,
+ event.xkey.keycode, 0,
+ event.xkey.state & ShiftMask ? 1 : 0);
+
se.type = SimpleEvent::KEY_RELEASE;
- strncpy(se.key,
- XKeysymToString(XKeycodeToKeysym(_display, event.xkey.keycode, 0)),
- (sizeof(se.key)/sizeof(char) - 1));
+ strncpy(se.key, XKeysymToString(mykey), (sizeof(se.key)/sizeof(char) - 1));
break;
default: