aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/native
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-09-16 21:13:51 +0200
committerSven Gothel <[email protected]>2012-09-16 21:13:51 +0200
commit646714d3dab87396b9a3119bf90ca26e0b1c97ce (patch)
tree678209f657c5f3bfa29e54c171565488a15f9951 /src/newt/native
parentf2bd50ff25009de477a203460abe8a5597acdbc5 (diff)
Fix Bug 601: Harmonize order of key events incl. auto-repeat and adding AUTOREPEAT_MASK modifier bit. Refine InputEvent toString(..) and list modifiers by name.
As now described in NEWT's KeyEvent: +/** + * Key events are delivered in the following order: + * <ol> + * <li>{@link #EVENT_KEY_PRESSED}</li> + * <li>{@link #EVENT_KEY_RELEASED}</li> + * <li>{@link #EVENT_KEY_TYPED}</li> + * </ol> + * In case the native platform does not + * deliver keyboard events in the above order or skip events, + * the NEWT driver will reorder and inject synthetic events if required. + * <p> + * Besides regular modifiers like {@link InputEvent##SHIFT_MASK} etc., + * the {@link InputEvent#AUTOREPEAT_MASK} bit is added if repetition is detected. + * </p> + */
Diffstat (limited to 'src/newt/native')
-rw-r--r--src/newt/native/InputEvent.h22
-rw-r--r--src/newt/native/X11Display.c18
2 files changed, 30 insertions, 10 deletions
diff --git a/src/newt/native/InputEvent.h b/src/newt/native/InputEvent.h
index b42c06d21..51c56c474 100644
--- a/src/newt/native/InputEvent.h
+++ b/src/newt/native/InputEvent.h
@@ -34,13 +34,19 @@
#ifndef _INPUT_EVENT_H_
#define _INPUT_EVENT_H_
-#define EVENT_SHIFT_MASK 1
-#define EVENT_CTRL_MASK 2
-#define EVENT_META_MASK 4
-#define EVENT_ALT_MASK 8
-#define EVENT_ALT_GRAPH_MASK 32
-#define EVENT_BUTTON1_MASK (1<<6)
-#define EVENT_BUTTON2_MASK (1<<7)
-#define EVENT_BUTTON3_MASK (1<<8)
+#define EVENT_SHIFT_MASK (1 << 0)
+#define EVENT_CTRL_MASK (1 << 1)
+#define EVENT_META_MASK (1 << 2)
+#define EVENT_ALT_MASK (1 << 3)
+#define EVENT_ALT_GRAPH_MASK (1 << 5)
+#define EVENT_BUTTON1_MASK (1 << 6)
+#define EVENT_BUTTON2_MASK (1 << 7)
+#define EVENT_BUTTON3_MASK (1 << 8)
+#define EVENT_BUTTON4_MASK (1 << 9)
+#define EVENT_BUTTON5_MASK (1 << 10)
+#define EVENT_BUTTON6_MASK (1 << 11)
+#define EVENT_AUTOREPEAT_MASK (1 << 15)
+#define EVENT_CONFINED_MASK (1 << 16)
+#define EVENT_INVISIBLE_MASK (1 << 17)
#endif
diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c
index 3157538c3..84b3a7630 100644
--- a/src/newt/native/X11Display.c
+++ b/src/newt/native/X11Display.c
@@ -400,6 +400,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage
Display * dpy = (Display *) (intptr_t) display;
Atom wm_delete_atom = (Atom)windowDeleteAtom;
int num_events = 100;
+ int autoRepeatModifiers = 0;
if ( NULL == dpy ) {
return;
@@ -458,6 +459,19 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage
switch(evt.type) {
case KeyRelease:
+ if (XEventsQueued(dpy, QueuedAfterReading)) {
+ XEvent nevt;
+ XPeekEvent(dpy, &nevt);
+
+ if (nevt.type == KeyPress && nevt.xkey.time == evt.xkey.time &&
+ nevt.xkey.keycode == evt.xkey.keycode)
+ {
+ autoRepeatModifiers |= EVENT_AUTOREPEAT_MASK;
+ } else {
+ autoRepeatModifiers &= ~EVENT_AUTOREPEAT_MASK;
+ }
+ }
+ // fall through intended
case KeyPress:
if(XLookupString(&evt.xkey,text,255,&keySym,0)==1) {
KeySym lower_return = 0, upper_return = 0;
@@ -469,13 +483,13 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage
keyChar=0;
keySym = X11KeySym2NewtVKey(keySym);
}
- modifiers = X11InputState2NewtModifiers(evt.xkey.state);
+ modifiers |= X11InputState2NewtModifiers(evt.xkey.state) | autoRepeatModifiers;
break;
case ButtonPress:
case ButtonRelease:
case MotionNotify:
- modifiers = X11InputState2NewtModifiers(evt.xbutton.state);
+ modifiers |= X11InputState2NewtModifiers(evt.xbutton.state);
break;
default: