summaryrefslogtreecommitdiffstats
path: root/src/newt
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-06-17 09:01:23 +0200
committerSven Gothel <[email protected]>2013-06-17 09:01:23 +0200
commit8b33170ec6fd3f215976875cb66d746fa1b48f61 (patch)
tree3e5c72feb9ed33fc1b81a073f92adb43f21836ce /src/newt
parentc24f44036971bf58b5c47a6e1f7d9f186c67e789 (diff)
Fix Bug 688: Removal of NEWT KeyEvent.EVENT_KEY_TYPED and KeyListener.keyTyped(KeyEvent)
Diffstat (limited to 'src/newt')
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java11
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java7
-rw-r--r--src/newt/classes/com/jogamp/newt/event/KeyAdapter.java2
-rw-r--r--src/newt/classes/com/jogamp/newt/event/KeyEvent.java6
-rw-r--r--src/newt/classes/com/jogamp/newt/event/KeyListener.java18
-rw-r--r--src/newt/classes/com/jogamp/newt/event/TraceKeyAdapter.java4
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java34
-rw-r--r--src/newt/native/KeyEvent.h1
-rw-r--r--src/newt/native/X11Event.c6
-rw-r--r--src/newt/native/X11Window.c1
-rw-r--r--src/newt/native/XCBEvent.c6
11 files changed, 19 insertions, 77 deletions
diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
index 32a92ec8b..692741a88 100644
--- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
+++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
@@ -201,8 +201,6 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
};
class FocusTraversalKeyListener implements KeyListener {
- boolean suppress = false;
-
public void keyPressed(KeyEvent e) {
if( isParent() && !isFullscreen() ) {
handleKey(e, false);
@@ -213,21 +211,16 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
handleKey(e, true);
}
}
- public void keyTyped(KeyEvent e) {
- if(suppress) {
- e.setConsumed(true);
- suppress = false; // reset
- }
- }
void handleKey(KeyEvent evt, boolean onRelease) {
if(null == keyboardFocusManager) {
throw new InternalError("XXX");
}
final AWTKeyStroke ks = AWTKeyStroke.getAWTKeyStroke(evt.getKeyCode(), evt.getModifiers(), onRelease);
+ boolean suppress = false;
if(null != ks) {
final Set<AWTKeyStroke> fwdKeys = keyboardFocusManager.getDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
- final Set<AWTKeyStroke> bwdKeys = keyboardFocusManager.getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);
+ final Set<AWTKeyStroke> bwdKeys = keyboardFocusManager.getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);
if(fwdKeys.contains(ks)) {
if(DEBUG) {
System.err.println("NewtCanvasAWT.focusKey (fwd): "+ks+", current focusOwner "+keyboardFocusManager.getFocusOwner());
diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java
index 091a1a5cf..35199dc82 100644
--- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java
+++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java
@@ -288,9 +288,10 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener {
public void keyPressed(KeyEvent e) {
}
- public void keyReleased(KeyEvent e) {
- }
- public void keyTyped(KeyEvent e) {
+ public void keyReleased(KeyEvent e) {
+ if( !e.isPrintableKey() || e.isAutoRepeat() ) {
+ return;
+ }
if(e.getKeyChar()=='d') {
glWindow.setUndecorated(!glWindow.isUndecorated());
} if(e.getKeyChar()=='f') {
diff --git a/src/newt/classes/com/jogamp/newt/event/KeyAdapter.java b/src/newt/classes/com/jogamp/newt/event/KeyAdapter.java
index 93c8409b1..42ebea722 100644
--- a/src/newt/classes/com/jogamp/newt/event/KeyAdapter.java
+++ b/src/newt/classes/com/jogamp/newt/event/KeyAdapter.java
@@ -35,7 +35,5 @@ public abstract class KeyAdapter implements KeyListener
}
public void keyReleased(KeyEvent e) {
}
- public void keyTyped(KeyEvent e) {
- }
}
diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java
index 6e63ad3a3..683a5ca54 100644
--- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java
+++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java
@@ -217,7 +217,6 @@ public class KeyEvent extends InputEvent
switch(type) {
case EVENT_KEY_PRESSED: return "EVENT_KEY_PRESSED";
case EVENT_KEY_RELEASED: return "EVENT_KEY_RELEASED";
- case EVENT_KEY_TYPED: return "EVENT_KEY_TYPED";
default: return "unknown (" + type + ")";
}
}
@@ -365,11 +364,6 @@ public class KeyEvent extends InputEvent
public static final short EVENT_KEY_PRESSED = 300;
/** A key has been released, excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys. */
public static final short EVENT_KEY_RELEASED= 301;
- /**
- * A {@link #isPrintableKey() printable} key has been typed (pressed and released), excluding {@link #isAutoRepeat() auto-repeat}.
- * @deprecated Redundant, will be removed soon. Use {@link #EVENT_KEY_RELEASED} and exclude non {@link #isPrintableKey() printable} keys and {@link #isAutoRepeat() auto-repeat}.
- */
- public static final short EVENT_KEY_TYPED = 302;
/**
* This value, {@code '\0'}, is used to indicate that the keyChar is unknown or not printable.
diff --git a/src/newt/classes/com/jogamp/newt/event/KeyListener.java b/src/newt/classes/com/jogamp/newt/event/KeyListener.java
index 5bca733d3..b3927d81a 100644
--- a/src/newt/classes/com/jogamp/newt/event/KeyListener.java
+++ b/src/newt/classes/com/jogamp/newt/event/KeyListener.java
@@ -43,13 +43,19 @@ public interface KeyListener extends NEWTEventListener
{
/** A key has been {@link KeyEvent#EVENT_KEY_PRESSED pressed}, excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys. See {@link KeyEvent}. */
public void keyPressed(KeyEvent e);
- /** A key has been {@link KeyEvent#EVENT_KEY_RELEASED released}, excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys. See {@link KeyEvent}. */
- public void keyReleased(KeyEvent e);
/**
- * A {@link #isPrintableKey() printable} key has been {@link KeyEvent#EVENT_KEY_TYPED typed} (pressed and released), excluding {@link #isAutoRepeat() auto-repeat}. See {@link KeyEvent}.
- * @deprecated Redundant, will be removed soon. Use {@link #keyReleased(KeyEvent)} and exclude non {@link #isPrintableKey() printable} keys and {@link #isAutoRepeat() auto-repeat}.
- */
- public void keyTyped(KeyEvent e) ;
+ * A key has been {@link KeyEvent#EVENT_KEY_RELEASED released}, excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys. See {@link KeyEvent}.
+ * <p>
+ * To simulated the removed <code>keyTyped(KeyEvent e)</code> semantics,
+ * simply apply the following constraints upfront and bail out if not matched, i.e.:
+ * <pre>
+ if( !e.isPrintableKey() || e.isAutoRepeat() ) {
+ return;
+ }
+ * </pre>
+ * </p>
+ */
+ public void keyReleased(KeyEvent e);
}
diff --git a/src/newt/classes/com/jogamp/newt/event/TraceKeyAdapter.java b/src/newt/classes/com/jogamp/newt/event/TraceKeyAdapter.java
index 98ba5a24d..629dc50d7 100644
--- a/src/newt/classes/com/jogamp/newt/event/TraceKeyAdapter.java
+++ b/src/newt/classes/com/jogamp/newt/event/TraceKeyAdapter.java
@@ -48,9 +48,5 @@ public class TraceKeyAdapter implements KeyListener {
System.err.println(e);
if(null!=downstream) { downstream.keyReleased(e); }
}
- public void keyTyped(KeyEvent e) {
- System.err.println(e);
- if(null!=downstream) { downstream.keyTyped(e); }
- }
}
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index 805ad08ad..dca287c6b 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -2476,7 +2476,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
return keyListeners.toArray(new KeyListener[keyListeners.size()]);
}
- @SuppressWarnings("deprecation")
private final boolean propagateKeyEvent(KeyEvent e, KeyListener l) {
switch(e.getEventType()) {
case KeyEvent.EVENT_KEY_PRESSED:
@@ -2485,40 +2484,19 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
case KeyEvent.EVENT_KEY_RELEASED:
l.keyReleased(e);
break;
- case KeyEvent.EVENT_KEY_TYPED:
- l.keyTyped(e);
- break;
default:
throw new NativeWindowException("Unexpected key event type " + e.getEventType());
}
return e.isConsumed();
}
- @SuppressWarnings("deprecation")
protected void consumeKeyEvent(KeyEvent e) {
- boolean consumedE = false, consumedTyped = false;
- if( KeyEvent.EVENT_KEY_TYPED == e.getEventType() ) {
- throw new InternalError("Deprecated KeyEvent.EVENT_KEY_TYPED is synthesized - don't send/enqueue it!");
- }
-
- // Synthesize deprecated event KeyEvent.EVENT_KEY_TYPED
- final KeyEvent eTyped;
- if( KeyEvent.EVENT_KEY_RELEASED == e.getEventType() && e.isPrintableKey() && !e.isAutoRepeat() ) {
- eTyped = KeyEvent.create(KeyEvent.EVENT_KEY_TYPED, e.getSource(), e.getWhen(), e.getModifiers(), e.getKeyCode(), e.getKeySymbol(), e.getKeyChar());
- } else {
- eTyped = null;
- }
+ boolean consumedE = false;
if(null != keyboardFocusHandler) {
consumedE = propagateKeyEvent(e, keyboardFocusHandler);
if(DEBUG_KEY_EVENT) {
System.err.println("consumeKeyEvent: "+e+", keyboardFocusHandler consumed: "+consumedE);
}
- if( null != eTyped ) {
- consumedTyped = propagateKeyEvent(eTyped, keyboardFocusHandler);
- if(DEBUG_KEY_EVENT) {
- System.err.println("consumeKeyEvent: "+eTyped+", keyboardFocusHandler consumed: "+consumedTyped);
- }
- }
}
if(DEBUG_KEY_EVENT) {
if( !consumedE ) {
@@ -2528,16 +2506,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
for(int i = 0; !consumedE && i < keyListeners.size(); i++ ) {
consumedE = propagateKeyEvent(e, keyListeners.get(i));
}
- if( null != eTyped ) {
- if(DEBUG_KEY_EVENT) {
- if( !consumedTyped ) {
- System.err.println("consumeKeyEvent: "+eTyped);
- }
- }
- for(int i = 0; !consumedTyped && i < keyListeners.size(); i++ ) {
- consumedTyped = propagateKeyEvent(eTyped, keyListeners.get(i));
- }
- }
}
//
diff --git a/src/newt/native/KeyEvent.h b/src/newt/native/KeyEvent.h
index a182db973..59977d565 100644
--- a/src/newt/native/KeyEvent.h
+++ b/src/newt/native/KeyEvent.h
@@ -31,7 +31,6 @@
#define EVENT_KEY_PRESSED 300
#define EVENT_KEY_RELEASED 301
-#define EVENT_KEY_TYPED 302
#define J_VK_UNDEFINED ( 0x0U )
#define J_VK_HOME ( 0x02U )
diff --git a/src/newt/native/X11Event.c b/src/newt/native/X11Event.c
index 770f60e8f..32a55c67c 100644
--- a/src/newt/native/X11Event.c
+++ b/src/newt/native/X11Event.c
@@ -170,15 +170,9 @@ void X11EventPoll(JNIEnv *env, jobject obj, Display *dpy, jlong javaObjectAtom,
#ifdef USE_SENDIO_DIRECT
(*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_RELEASED,
modifiers, keySym, (jchar) -1);
-
- (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_TYPED,
- modifiers, keySym, (jchar) keyChar);
#else
(*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, JNI_FALSE, (jint) EVENT_KEY_RELEASED,
modifiers, keySym, (jchar) -1);
-
- (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, JNI_FALSE, (jint) EVENT_KEY_TYPED,
- modifiers, keySym, (jchar) keyChar);
#endif
break;
diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c
index e567781cf..3f50f27a4 100644
--- a/src/newt/native/X11Window.c
+++ b/src/newt/native/X11Window.c
@@ -699,7 +699,6 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CloseWindow0
XGetWindowAttributes(dpy, w, &xwa); // prefetch colormap to be destroyed after window destruction
XSelectInput(dpy, w, 0);
XUnmapWindow(dpy, w);
- XSync(dpy, False);
// Drain all events related to this window ..
Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessages0(env, obj, display, javaObjectAtom, windowDeleteAtom /*, kbdHandle */); // XKB disabled for now
diff --git a/src/newt/native/XCBEvent.c b/src/newt/native/XCBEvent.c
index f067f4b7a..d02d5a4ba 100644
--- a/src/newt/native/XCBEvent.c
+++ b/src/newt/native/XCBEvent.c
@@ -176,15 +176,9 @@ void XCBEventPoll(JNIEnv *env, jobject obj, Display *dpy, jlong javaObjectAtom,
#ifdef USE_SENDIO_DIRECT
(*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_RELEASED,
modifiers, X11KeySym2NewtVKey(_evt->state), (jchar) keyChar);
-
- (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_TYPED,
- modifiers, (jint) -1, (jchar) keyChar);
#else
(*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, JNI_FALSE, (jint) EVENT_KEY_RELEASED,
modifiers, X11KeySym2NewtVKey(_evt->state), (jchar) keyChar);
-
- (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, JNI_FALSE, (jint) EVENT_KEY_TYPED,
- modifiers, (jint) -1, (jchar) keyChar);
#endif
} break;