diff --git a/core/src/processing/awt/PSurfaceAWT.java b/core/src/processing/awt/PSurfaceAWT.java index 03bb03a48..0bee141d1 100644 --- a/core/src/processing/awt/PSurfaceAWT.java +++ b/core/src/processing/awt/PSurfaceAWT.java @@ -1316,44 +1316,24 @@ public class PSurfaceAWT extends PSurfaceNone { break; } - //System.out.println(nativeEvent); - //int modifiers = nativeEvent.getModifiersEx(); - // If using getModifiersEx(), the regular modifiers don't set properly. - int modifiers = nativeEvent.getModifiers(); - - int peModifiers = modifiers & - (InputEvent.SHIFT_MASK | - InputEvent.CTRL_MASK | - InputEvent.META_MASK | - InputEvent.ALT_MASK); - - // Windows and OS X seem to disagree on how to handle this. Windows only - // sets BUTTON1_DOWN_MASK, while OS X seems to set BUTTON1_MASK. - // This is an issue in particular with mouse release events: + // Switching to getModifiersEx() for 4.0a2 because of Java 9 deprecation. + // Had trouble with this in the past and rolled it back because it was + // optional at the time. This time around, just need to iron out the issue. // http://code.google.com/p/processing/issues/detail?id=1294 - // The fix for which led to a regression (fixed here by checking both): // http://code.google.com/p/processing/issues/detail?id=1332 + int modifiers = nativeEvent.getModifiersEx(); + int peButton = 0; -// if ((modifiers & InputEvent.BUTTON1_MASK) != 0 || -// (modifiers & InputEvent.BUTTON1_DOWN_MASK) != 0) { -// peButton = LEFT; -// } else if ((modifiers & InputEvent.BUTTON2_MASK) != 0 || -// (modifiers & InputEvent.BUTTON2_DOWN_MASK) != 0) { -// peButton = CENTER; -// } else if ((modifiers & InputEvent.BUTTON3_MASK) != 0 || -// (modifiers & InputEvent.BUTTON3_DOWN_MASK) != 0) { -// peButton = RIGHT; -// } - if ((modifiers & InputEvent.BUTTON1_MASK) != 0) { + if ((modifiers & InputEvent.BUTTON1_DOWN_MASK) != 0) { peButton = PConstants.LEFT; - } else if ((modifiers & InputEvent.BUTTON2_MASK) != 0) { + } else if ((modifiers & InputEvent.BUTTON2_DOWN_MASK) != 0) { peButton = PConstants.CENTER; - } else if ((modifiers & InputEvent.BUTTON3_MASK) != 0) { + } else if ((modifiers & InputEvent.BUTTON3_DOWN_MASK) != 0) { peButton = PConstants.RIGHT; } sketch.postEvent(new MouseEvent(nativeEvent, nativeEvent.getWhen(), - peAction, peModifiers, + peAction, modifiers, nativeEvent.getX() / windowScaleFactor, nativeEvent.getY() / windowScaleFactor, peButton, @@ -1375,6 +1355,9 @@ public class PSurfaceAWT extends PSurfaceNone { break; } + int modifiers = event.getModifiersEx(); + + /* // int peModifiers = event.getModifiersEx() & // (InputEvent.SHIFT_DOWN_MASK | // InputEvent.CTRL_DOWN_MASK | @@ -1385,9 +1368,10 @@ public class PSurfaceAWT extends PSurfaceNone { InputEvent.CTRL_MASK | InputEvent.META_MASK | InputEvent.ALT_MASK); + */ sketch.postEvent(new KeyEvent(event, event.getWhen(), - peAction, peModifiers, + peAction, modifiers, event.getKeyChar(), event.getKeyCode())); } diff --git a/core/src/processing/event/MouseEvent.java b/core/src/processing/event/MouseEvent.java index bde328ff3..ee36a5232 100644 --- a/core/src/processing/event/MouseEvent.java +++ b/core/src/processing/event/MouseEvent.java @@ -37,28 +37,17 @@ public class MouseEvent extends Event { protected int x, y; protected int button; -// protected int clickCount; -// protected float amount; protected int count; -// public MouseEvent(int x, int y) { -// this(null, -// System.currentTimeMillis(), PRESSED, 0, -// x, y, PConstants.LEFT, 1); -// } - - public MouseEvent(Object nativeObject, long millis, int action, int modifiers, - int x, int y, int button, int count) { //float amount) { //int clickCount) { + int x, int y, int button, int count) { super(nativeObject, millis, action, modifiers); this.flavor = MOUSE; this.x = x; this.y = y; this.button = button; - //this.clickCount = clickCount; - //this.amount = amount; this.count = count; } @@ -79,27 +68,6 @@ public class MouseEvent extends Event { } -// public void setButton(int button) { -// this.button = button; -// } - - - /** Do not use, getCount() is the correct method. */ - @Deprecated - public int getClickCount() { - //return (int) amount; //clickCount; - return count; - } - - - /** Do not use, getCount() is the correct method. */ - @Deprecated - public float getAmount() { - //return amount; - return count; - } - - /** * Number of clicks for mouse button events, or the number of steps (positive * or negative depending on direction) for a mouse wheel event. @@ -114,10 +82,6 @@ public class MouseEvent extends Event { } -// public void setClickCount(int clickCount) { -// this.clickCount = clickCount; -// } - private String actionString() { switch (action) { default: diff --git a/core/src/processing/opengl/PGraphicsOpenGL.java b/core/src/processing/opengl/PGraphicsOpenGL.java index 7d992cdb3..f9b60be01 100644 --- a/core/src/processing/opengl/PGraphicsOpenGL.java +++ b/core/src/processing/opengl/PGraphicsOpenGL.java @@ -751,6 +751,7 @@ public class PGraphicsOpenGL extends PGraphics { } + @Override public boolean saveImpl(String filename) { // return super.save(filename); // ASYNC save frame using PBOs not yet available on Android diff --git a/core/src/processing/opengl/PSurfaceJOGL.java b/core/src/processing/opengl/PSurfaceJOGL.java index ae632d9a0..487aa0a83 100644 --- a/core/src/processing/opengl/PSurfaceJOGL.java +++ b/core/src/processing/opengl/PSurfaceJOGL.java @@ -65,7 +65,6 @@ import com.jogamp.newt.Display.PointerIcon; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Screen; import com.jogamp.newt.awt.NewtCanvasAWT; -import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.util.FPSAnimator; @@ -77,6 +76,7 @@ import processing.core.PSurface; import processing.event.KeyEvent; import processing.event.MouseEvent; import processing.awt.PImageAWT; + // have this removed by 4.0 final import processing.awt.ShimAWT; @@ -1110,11 +1110,13 @@ public class PSurfaceJOGL implements PSurface { protected void nativeMouseEvent(com.jogamp.newt.event.MouseEvent nativeEvent, int peAction) { int modifiers = nativeEvent.getModifiers(); + /* int peModifiers = modifiers & (InputEvent.SHIFT_MASK | InputEvent.CTRL_MASK | InputEvent.META_MASK | InputEvent.ALT_MASK); + */ int peButton = 0; switch (nativeEvent.getButton()) { @@ -1163,7 +1165,7 @@ public class PSurfaceJOGL implements PSurface { } MouseEvent me = new MouseEvent(nativeEvent, nativeEvent.getWhen(), - peAction, peModifiers, + peAction, modifiers, mx, my, peButton, peCount); @@ -1174,11 +1176,12 @@ public class PSurfaceJOGL implements PSurface { protected void nativeKeyEvent(com.jogamp.newt.event.KeyEvent nativeEvent, int peAction) { - int peModifiers = nativeEvent.getModifiers() & - (InputEvent.SHIFT_MASK | - InputEvent.CTRL_MASK | - InputEvent.META_MASK | - InputEvent.ALT_MASK); + int modifiers = nativeEvent.getModifiers(); +// int peModifiers = nativeEvent.getModifiers() & +// (InputEvent.SHIFT_MASK | +// InputEvent.CTRL_MASK | +// InputEvent.META_MASK | +// InputEvent.ALT_MASK); short code = nativeEvent.getKeyCode(); char keyChar; @@ -1204,7 +1207,7 @@ public class PSurfaceJOGL implements PSurface { // In contrast to key symbol, key code uses a fixed US keyboard layout and therefore is keyboard layout independent. // E.g. virtual key code VK_Y denotes the same physical key regardless whether keyboard layout QWERTY or QWERTZ is active. The key symbol of the former is VK_Y, where the latter produces VK_Y. KeyEvent ke = new KeyEvent(nativeEvent, nativeEvent.getWhen(), - peAction, peModifiers, + peAction, modifiers, keyChar, keyCode, nativeEvent.isAutoRepeat()); @@ -1216,7 +1219,7 @@ public class PSurfaceJOGL implements PSurface { // Create key typed event // TODO: combine dead keys with the following key KeyEvent tke = new KeyEvent(nativeEvent, nativeEvent.getWhen(), - KeyEvent.TYPE, peModifiers, + KeyEvent.TYPE, modifiers, keyChar, 0, nativeEvent.isAutoRepeat()); diff --git a/core/todo.txt b/core/todo.txt index 08ab4ed05..c54e587d3 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -15,6 +15,13 @@ X move loadImage() into ShimAWT X desktopFile() and desktopPath() methods are supported, unless we find they're trouble X move ShimAWT.loadImage() to the PSurface subclasses X move all java.awt and javax.imageio out of PImage +X make the switch to getModifiersEx() instead of getModifiers() +X pass all modifiers to the KeyEvent and MouseEvent constructors +X though they aren't even being stored, so what's the point? + +contribs +X remove redundant boxing and casting +X https://github.com/processing/processing4/pull/51 api changes _ static versions of selectInput/selectOutput/selectFolder in PApplet have been removed @@ -22,6 +29,8 @@ _ java.awt.Frame object "frame" removed from PApplet (been warning since 2015) _ protected PImage.checkAlpha() now public _ all AWT calls have been moved out of PImage _ this may be a problem for anything that was relying on those internals +_ removed MouseEvent.getClickCount() and MouseEvent.getAmount() +_ these had been deprecated, not clear they were used anywhere api todo _ Surface not available inside handleSettings()