aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt
diff options
context:
space:
mode:
Diffstat (limited to 'src/newt')
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java22
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java37
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java20
-rw-r--r--src/newt/classes/com/jogamp/newt/event/KeyAdapter.java2
-rw-r--r--src/newt/classes/com/jogamp/newt/event/KeyEvent.java91
-rw-r--r--src/newt/classes/com/jogamp/newt/event/KeyListener.java18
-rw-r--r--src/newt/classes/com/jogamp/newt/event/MouseEvent.java22
-rw-r--r--src/newt/classes/com/jogamp/newt/event/TraceKeyAdapter.java4
-rw-r--r--src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java7
-rw-r--r--src/newt/classes/jogamp/newt/Debug.java25
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java74
-rw-r--r--src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java16
-rw-r--r--src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java4
-rw-r--r--src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java4
-rw-r--r--src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java24
-rw-r--r--src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java12
-rw-r--r--src/newt/native/KeyEvent.h21
-rw-r--r--src/newt/native/WindowsWindow.c42
-rw-r--r--src/newt/native/X11Display.c24
-rw-r--r--src/newt/native/X11Event.c6
-rw-r--r--src/newt/native/X11Window.c6
-rw-r--r--src/newt/native/XCBEvent.c6
22 files changed, 231 insertions, 256 deletions
diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
index d0a4b7e98..65b44b141 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());
@@ -355,8 +348,8 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
// after native peer is valid: Windows
disableBackgroundErase();
-
- jawtWindow = NewtFactoryAWT.getNativeWindow(this, newtChild.getRequestedCapabilities());
+
+ jawtWindow = NewtFactoryAWT.getNativeWindow(this, null != newtChild ? newtChild.getRequestedCapabilities() : null);
jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer);
if(DEBUG) {
@@ -540,6 +533,9 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
newtChildCloseOp = newtChild.setDefaultCloseOperation(WindowClosingMode.DO_NOTHING_ON_CLOSE);
keyboardFocusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
keyboardFocusManager.addPropertyChangeListener("focusOwner", focusPropertyChangeListener);
+ // force this AWT Canvas to be focus-able,
+ // since this it is completely covered by the newtChild (z-order).
+ setFocusable(true);
if(isOnscreen) {
// onscreen newt child needs to fwd AWT focus
newtChild.setKeyboardFocusHandler(newtFocusTraversalKeyListener);
@@ -552,6 +548,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
newtChild.removeWindowListener(clearAWTMenusOnNewtFocus);
newtChild.setFocusAction(null);
newtChild.setDefaultCloseOperation(newtChildCloseOp);
+ setFocusable(false);
}
}
}
@@ -588,9 +585,6 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
configureNewtChild(true);
newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout to listener
- // force this AWT Canvas to be focus-able,
- // since this it is completely covered by the newtChild (z-order).
- setFocusable(true);
if(DEBUG) {
System.err.println("NewtCanvasAWT.attachNewtChild.X: win "+newtWinHandleToHexString(newtChild)+", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()+", comp "+this);
}
diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java
index d06aca039..e8cd71514 100644
--- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java
+++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java
@@ -42,6 +42,7 @@ import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;
+import com.jogamp.common.os.Platform;
import com.jogamp.newt.awt.NewtCanvasAWT;
import com.jogamp.newt.opengl.GLWindow;
@@ -94,12 +95,11 @@ import com.jogamp.newt.opengl.GLWindow;
public class JOGLNewtApplet1Run extends Applet {
public static final boolean DEBUG = JOGLNewtAppletBase.DEBUG;
- GLWindow glWindow;
- NewtCanvasAWT newtCanvasAWT;
- JOGLNewtAppletBase base;
+ GLWindow glWindow = null;
+ NewtCanvasAWT newtCanvasAWT = null;
+ JOGLNewtAppletBase base = null;
/** if valid glStandalone:=true (own window) ! */
int glXd=Integer.MAX_VALUE, glYd=Integer.MAX_VALUE, glWidth=Integer.MAX_VALUE, glHeight=Integer.MAX_VALUE;
- boolean glStandalone = false;
public void init() {
if(DEBUG) {
@@ -108,7 +108,7 @@ public class JOGLNewtApplet1Run extends Applet {
if(!(this instanceof Container)) {
throw new RuntimeException("This Applet is not a AWT Container");
}
- Container container = (Container) this;
+ final Container container = (Container) this;
String glEventListenerClazzName=null;
String glProfileName=null;
@@ -147,7 +147,7 @@ public class JOGLNewtApplet1Run extends Applet {
if(null==glEventListenerClazzName) {
throw new RuntimeException("No applet parameter 'gl_event_listener_class'");
}
- glStandalone = Integer.MAX_VALUE>glXd && Integer.MAX_VALUE>glYd && Integer.MAX_VALUE>glWidth && Integer.MAX_VALUE>glHeight;
+ final boolean glStandalone = Integer.MAX_VALUE>glXd && Integer.MAX_VALUE>glYd && Integer.MAX_VALUE>glWidth && Integer.MAX_VALUE>glHeight;
if(DEBUG) {
System.err.println("JOGLNewtApplet1Run Configuration:");
System.err.println("glStandalone: "+glStandalone);
@@ -209,9 +209,7 @@ public class JOGLNewtApplet1Run extends Applet {
addKeyListener((KeyListener)glEventListener);
}
}
- if(glStandalone) {
- newtCanvasAWT = null;
- } else {
+ if( !glStandalone ) {
newtCanvasAWT = new NewtCanvasAWT(glWindow);
container.add(newtCanvasAWT, BorderLayout.CENTER);
container.validate();
@@ -226,13 +224,15 @@ public class JOGLNewtApplet1Run extends Applet {
public void start() {
if(DEBUG) {
- System.err.println("JOGLNewtApplet1Run.start() START");
+ System.err.println("JOGLNewtApplet1Run.start() START (isVisible "+isVisible()+", isDisplayable "+isDisplayable()+")");
}
- this.validate();
this.setVisible(true);
-
final java.awt.Point p0 = this.getLocationOnScreen();
- if(glStandalone) {
+ if( null != newtCanvasAWT ) {
+ newtCanvasAWT.setFocusable(true);
+ newtCanvasAWT.requestFocus();
+ } else {
+ glWindow.requestFocus();
glWindow.setSize(glWidth, glHeight);
glWindow.setPosition(p0.x+glXd, p0.y+glYd);
}
@@ -251,6 +251,13 @@ public class JOGLNewtApplet1Run extends Applet {
System.err.println("GLWindow: "+glWindow);
}
base.start();
+ if( null != newtCanvasAWT && Platform.OSType.MACOS == Platform.getOSType() && newtCanvasAWT.isOffscreenLayerSurfaceEnabled() ) {
+ // force relayout
+ final int cW = newtCanvasAWT.getWidth();
+ final int cH = newtCanvasAWT.getHeight();
+ newtCanvasAWT.setSize(cW+1, cH+1);
+ newtCanvasAWT.setSize(cW, cH);
+ }
if(DEBUG) {
System.err.println("JOGLNewtApplet1Run.start() END");
}
@@ -271,12 +278,14 @@ public class JOGLNewtApplet1Run extends Applet {
System.err.println("JOGLNewtApplet1Run.destroy() START");
}
glWindow.setVisible(false); // hide 1st
- if(!glStandalone) {
+ if( null != newtCanvasAWT ) {
glWindow.reparentWindow(null); // get out of newtCanvasAWT
this.remove(newtCanvasAWT); // remove newtCanvasAWT
}
base.destroy(); // destroy glWindow unrecoverable
base=null;
+ glWindow=null;
+ newtCanvasAWT=null;
if(DEBUG) {
System.err.println("JOGLNewtApplet1Run.destroy() END");
}
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 c3ad51c96..25ddfad48 100644
--- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java
+++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java
@@ -164,12 +164,14 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener {
// Closing action: back to parent!
@Override
public void windowDestroyNotify(WindowEvent e) {
- if( WindowClosingMode.DO_NOTHING_ON_CLOSE == glWindow.getDefaultCloseOperation() ) {
+ if( isValid() && WindowClosingMode.DO_NOTHING_ON_CLOSE == glWindow.getDefaultCloseOperation() ) {
if(null == glWindow.getParent()) {
// we may be called directly by the native EDT
new Thread(new Runnable() {
public void run() {
- glWindow.reparentWindow(awtParent);
+ if( glWindow.isNativeValid() ) {
+ glWindow.reparentWindow(awtParent);
+ }
}
}).start();
}
@@ -284,11 +286,11 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener {
// ***********************************************************************************
// ***********************************************************************************
- public void keyPressed(KeyEvent e) {
- }
- public void keyReleased(KeyEvent e) {
- }
- public void keyTyped(KeyEvent e) {
+ @Override
+ public void keyPressed(KeyEvent e) {
+ if( !e.isPrintableKey() || e.isAutoRepeat() ) {
+ return;
+ }
if(e.getKeyChar()=='d') {
glWindow.setUndecorated(!glWindow.isUndecorated());
} if(e.getKeyChar()=='f') {
@@ -304,5 +306,9 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener {
}
}
}
+
+ @Override
+ public void keyReleased(KeyEvent e) {
+ }
}
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 45bccf964..ec05a34ad 100644
--- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java
+++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java
@@ -43,9 +43,8 @@ import com.jogamp.common.util.IntBitfield;
* <p>
* <table border="0">
* <tr><th>#</th><th>Event Type</th> <th>Constraints</th> <th>Notes</th></tr>
- * <tr><td>1</td><td>{@link #EVENT_KEY_PRESSED} </td><td> <i> excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys</i></td><td></td></tr>
- * <tr><td>2</td><td>{@link #EVENT_KEY_RELEASED} </td><td> <i> excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys</i></td><td></td></tr>
- * <tr><td>3</td><td>{@link #EVENT_KEY_TYPED} </td><td> <i>only for {@link #isPrintableKey() printable} and non {@link #isAutoRepeat() auto-repeat} keys</i></td><td><b>Deprecated</b>: Use {@link #EVENT_KEY_RELEASED} and apply constraints.</td></tr>
+ * <tr><td>1</td><td>{@link #EVENT_KEY_PRESSED} </td><td> <i> excluding {@link #isAutoRepeat() auto-repeat}-{@link #isModifierKey() modifier} keys</i></td><td></td></tr>
+ * <tr><td>2</td><td>{@link #EVENT_KEY_RELEASED} </td><td> <i> excluding {@link #isAutoRepeat() auto-repeat}-{@link #isModifierKey() modifier} keys</i></td><td></td></tr>
* </table>
* </p>
* In case the native platform does not
@@ -58,27 +57,24 @@ import com.jogamp.common.util.IntBitfield;
* <p>
* Auto-Repeat shall behave as follow:
* <pre>
- P = pressed, R = released, T = typed
+ P = pressed, R = released
0 = normal, 1 = auto-repeat
- P(0), [ R(1), P(1), R(1), ..], R(0) T(0)
+ P(0), [ R(1), P(1), R(1), ..], R(0)
* </pre>
* The idea is if you mask out auto-repeat in your event listener
- * or catch {@link #EVENT_KEY_TYPED typed} events only,
- * you just get one long pressed P/R/T triple for {@link #isPrintableKey() printable} keys.
- * {@link #isActionKey() Action} keys would produce one long pressed P/R tuple in case you mask out auto-repeat .
+ * you just get one long pressed P/R tuple for {@link #isPrintableKey() printable} and {@link #isActionKey() Action} keys.
* </p>
* <p>
* {@link #isActionKey() Action} keys will produce {@link #EVENT_KEY_PRESSED pressed}
* and {@link #EVENT_KEY_RELEASED released} events including {@link #isAutoRepeat() auto-repeat}.
* </p>
* <p>
- * {@link #isPrintableKey() Printable} keys will produce {@link #EVENT_KEY_PRESSED pressed},
- * {@link #EVENT_KEY_RELEASED released} and {@link #EVENT_KEY_TYPED typed} events, the latter is excluded for {@link #isAutoRepeat() auto-repeat} events.
+ * {@link #isPrintableKey() Printable} keys will produce {@link #EVENT_KEY_PRESSED pressed} and {@link #EVENT_KEY_RELEASED released} events.
* </p>
* <p>
- * {@link #isModifierKey() Modifier} keys will produce {@link #EVENT_KEY_PRESSED pressed}
- * and {@link #EVENT_KEY_RELEASED released} events excluding {@link #isAutoRepeat() auto-repeat}.
+ * {@link #isModifierKey() Modifier} keys will produce {@link #EVENT_KEY_PRESSED pressed} and {@link #EVENT_KEY_RELEASED released} events
+ * excluding {@link #isAutoRepeat() auto-repeat}.
* They will also influence subsequent event's {@link #getModifiers() modifier} bits while pressed.
* </p>
*
@@ -217,7 +213,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 + ")";
}
}
@@ -327,7 +322,6 @@ public class KeyEvent extends InputEvent
( nonPrintableKeys[3].min <= uniChar && uniChar <= nonPrintableKeys[3].max ) ) {
return false;
}
-
} else {
if( ( nonPrintableKeys[0].inclKeyChar && nonPrintableKeys[0].min <= uniChar && uniChar <= nonPrintableKeys[0].max ) ||
( nonPrintableKeys[1].inclKeyChar && nonPrintableKeys[1].min <= uniChar && uniChar <= nonPrintableKeys[1].max ) ||
@@ -362,15 +356,10 @@ public class KeyEvent extends InputEvent
private static final byte F_ACTION_MASK = 1 << 1;
private static final byte F_PRINTABLE_MASK = 1 << 2;
- /** A key has been pressed, excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys. */
+ /** A key has been pressed, excluding {@link #isAutoRepeat() auto-repeat}-{@link #isModifierKey() modifier} keys. */
public static final short EVENT_KEY_PRESSED = 300;
- /** A key has been released, excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys. */
+ /** 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.
@@ -391,12 +380,14 @@ public class KeyEvent extends InputEvent
this.max = max;
this.inclKeyChar = inclKeyChar;
}
- };
- /** Non printable key ranges, currently fixed to an aray of size 4. */
- public final static NonPrintableRange[] nonPrintableKeys = { new NonPrintableRange( (short)0x0000, (short)0x001F, true ),
- new NonPrintableRange( (short)0x0061, (short)0x0078, false),
- new NonPrintableRange( (short)0x007F, (short)0x009F, true ),
- new NonPrintableRange( (short)0xE000, (short)0xF8FF, true ) };
+ };
+ /** Non printable key ranges, currently fixed to an array of size 4. */
+ public final static NonPrintableRange[] nonPrintableKeys = {
+ new NonPrintableRange( (short)0x0000, (short)0x001F, true ), // Unicode: Non printable controls: [0x00 - 0x1F]
+ new NonPrintableRange( (short)0x0061, (short)0x0078, false), // Small 'a' thru 'z' (0x61 - 0x7a) - Not used for keyCode / keySym - Re-used for Fn (collision)
+ new NonPrintableRange( (short)0x008F, (short)0x009F, true ), // Unicode: Non printable controls: [0x7F - 0x9F], Numpad keys [0x7F - 0x8E] are printable!
+ new NonPrintableRange( (short)0xE000, (short)0xF8FF, true ) // Unicode: Private 0xE000 - 0xF8FF (Marked Non-Printable)
+ };
//
// Unicode: Non printable controls: [0x00 - 0x1F]
@@ -657,7 +648,7 @@ public class KeyEvent extends InputEvent
/** Constant for the "`" key */
public static final short VK_BACK_QUOTE = (short) 0x60;
- /** Small UTF/ASCII 'a' thru 'z' (0x61 - 0x7a) - Not used for keyCode / keySym. */
+ /** Small UTF/ASCII 'a' thru 'z' (0x61 - 0x7a) - Not used for keyCode / keySym. */
/**
* Constant for the F<i>n</i> function keys.
@@ -754,9 +745,11 @@ public class KeyEvent extends InputEvent
//
// Unicode: Non printable controls: [0x7F - 0x9F]
//
+ // Numpad keys [0x7F - 0x8E] are printable
+ //
- /** Constant for the DEL key, matching ASCII. Non printable UTF control. */
- public static final short VK_DELETE = (short) 0x7F;
+ /** Numeric keypad <b>decimal separator</b> key. Non printable UTF control. */
+ public static final short VK_SEPARATOR = (short) 0x7F;
/** Numeric keypad VK_NUMPAD0 thru VK_NUMPAD9 are mapped to UTF control (0x80 - 0x89). Non printable UTF control. */
public static final short VK_NUMPAD0 = (short) 0x80;
@@ -782,49 +775,37 @@ public class KeyEvent extends InputEvent
/** Numeric keypad <b>decimal separator</b> key. Non printable UTF control. */
public static final short VK_DECIMAL = (short) 0x8A;
- /** Numeric keypad <b>decimal separator</b> key. Non printable UTF control. */
- public static final short VK_SEPARATOR = (short) 0x8B;
-
/** Numeric keypad <b>add</b> key. Non printable UTF control. */
- public static final short VK_ADD = (short) 0x8C;
+ public static final short VK_ADD = (short) 0x8B;
/** Numeric keypad <b>subtract</b> key. Non printable UTF control. */
- public static final short VK_SUBTRACT = (short) 0x8D;
+ public static final short VK_SUBTRACT = (short) 0x8C;
/** Numeric keypad <b>multiply</b> key. Non printable UTF control. */
- public static final short VK_MULTIPLY = (short) 0x8E;
+ public static final short VK_MULTIPLY = (short) 0x8D;
/** Numeric keypad <b>divide</b> key. Non printable UTF control. */
- public static final short VK_DIVIDE = (short) 0x8F;
+ public static final short VK_DIVIDE = (short) 0x8E;
- /** Numeric keypad <b>num lock</b> key. Non printable UTF control. */
- public static final short VK_NUM_LOCK = (short) 0x90;
+ /** Constant for the DEL key, matching ASCII. Non printable UTF control. */
+ public static final short VK_DELETE = (short) 0x93;
- /** Numeric keypad <b>left</b> arrow key, for cursor pad see {@link #VK_LEFT}. Non printable UTF control. */
- public static final short VK_KP_LEFT = (short) 0x91;
-
- /** Numeric keypad <b>up</b> arrow key, for cursor pad see {@link #VK_UP}. Non printable UTF control. */
- public static final short VK_KP_UP = (short) 0x92;
-
- /** Constant for the numeric keypad <b>right</b> arrow key, for cursor pad see {@link #VK_RIGHT}. Non printable UTF control. */
- public static final short VK_KP_RIGHT = (short) 0x93;
+ /** Numeric keypad <b>num lock</b> key. Non printable UTF control. */
+ public static final short VK_NUM_LOCK = (short) 0x94;
- /** Numeric keypad <b>down</b> arrow key, for cursor pad see {@link #VK_DOWN}. Non printable UTF control. */
- public static final short VK_KP_DOWN = (short) 0x94;
-
- /** Constant for the cursor-pad <b>left</b> arrow key, for numerical pad see {@link #VK_KP_LEFT}*/
+ /** Constant for the cursor- or numerical-pad <b>left</b> arrow key. Non printable UTF control. */
public static final short VK_LEFT = (short) 0x95;
- /** Constant for the cursor-pad <b>left</b> arrow key, for numerical pad see {@link #VK_KP_UP}.*/
+ /** Constant for the cursor- or numerical-pad <b>up</b> arrow key. Non printable UTF control. */
public static final short VK_UP = (short) 0x96;
- /** Constant for the cursor-pad <b>left</b> arrow key, for numerical pad see {@link #VK_KP_RIGHT}.*/
+ /** Constant for the cursor- or numerical-pad <b>right</b> arrow key. Non printable UTF control. */
public static final short VK_RIGHT = (short) 0x97;
- /** Constant for the cursor-pad <b>left</b> arrow key, for numerical pad see {@link #VK_KP_DOWN}.*/
+ /** Constant for the cursor- or numerical pad <b>down</b> arrow key. Non printable UTF control. */
public static final short VK_DOWN = (short) 0x98;
- /** Constant for the Context Menu key. */
+ /** Constant for the Context Menu key. Non printable UTF control. */
public static final short VK_CONTEXT_MENU = (short) 0x99;
/**
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/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java
index a40b0aa18..18c8285f7 100644
--- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java
+++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java
@@ -92,6 +92,17 @@ public class MouseEvent extends InputEvent
/** Maximum number of buttons, value <code>16</code> */
public static final short BUTTON_NUMBER = 16;
+ /** Returns the 3-axis XYZ rotation array by given rotation on Y axis or X axis (if SHIFT_MASK is given in mods). */
+ public static final float[] getRotationXYZ(final float rotationXorY, final int mods) {
+ final float[] rotationXYZ = new float[] { 0f, 0f, 0f };
+ if( 0 != ( mods & InputEvent.SHIFT_MASK ) ) {
+ rotationXYZ[0] = rotationXorY;
+ } else {
+ rotationXYZ[1] = rotationXorY;
+ }
+ return rotationXYZ;
+ }
+
public static final short getClickTimeout() {
return 300;
}
@@ -99,7 +110,7 @@ public class MouseEvent extends InputEvent
/** Constructor for tradition 1-pointer mouse events. */
public MouseEvent(short eventType, Object source, long when,
int modifiers, int x, int y, short clickCount, short button,
- float rotation)
+ float[] rotationXYZ, float rotationScale)
{
super(eventType, source, when, modifiers);
this.x = new int[]{x};
@@ -109,13 +120,8 @@ public class MouseEvent extends InputEvent
this.pointerIDs = constMousePointerIDs;
this.clickCount=clickCount;
this.button=button;
- this.rotationXYZ = new float[] { 0f, 0f, 0f };
- if( isShiftDown() ) {
- this.rotationXYZ[0] = rotation;
- } else {
- this.rotationXYZ[1] = rotation;
- }
- this.rotationScale = 1f;
+ this.rotationXYZ = rotationXYZ;
+ this.rotationScale = rotationScale;
this.pointerTypes = constMousePointerTypes;
}
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/com/jogamp/newt/event/awt/AWTKeyAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java
index 1edef347b..bef2e5d0f 100644
--- a/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java
+++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java
@@ -71,12 +71,11 @@ public class AWTKeyAdapter extends AWTAdapter implements java.awt.event.KeyListe
@Override
public void keyReleased(java.awt.event.KeyEvent e) {
- com.jogamp.newt.event.KeyEvent keyReleaseEvt = AWTNewtEventFactory.createKeyEvent(com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED, e, newtWindow);
+ final com.jogamp.newt.event.KeyEvent event = AWTNewtEventFactory.createKeyEvent(com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED, e, newtWindow);
if(null!=newtListener) {
- final com.jogamp.newt.event.KeyListener newtKeyListener = (com.jogamp.newt.event.KeyListener)newtListener;
- newtKeyListener.keyReleased(keyReleaseEvt);
+ ((com.jogamp.newt.event.KeyListener)newtListener).keyReleased(event);
} else {
- enqueueEvent(false, keyReleaseEvt);
+ enqueueEvent(false, event);
}
}
diff --git a/src/newt/classes/jogamp/newt/Debug.java b/src/newt/classes/jogamp/newt/Debug.java
index 3c83da4d9..676d9b758 100644
--- a/src/newt/classes/jogamp/newt/Debug.java
+++ b/src/newt/classes/jogamp/newt/Debug.java
@@ -1,5 +1,6 @@
/*
- * Copyright (c) 2003-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -39,6 +40,9 @@
package jogamp.newt;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
import com.jogamp.common.util.PropertyAccess;
/** Helper routines for logging and debugging. */
@@ -49,7 +53,12 @@ public class Debug extends PropertyAccess {
private static final boolean debugAll;
static {
- PropertyAccess.addTrustedPrefix("newt.", Debug.class);
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ PropertyAccess.addTrustedPrefix("newt.");
+ return null;
+ } } );
+
verbose = isPropertyDefined("newt.verbose", true);
debugAll = isPropertyDefined("newt.debug", true);
if (verbose) {
@@ -60,18 +69,6 @@ public class Debug extends PropertyAccess {
}
}
- public static final boolean isPropertyDefined(final String property, final boolean jnlpAlias) {
- return PropertyAccess.isPropertyDefined(property, jnlpAlias, null);
- }
-
- public static final int getIntProperty(final String property, final boolean jnlpAlias, int defaultValue) {
- return PropertyAccess.getIntProperty(property, jnlpAlias, null, defaultValue);
- }
-
- public static final boolean getBooleanProperty(final String property, final boolean jnlpAlias) {
- return PropertyAccess.getBooleanProperty(property, jnlpAlias, null);
- }
-
public static boolean verbose() {
return verbose;
}
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index 16d252ca3..dca287c6b 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -2133,17 +2133,29 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
//
// MouseListener/Event Support
//
- public void sendMouseEvent(short eventType, int modifiers,
- int x, int y, short button, float rotation) {
+ public final void sendMouseEvent(short eventType, int modifiers,
+ int x, int y, short button, float rotation) {
doMouseEvent(false, false, eventType, modifiers, x, y, button, rotation);
}
- public void enqueueMouseEvent(boolean wait, short eventType, int modifiers,
- int x, int y, short button, float rotation) {
+ public final void enqueueMouseEvent(boolean wait, short eventType, int modifiers,
+ int x, int y, short button, float rotation) {
doMouseEvent(true, wait, eventType, modifiers, x, y, button, rotation);
}
-
+ protected final void doMouseEvent(boolean enqueue, boolean wait, short eventType, int modifiers,
+ int x, int y, short button, float rotation) {
+ this.doMouseEvent(enqueue, wait, eventType, modifiers, x, y, button, MouseEvent.getRotationXYZ(rotation, modifiers), 1f);
+ }
+ /**
+ public final void sendMouseEvent(short eventType, int modifiers,
+ int x, int y, short button, float[] rotationXYZ, float rotationScale) {
+ doMouseEvent(false, false, eventType, modifiers, x, y, button, rotationXYZ, rotationScale);
+ }
+ public final void enqueueMouseEvent(boolean wait, short eventType, int modifiers,
+ int x, int y, short button, float[] rotationXYZ, float rotationScale) {
+ doMouseEvent(true, wait, eventType, modifiers, x, y, button, rotationXYZ, rotationScale);
+ } */
protected void doMouseEvent(boolean enqueue, boolean wait, short eventType, int modifiers,
- int x, int y, short button, float rotation) {
+ int x, int y, short button, float[] rotationXYZ, float rotationScale) {
if( eventType == MouseEvent.EVENT_MOUSE_ENTERED || eventType == MouseEvent.EVENT_MOUSE_EXITED ) {
if( eventType == MouseEvent.EVENT_MOUSE_EXITED && x==-1 && y==-1 ) {
x = lastMousePosition.getX();
@@ -2172,7 +2184,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
if(!mouseInWindow) {
mouseInWindow = true;
eEntered = new MouseEvent(MouseEvent.EVENT_MOUSE_ENTERED, this, when,
- modifiers, x, y, (short)0, (short)0, (short)0);
+ modifiers, x, y, (short)0, (short)0, rotationXYZ, rotationScale);
// clear states
lastMousePressed = 0;
lastMouseClickCount = (short)0;
@@ -2213,13 +2225,13 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
mouseButtonPressed = button;
mouseButtonModMask |= MouseEvent.getButtonMask(button);
e = new MouseEvent(eventType, this, when,
- modifiers, x, y, lastMouseClickCount, button, 0);
+ modifiers, x, y, lastMouseClickCount, button, rotationXYZ, rotationScale);
} else if( MouseEvent.EVENT_MOUSE_RELEASED == eventType ) {
e = new MouseEvent(eventType, this, when,
- modifiers, x, y, lastMouseClickCount, button, 0);
+ modifiers, x, y, lastMouseClickCount, button, rotationXYZ, rotationScale);
if( when - lastMousePressed < MouseEvent.getClickTimeout() ) {
eClicked = new MouseEvent(MouseEvent.EVENT_MOUSE_CLICKED, this, when,
- modifiers, x, y, lastMouseClickCount, button, 0);
+ modifiers, x, y, lastMouseClickCount, button, rotationXYZ, rotationScale);
} else {
lastMouseClickCount = (short)0;
lastMousePressed = 0;
@@ -2229,15 +2241,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
} else if( MouseEvent.EVENT_MOUSE_MOVED == eventType ) {
if ( mouseButtonPressed > 0 ) {
e = new MouseEvent(MouseEvent.EVENT_MOUSE_DRAGGED, this, when,
- modifiers, x, y, (short)1, mouseButtonPressed, 0);
+ modifiers, x, y, (short)1, mouseButtonPressed, rotationXYZ, rotationScale);
} else {
e = new MouseEvent(eventType, this, when,
- modifiers, x, y, (short)0, button, (short)0);
+ modifiers, x, y, (short)0, button, rotationXYZ, rotationScale);
}
} else if( MouseEvent.EVENT_MOUSE_WHEEL_MOVED == eventType ) {
- e = new MouseEvent(eventType, this, when, modifiers, x, y, (short)0, button, rotation);
+ e = new MouseEvent(eventType, this, when, modifiers, x, y, (short)0, button, rotationXYZ, rotationScale);
} else {
- e = new MouseEvent(eventType, this, when, modifiers, x, y, (short)0, button, 0);
+ e = new MouseEvent(eventType, this, when, modifiers, x, y, (short)0, button, rotationXYZ, rotationScale);
}
if( null != eEntered ) {
if(DEBUG_MOUSE_EVENT) {
@@ -2464,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:
@@ -2473,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 ) {
@@ -2516,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/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java
index ccbdc07bf..1e15070f8 100644
--- a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java
+++ b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java
@@ -28,6 +28,8 @@
package jogamp.newt.awt.event;
+import com.jogamp.newt.event.MouseEvent;
+
/**
*
* <a name="AWTEventModifierMapping"><h5>AWT Event Modifier Mapping</h5></a>
@@ -369,13 +371,13 @@ public class AWTNewtEventFactory {
case java.awt.event.KeyEvent.VK_MULTIPLY : return com.jogamp.newt.event.KeyEvent.VK_MULTIPLY;
case java.awt.event.KeyEvent.VK_DIVIDE : return com.jogamp.newt.event.KeyEvent.VK_DIVIDE;
case java.awt.event.KeyEvent.VK_NUM_LOCK : return com.jogamp.newt.event.KeyEvent.VK_NUM_LOCK;
- case java.awt.event.KeyEvent.VK_KP_LEFT : return com.jogamp.newt.event.KeyEvent.VK_KP_LEFT;
- case java.awt.event.KeyEvent.VK_KP_UP : return com.jogamp.newt.event.KeyEvent.VK_KP_UP;
- case java.awt.event.KeyEvent.VK_KP_RIGHT : return com.jogamp.newt.event.KeyEvent.VK_KP_RIGHT;
- case java.awt.event.KeyEvent.VK_KP_DOWN : return com.jogamp.newt.event.KeyEvent.VK_KP_DOWN;
+ case java.awt.event.KeyEvent.VK_KP_LEFT : /** Fall through intended .. */
case java.awt.event.KeyEvent.VK_LEFT : return com.jogamp.newt.event.KeyEvent.VK_LEFT;
+ case java.awt.event.KeyEvent.VK_KP_UP : /** Fall through intended .. */
case java.awt.event.KeyEvent.VK_UP : return com.jogamp.newt.event.KeyEvent.VK_UP;
+ case java.awt.event.KeyEvent.VK_KP_RIGHT : /** Fall through intended .. */
case java.awt.event.KeyEvent.VK_RIGHT : return com.jogamp.newt.event.KeyEvent.VK_RIGHT;
+ case java.awt.event.KeyEvent.VK_KP_DOWN : /** Fall through intended .. */
case java.awt.event.KeyEvent.VK_DOWN : return com.jogamp.newt.event.KeyEvent.VK_DOWN;
case java.awt.event.KeyEvent.VK_CONTEXT_MENU : return com.jogamp.newt.event.KeyEvent.VK_CONTEXT_MENU;
case java.awt.event.KeyEvent.VK_WINDOWS : return com.jogamp.newt.event.KeyEvent.VK_WINDOWS;
@@ -550,10 +552,6 @@ public class AWTNewtEventFactory {
case com.jogamp.newt.event.KeyEvent.VK_MULTIPLY : return java.awt.event.KeyEvent.VK_MULTIPLY;
case com.jogamp.newt.event.KeyEvent.VK_DIVIDE : return java.awt.event.KeyEvent.VK_DIVIDE;
case com.jogamp.newt.event.KeyEvent.VK_NUM_LOCK : return java.awt.event.KeyEvent.VK_NUM_LOCK;
- case com.jogamp.newt.event.KeyEvent.VK_KP_LEFT : return java.awt.event.KeyEvent.VK_KP_LEFT;
- case com.jogamp.newt.event.KeyEvent.VK_KP_UP : return java.awt.event.KeyEvent.VK_KP_UP;
- case com.jogamp.newt.event.KeyEvent.VK_KP_RIGHT : return java.awt.event.KeyEvent.VK_KP_RIGHT;
- case com.jogamp.newt.event.KeyEvent.VK_KP_DOWN : return java.awt.event.KeyEvent.VK_KP_DOWN;
case com.jogamp.newt.event.KeyEvent.VK_LEFT : return java.awt.event.KeyEvent.VK_LEFT;
case com.jogamp.newt.event.KeyEvent.VK_UP : return java.awt.event.KeyEvent.VK_UP;
case com.jogamp.newt.event.KeyEvent.VK_RIGHT : return java.awt.event.KeyEvent.VK_RIGHT;
@@ -639,7 +637,7 @@ public class AWTNewtEventFactory {
return new com.jogamp.newt.event.MouseEvent(
newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(),
mods, event.getX(), event.getY(), (short)event.getClickCount(),
- newtButton, rotation);
+ newtButton, MouseEvent.getRotationXYZ(rotation, mods), 1f);
}
return null; // no mapping ..
}
diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
index 6370782df..6aebf0410 100644
--- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
@@ -423,8 +423,8 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
", was: pressed "+isKeyPressed(keyCode)+", isModifierKeyCode "+isModifierKeyCode);
} */
- // 1:1 Order: OSX and NEWT delivery order is PRESSED, RELEASED and TYPED
- // Auto-Repeat: OSX delivers only PRESSED, inject auto-repeat RELEASE and TYPED keys _before_ PRESSED
+ // OSX delivery order is PRESSED (t0), RELEASED (t1) and TYPED (t2) -> NEWT order: PRESSED (t0) and RELEASED (t1)
+ // Auto-Repeat: OSX delivers only PRESSED, inject auto-repeat RELEASE key _before_ PRESSED
switch(eventType) {
case KeyEvent.EVENT_KEY_RELEASED:
if( isKeyCodeTracked(keyCode) ) {
diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java
index ad7e1e8f3..60fc3ec0f 100644
--- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java
@@ -288,7 +288,7 @@ public class WindowDriver extends WindowImpl {
// System.err.println("*** sendKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", keyCode "+toHexString(keyCode)+", keyChar <"+keyChar+">, mods "+toHexString(modifiers)+
// ", isKeyCodeTracked "+isKeyCodeTracked(keyCode)+", was: pressed "+isKeyPressed(keyCode)+", repeat "+isKeyInAutoRepeat(keyCode)+", printableKey "+KeyEvent.isPrintableKey(keyCode)+" [modifierKey "+isModifierKey+"] - "+System.currentTimeMillis());
- // Reorder: WINDOWS delivery order is PRESSED (t0), TYPED (t0) and RELEASED (t1) -> NEWT order: PRESSED (t0), RELEASED (t1) and TYPED (t1)
+ // Reorder: WINDOWS delivery order is PRESSED (t0), TYPED (t0) and RELEASED (t1) -> NEWT order: PRESSED (t0) and RELEASED (t1)
// Auto-Repeat: WINDOWS delivers only PRESSED (t0) and TYPED (t0).
switch(eventType) {
case KeyEvent.EVENT_KEY_RELEASED:
@@ -307,8 +307,6 @@ public class WindowDriver extends WindowImpl {
super.sendKeyEvent(KeyEvent.EVENT_KEY_PRESSED, modifiers, keyCode, keySym, keyChar);
}
break;
- // case KeyEvent.EVENT_KEY_TYPED:
- // break;
}
}
diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java
index fcc5b2148..c752977a9 100644
--- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java
@@ -228,7 +228,7 @@ public class WindowDriver extends WindowImpl {
@Override
protected final void doMouseEvent(boolean enqueue, boolean wait, short eventType, int modifiers,
- int x, int y, short button, float rotation) {
+ int x, int y, short button, float[] rotationXYZ, float rotationScale) {
switch(eventType) {
case MouseEvent.EVENT_MOUSE_PRESSED:
switch(button) {
@@ -241,33 +241,34 @@ public class WindowDriver extends WindowImpl {
}
break;
case MouseEvent.EVENT_MOUSE_RELEASED:
+ final boolean shiftPressed = 0 != ( modifiers & InputEvent.SHIFT_MASK );
switch(button) {
- case X11_WHEEL_ONE_UP_BUTTON:
+ case X11_WHEEL_ONE_UP_BUTTON: // vertical scroll up
eventType = MouseEvent.EVENT_MOUSE_WHEEL_MOVED;
button = 1;
- rotation = 1;
+ rotationXYZ[shiftPressed ? 0 : 1] = 1;
break;
- case X11_WHEEL_ONE_DOWN_BUTTON:
+ case X11_WHEEL_ONE_DOWN_BUTTON: // vertical scroll down
eventType = MouseEvent.EVENT_MOUSE_WHEEL_MOVED;
button = 1;
- rotation = -1;
+ rotationXYZ[shiftPressed ? 0 : 1] = -1;
break;
- case X11_WHEEL_TWO_UP_BUTTON: // vertical scroll left
+ case X11_WHEEL_TWO_UP_BUTTON: // horizontal scroll left
eventType = MouseEvent.EVENT_MOUSE_WHEEL_MOVED;
button = 1;
- rotation = 1;
+ rotationXYZ[0] = 1;
modifiers |= InputEvent.SHIFT_MASK;
break;
- case X11_WHEEL_TWO_DOWN_BUTTON: // vertical scroll right
+ case X11_WHEEL_TWO_DOWN_BUTTON: // horizontal scroll right
eventType = MouseEvent.EVENT_MOUSE_WHEEL_MOVED;
button = 1;
- rotation = -1;
+ rotationXYZ[0] = -1;
modifiers |= InputEvent.SHIFT_MASK;
break;
}
break;
}
- super.doMouseEvent(enqueue, wait, eventType, modifiers, x, y, button, rotation);
+ super.doMouseEvent(enqueue, wait, eventType, modifiers, x, y, button, rotationXYZ, rotationScale);
}
protected final void sendKeyEvent(short eventType, int modifiers, short keyCode, short keySym, char keyChar0, String keyString) {
@@ -287,9 +288,6 @@ public class WindowDriver extends WindowImpl {
case KeyEvent.EVENT_KEY_RELEASED:
super.sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keySym, keyChar);
break;
-
- // case KeyEvent.EVENT_KEY_TYPED:
- // break;
}
}
}
diff --git a/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java
index 5e240636d..3782a1186 100644
--- a/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java
+++ b/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java
@@ -33,6 +33,7 @@ import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import com.jogamp.newt.event.InputEvent;
+import com.jogamp.newt.event.MouseEvent;
/**
* SWT event translator to NEWT, inclusive dispatch listener.
@@ -55,7 +56,6 @@ public class SWTNewtEventFactory {
case SWT.KeyDown: return com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED;
case SWT.KeyUp: return com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED;
- // case SWT.KeyXXX: return com.jogamp.newt.event.KeyEvent.EVENT_KEY_TYPED;
}
return (short)0;
}
@@ -189,13 +189,9 @@ public class SWTNewtEventFactory {
case com.jogamp.newt.event.KeyEvent.VK_MULTIPLY : return SWT.KEYPAD_MULTIPLY;
case com.jogamp.newt.event.KeyEvent.VK_DIVIDE : return SWT.KEYPAD_DIVIDE;
case com.jogamp.newt.event.KeyEvent.VK_NUM_LOCK : return SWT.NUM_LOCK;
- case com.jogamp.newt.event.KeyEvent.VK_KP_LEFT :
case com.jogamp.newt.event.KeyEvent.VK_LEFT : return SWT.ARROW_LEFT;
- case com.jogamp.newt.event.KeyEvent.VK_KP_UP :
case com.jogamp.newt.event.KeyEvent.VK_UP : return SWT.ARROW_UP;
- case com.jogamp.newt.event.KeyEvent.VK_KP_RIGHT :
case com.jogamp.newt.event.KeyEvent.VK_RIGHT : return SWT.ARROW_RIGHT;
- case com.jogamp.newt.event.KeyEvent.VK_KP_DOWN :
case com.jogamp.newt.event.KeyEvent.VK_DOWN : return SWT.ARROW_DOWN;
case com.jogamp.newt.event.KeyEvent.VK_HELP : return SWT.HELP;
}
@@ -246,7 +242,7 @@ public class SWTNewtEventFactory {
return new com.jogamp.newt.event.MouseEvent(
type, (null==source)?(Object)event.data:source, (0xFFFFFFFFL & (long)event.time),
- mods, event.x, event.y, (short)event.count, (short)event.button, rotation);
+ mods, event.x, event.y, (short)event.count, (short)event.button, MouseEvent.getRotationXYZ(rotation, mods), 1f);
}
return null; // no mapping ..
}
@@ -301,7 +297,7 @@ public class SWTNewtEventFactory {
res.getSource(),
res.getWhen(), res.getModifiers(),
res.getX(), res.getY(), res.getClickCount(),
- res.getButton(), res.getWheelRotation() );
+ res.getButton(), res.getRotation(), res.getRotationScale());
l.mouseClicked(res2);
}
break;
@@ -312,7 +308,7 @@ public class SWTNewtEventFactory {
res.getSource(),
res.getWhen(), res.getModifiers(),
res.getX(), res.getY(), res.getClickCount(),
- dragButtonDown, res.getWheelRotation() );
+ dragButtonDown, res.getRotation(), res.getRotationScale());
l.mouseDragged( res2 );
} else {
l.mouseMoved(res);
diff --git a/src/newt/native/KeyEvent.h b/src/newt/native/KeyEvent.h
index 7a63b19ce..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 )
@@ -161,7 +160,7 @@
// Unicode: Non printable controls: [0x7F - 0x9F]
//
-#define J_VK_DELETE ( 0x7FU )
+#define J_VK_SEPARATOR ( 0x7FU )
#define J_VK_NUMPAD0 ( 0x80U )
#define J_VK_NUMPAD1 ( 0x81U )
#define J_VK_NUMPAD2 ( 0x82U )
@@ -173,16 +172,13 @@
#define J_VK_NUMPAD8 ( 0x88U )
#define J_VK_NUMPAD9 ( 0x89U )
#define J_VK_DECIMAL ( 0x8AU )
-#define J_VK_SEPARATOR ( 0x8BU )
-#define J_VK_ADD ( 0x8CU )
-#define J_VK_SUBTRACT ( 0x8DU )
-#define J_VK_MULTIPLY ( 0x8EU )
-#define J_VK_DIVIDE ( 0x8FU )
-#define J_VK_NUM_LOCK ( 0x90U )
-#define J_VK_KP_LEFT ( 0x91U )
-#define J_VK_KP_UP ( 0x92U )
-#define J_VK_KP_RIGHT ( 0x93U )
-#define J_VK_KP_DOWN ( 0x94U )
+#define J_VK_ADD ( 0x8BU )
+#define J_VK_SUBTRACT ( 0x8CU )
+#define J_VK_MULTIPLY ( 0x8DU )
+#define J_VK_DIVIDE ( 0x8EU )
+
+#define J_VK_DELETE ( 0x93U )
+#define J_VK_NUM_LOCK ( 0x94U )
#define J_VK_LEFT ( 0x95U )
#define J_VK_UP ( 0x96U )
#define J_VK_RIGHT ( 0x97U )
@@ -195,7 +191,6 @@
#define J_VK_BEGIN ( 0x9EU )
#define J_VK_STOP ( 0x9FU )
-
//
// Unicode: Printable [0x00A0 - 0xDFFF]
//
diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c
index 7ede3a20d..ac0ebf07e 100644
--- a/src/newt/native/WindowsWindow.c
+++ b/src/newt/native/WindowsWindow.c
@@ -219,6 +219,7 @@ static KeyMapEntry keyMapTable[] = {
{J_VK_INSERT, VK_INSERT, 0},
{J_VK_DELETE, VK_DELETE, 0},
{J_VK_HOME, VK_HOME, 0},
+ // {J_VK_BEGIN, VK_BEGIN, 0}, // not mapped
{J_VK_END, VK_END, 0},
{J_VK_PAGE_UP, VK_PRIOR, 0},
{J_VK_PAGE_DOWN, VK_NEXT, 0},
@@ -332,6 +333,8 @@ static KeyMapEntry keyMapTable[] = {
#define MAPVK_VK_TO_VSC_EX 4
#endif
+#define IS_WITHIN(k,a,b) ((a)<=(k)&&(k)<=(b))
+
static HKL kbdLayoutUS = 0;
static const LPCSTR US_LAYOUT_NAME = "00000409";
@@ -398,23 +401,6 @@ static void ParseWmVKeyAndScanCode(USHORT winVKey, BYTE winScanCode, BYTE flags,
kbdState[VK_SPACE] &= ~0x80;
}
- // Assume extended scan code 0xE0 if extended flags is set (no 0xE1 from WM_KEYUP/WM_KEYDOWN)
- USHORT winScanCodeExt = winScanCode;
- if( 0 != ( 0x01 & flags ) ) {
- winScanCodeExt |= 0xE000;
- }
-
- //
- // winVKey, winScanCodeExt -> javaVKeyUS w/ US KeyboardLayout
- //
- for (i = 0; keyMapTable[i].windowsKey != 0; i++) {
- if ( keyMapTable[i].windowsScanCodeUS == winScanCodeExt ) {
- javaVKeyUS = keyMapTable[i].javaKey;
- winVKeyUS = keyMapTable[i].windowsKey;
- break;
- }
- }
-
//
// winVKey -> javaVKeyXX
//
@@ -424,6 +410,28 @@ static void ParseWmVKeyAndScanCode(USHORT winVKey, BYTE winScanCode, BYTE flags,
break;
}
}
+ if( IS_WITHIN( winVKey, VK_NUMPAD0, VK_DIVIDE ) ) {
+ // Use modded keySym for keypad for US and NN
+ winVKeyUS = winVKey;
+ javaVKeyUS = javaVKeyXX;
+ } else {
+ // Assume extended scan code 0xE0 if extended flags is set (no 0xE1 from WM_KEYUP/WM_KEYDOWN)
+ USHORT winScanCodeExt = winScanCode;
+ if( 0 != ( 0x01 & flags ) ) {
+ winScanCodeExt |= 0xE000;
+ }
+
+ //
+ // winVKey, winScanCodeExt -> javaVKeyUS w/ US KeyboardLayout
+ //
+ for (i = 0; keyMapTable[i].windowsKey != 0; i++) {
+ if ( keyMapTable[i].windowsScanCodeUS == winScanCodeExt ) {
+ winVKeyUS = keyMapTable[i].windowsKey;
+ javaVKeyUS = keyMapTable[i].javaKey;
+ break;
+ }
+ }
+ }
*outJavaVKeyUS = javaVKeyUS;
*outJavaVKeyXX = javaVKeyXX;
diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c
index 56b7251d2..e2392a113 100644
--- a/src/newt/native/X11Display.c
+++ b/src/newt/native/X11Display.c
@@ -58,6 +58,10 @@ static jmethodID requestFocusID = NULL;
#define IS_WITHIN(k,a,b) ((a)<=(k)&&(k)<=(b))
+/**
+ * QT Reference:
+ * <http://qt.gitorious.org/qt/qt/blobs/4.7/src/gui/kernel/qkeymapper_x11.cpp#line879>
+ */
static short X11KeySym2NewtVKey(KeySym keySym) {
if( IS_WITHIN( keySym, XK_a, XK_z ) ) {
return ( keySym - XK_a ) + J_VK_A ;
@@ -84,8 +88,6 @@ static short X11KeySym2NewtVKey(KeySym keySym) {
return J_VK_TAB;
case XK_Cancel:
return J_VK_CANCEL;
- case XK_Clear:
- return J_VK_CLEAR;
case XK_Shift_L:
case XK_Shift_R:
return J_VK_SHIFT;
@@ -95,6 +97,7 @@ static short X11KeySym2NewtVKey(KeySym keySym) {
case XK_Alt_L:
return J_VK_ALT;
case XK_Alt_R:
+ case XK_ISO_Level3_Shift:
return J_VK_ALT_GRAPH;
case XK_Super_L:
case XK_Super_R:
@@ -119,6 +122,10 @@ static short X11KeySym2NewtVKey(KeySym keySym) {
case XK_End:
case XK_KP_End:
return J_VK_END;
+ case XK_Begin:
+ return J_VK_BEGIN;
+ case XK_KP_Begin: // NumPad 5 - equal behavior w/ QT/Windows
+ return J_VK_CLEAR;
case XK_Home:
case XK_KP_Home:
return J_VK_HOME;
@@ -146,6 +153,7 @@ static short X11KeySym2NewtVKey(KeySym keySym) {
return J_VK_DECIMAL;
case XK_KP_Divide:
return J_VK_DIVIDE;
+ case XK_Clear: // equal behavior w/ QT
case XK_Delete:
case XK_KP_Delete:
return J_VK_DELETE;
@@ -450,7 +458,15 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage
keyString = (*env)->NewStringUTF(env, text);
}
- if( 0 == keyChar ) {
+ #ifdef DEBUG_KEYS
+ fprintf(stderr, "NEWT X11 Key.0: keyCode 0x%X keySym 0x%X, (shifted: 0x%X)\n",
+ (int)keyCode, (int)keySym, (int) shiftedKeySym);
+ #endif
+ if( IS_WITHIN( shiftedKeySym, XK_KP_Space, XK_KP_9 ) ) {
+ // Use modded keySym for keypad for US and NN
+ keySym = shiftedKeySym;
+ unShiftedKeySym = shiftedKeySym;
+ } else if( 0 == keyChar ) {
// Use keyCode's keySym for dead-key (aka modifiers, etc)
unShiftedKeySym = keySym;
} else if( 0 == ( evt.xkey.state & ShiftCtrlModMask ) ) {
@@ -467,7 +483,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage
modifiers |= X11InputState2NewtModifiers(xkey_state, javaVKeyNN, evt.type == KeyPress) | autoRepeatModifiers;
#ifdef DEBUG_KEYS
- fprintf(stderr, "NEWT X11 Key: keyCode 0x%X keySym 0x%X, (0x%X, shifted: 0x%X), keyChar '%c' 0x%X %d, javaVKey[US 0x%X, NN 0x%X], xstate 0x%X %u, jmods 0x%X\n",
+ fprintf(stderr, "NEWT X11 Key.X: keyCode 0x%X keySym 0x%X, (0x%X, shifted: 0x%X), keyChar '%c' 0x%X %d, javaVKey[US 0x%X, NN 0x%X], xstate 0x%X %u, jmods 0x%X\n",
(int)keyCode, (int)keySym, (int) unShiftedKeySym, (int)shiftedKeySym, keyChar, keyChar, charCount,
(int)javaVKeyUS, (int)javaVKeyNN,
(int)xkey_state, (int)xkey_state, (int)modifiers);
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 6c5a127b6..3f50f27a4 100644
--- a/src/newt/native/X11Window.c
+++ b/src/newt/native/X11Window.c
@@ -676,6 +676,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CloseWindow0
Display * dpy = (Display *) (intptr_t) display;
Window w = (Window)window;
jobject jwindow;
+ XWindowAttributes xwa;
if(dpy==NULL) {
NewtCommon_FatalError(env, "invalid display connection..");
@@ -694,6 +695,8 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CloseWindow0
}
XSync(dpy, False);
+ memset(&xwa, 0, sizeof(XWindowAttributes));
+ XGetWindowAttributes(dpy, w, &xwa); // prefetch colormap to be destroyed after window destruction
XSelectInput(dpy, w, 0);
XUnmapWindow(dpy, w);
@@ -701,6 +704,9 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CloseWindow0
Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessages0(env, obj, display, javaObjectAtom, windowDeleteAtom /*, kbdHandle */); // XKB disabled for now
XDestroyWindow(dpy, w);
+ if( None != xwa.colormap ) {
+ XFreeColormap(dpy, xwa.colormap);
+ }
XSync(dpy, True); // discard all events now, no more handler
(*env)->DeleteGlobalRef(env, jwindow);
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;