diff options
author | Sven Gothel <[email protected]> | 2014-05-21 08:53:54 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-05-21 08:53:54 +0200 |
commit | f9a00b91dcd146c72a50237b62270f33bd0da98e (patch) | |
tree | f4387da868608cea5066ce3a8cb9039a16b529de /src/newt | |
parent | 0ffba122ea5c4b8cc247234ca9f48ccfcce833cd (diff) |
Bug 742 HiDPI: [Core API Change] Distinguish window-units and pixel-units; Add HiDPI for AWT GLCanvas w/ OSX CALayer
Core API Change:
To support HiDPI thoroughly in JOGL (NativeWindow, JOGL, NEWT)
we need to separate window- and pixel units.
NativeWindow and NativeSurface now have distinguished
access methods for window units and pixel units.
NativeWindow: Using window units
- getWindowWidth() * NEW Method *
- getWindowHeight() * NEW Method *
- getX(), getY(), ...
NativeSurface: Using pixel units
- getWidth() -> getSurfaceWidth() * RENAMED *
- getHeight() -> getSurfaceHeight() * RENAMED *
GLDrawable: Using pixel units
- getWidth() -> getSurfaceWidth() * RENAMED, aligned w/ NativeSurface *
- getHeight() -> getSurfaceHeight() * RENAMED, aligned w/ NativeSurface *
Above changes also removes API collision w/ other windowing TK,
e.g. AWT's getWidth()/getHeight() in GLCanvas
and the same method names in GLDrawable before this change.
+++
Now preliminary 'working':
- AWT GLCanvas
- AWT GLJPanel
Tested manually on OSX w/ and w/o HiDPI Retina:
java com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT -manual -noanim -time 1000000
java com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT -manual -noanim -time 1000000
+++
TODO:
- NEWT
- Change Window.setSize(..) to use pixel units ?
- OSX HiDPI support
- Testing ..
- API refinement
Diffstat (limited to 'src/newt')
22 files changed, 239 insertions, 134 deletions
diff --git a/src/newt/classes/com/jogamp/newt/NewtFactory.java b/src/newt/classes/com/jogamp/newt/NewtFactory.java index 9685200eb..3b31861f0 100644 --- a/src/newt/classes/com/jogamp/newt/NewtFactory.java +++ b/src/newt/classes/com/jogamp/newt/NewtFactory.java @@ -296,7 +296,7 @@ public class NewtFactory { } final Window win = WindowImpl.create(parentWindow, 0, screen, caps); - win.setSize(parentWindow.getWidth(), parentWindow.getHeight()); + win.setSize(parentWindow.getSurfaceWidth(), parentWindow.getSurfaceHeight()); if ( null != newtParentWindow ) { newtParentWindow.addChild(win); win.setVisible(newtParentWindow.isVisible()); diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index 4816e62e5..9cf67c56f 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -232,7 +232,7 @@ public interface Window extends NativeWindow, WindowClosingProtocol { // /** - * Sets the size of the window's client area, excluding decorations. + * Sets the size of the window's client area in window units, excluding decorations. * * <p> * Zero size semantics are respected, see {@link #setVisible(boolean)}:<br> @@ -248,22 +248,22 @@ public interface Window extends NativeWindow, WindowClosingProtocol { * <p> * This call is ignored if in fullscreen mode.<br></p> * - * @param width of the window's client area - * @param height of the window's client area + * @param width of the window's client area in window units + * @param height of the window's client area in window units * * @see #getInsets() */ void setSize(int width, int height); /** - * Sets the size of the top-level window including insets (window decorations). + * Sets the size of the top-level window including insets (window decorations) in window units. * * <p> * Note: Insets (if supported) are available only after the window is set visible and hence has been created. * </p> * - * @param width of the top-level window area - * @param height of the top-level window area + * @param width of the top-level window area in window units + * @param height of the top-level window area in window units * * @see #setSize(int, int) * @see #getInsets() @@ -271,19 +271,19 @@ public interface Window extends NativeWindow, WindowClosingProtocol { void setTopLevelSize(int width, int height); /** - * Sets the location of the window's client area, excluding insets (window decorations).<br> + * Sets the location of the window's client area excluding insets (window decorations) in window units.<br> * * This call is ignored if in fullscreen mode.<br> * - * @param x coord of the client-area's top left corner - * @param y coord of the client-area's top left corner + * @param x coord of the client-area's top left corner in window units + * @param y coord of the client-area's top left corner in window units * * @see #getInsets() */ void setPosition(int x, int y); /** - * Sets the location of the top-level window inclusive insets (window decorations).<br> + * Sets the location of the top-level window inclusive insets (window decorations) in window units.<br> * * <p> * Note: Insets (if supported) are available only after the window is set visible and hence has been created. @@ -291,8 +291,8 @@ public interface Window extends NativeWindow, WindowClosingProtocol { * * This call is ignored if in fullscreen mode.<br> * - * @param x coord of the top-level left corner - * @param y coord of the top-level left corner + * @param x coord of the top-level left corner in window units + * @param y coord of the top-level left corner in window units * * @see #setPosition(int, int) * @see #getInsets() @@ -356,10 +356,10 @@ public interface Window extends NativeWindow, WindowClosingProtocol { void confinePointer(boolean confine); /** - * Moves the pointer to x/y relative to this window's origin. + * Moves the pointer to x/y relative to this window's origin in pixel units. * - * @param x relative pointer x position within this window - * @param y relative pointer y position within this window + * @param x relative pointer x position within this window in pixel units + * @param y relative pointer y position within this window in pixel units * * @see #confinePointer(boolean) */ @@ -431,8 +431,8 @@ public interface Window extends NativeWindow, WindowClosingProtocol { * this window is added to it's list of children.<br></P> * * @param newParent The new parent NativeWindow. If null, this Window becomes a top level window. - * @param x new top-level position, use -1 for default position. - * @param y new top-level position, use -1 for default position. + * @param x new top-level position in window units, use -1 for default position. + * @param y new top-level position in window units, use -1 for default position. * @param hints May contain hints (bitfield values) like {@link #REPARENT_HINT_FORCE_RECREATION} or {@link #REPARENT_HINT_BECOMES_VISIBLE}. * * @return The issued reparent action type (strategy) as defined in Window.ReparentAction @@ -520,6 +520,13 @@ public interface Window extends NativeWindow, WindowClosingProtocol { */ void requestFocus(boolean wait); + /** + * Trigger window repaint while passing the dirty region in pixel units. + * @param x dirty-region y-pos in pixel units + * @param y dirty-region x-pos in pixel units + * @param width dirty-region width in pixel units + * @param height dirty-region height in pixel units + */ void windowRepaint(int x, int y, int width, int height); void enqueueEvent(boolean wait, com.jogamp.newt.event.NEWTEvent event); diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index f0cc68903..891843cb7 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -400,7 +400,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto final Window w = newtChild; if( null != w ) { // use NEWT child's size for min/pref size! - java.awt.Dimension minSize = new java.awt.Dimension(w.getWidth(), w.getHeight()); + java.awt.Dimension minSize = new java.awt.Dimension(w.getSurfaceWidth(), w.getSurfaceHeight()); setMinimumSize(minSize); setPreferredSize(minSize); } @@ -645,8 +645,8 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto final int printNumSamples = printAWTTiles.getNumSamples(caps); GLDrawable printDrawable = printGLAD.getDelegatedDrawable(); final boolean reqNewGLADSamples = printNumSamples != caps.getNumSamples(); - final boolean reqNewGLADSize = printAWTTiles.customTileWidth != -1 && printAWTTiles.customTileWidth != printDrawable.getWidth() || - printAWTTiles.customTileHeight != -1 && printAWTTiles.customTileHeight != printDrawable.getHeight(); + final boolean reqNewGLADSize = printAWTTiles.customTileWidth != -1 && printAWTTiles.customTileWidth != printDrawable.getSurfaceWidth() || + printAWTTiles.customTileHeight != -1 && printAWTTiles.customTileHeight != printDrawable.getSurfaceHeight(); final boolean reqNewGLADOnscrn = caps.isOnscreen(); // It is desired to use a new offscreen GLAD, however Bug 830 forbids this for AA onscreen context. @@ -654,7 +654,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto final boolean reqNewGLAD = !caps.getSampleBuffers() && ( reqNewGLADOnscrn || reqNewGLADSamples || reqNewGLADSize ); if( DEBUG ) { System.err.println("AWT print.setup: reqNewGLAD "+reqNewGLAD+"[ onscreen "+reqNewGLADOnscrn+", samples "+reqNewGLADSamples+", size "+reqNewGLADSize+"], "+ - ", drawableSize "+printDrawable.getWidth()+"x"+printDrawable.getHeight()+ + ", drawableSize "+printDrawable.getSurfaceWidth()+"x"+printDrawable.getSurfaceHeight()+ ", customTileSize "+printAWTTiles.customTileWidth+"x"+printAWTTiles.customTileHeight+ ", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+ ", numSamples "+printAWTTiles.customNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator); @@ -674,13 +674,13 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto printDrawable = printGLAD.getDelegatedDrawable(); } printAWTTiles.setGLOrientation(printGLAD.isGLOriented(), printGLAD.isGLOriented()); - printAWTTiles.renderer.setTileSize(printDrawable.getWidth(), printDrawable.getHeight(), 0); + printAWTTiles.renderer.setTileSize(printDrawable.getSurfaceWidth(), printDrawable.getSurfaceHeight(), 0); printAWTTiles.renderer.attachAutoDrawable(printGLAD); if( DEBUG ) { System.err.println("AWT print.setup "+printAWTTiles); System.err.println("AWT print.setup AA "+printNumSamples+", "+caps); - System.err.println("AWT print.setup printGLAD: "+printGLAD.getWidth()+"x"+printGLAD.getHeight()+", "+printGLAD); - System.err.println("AWT print.setup printDraw: "+printDrawable.getWidth()+"x"+printDrawable.getHeight()+", "+printDrawable); + System.err.println("AWT print.setup printGLAD: "+printGLAD.getSurfaceWidth()+"x"+printGLAD.getSurfaceHeight()+", "+printGLAD); + System.err.println("AWT print.setup printDraw: "+printDrawable.getSurfaceWidth()+"x"+printDrawable.getSurfaceHeight()+", "+printDrawable); } } } diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java index fb74b5a09..43cac31bb 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java @@ -42,6 +42,11 @@ package com.jogamp.newt.event; * <p> * http://www.w3.org/Submission/pointer-events/#pointerevent-interface * </p> + * <a name="coordUnit"><h5>Unit of Coordinates</h5></a> + * <p> + * All pointer coordinates of this interface are represented in pixel units, + * see {@link NativeSurface} and {@link NativeWindow}. + * </p> * <a name="multiPtrEvent"><h5>Multiple-Pointer Events</h5></a> * <p> * In case an instance represents a multiple-pointer event, i.e. {@link #getPointerCount()} is > 1, @@ -349,10 +354,18 @@ public class MouseEvent extends InputEvent return clickCount; } + /** + * See details for <a href="#multiPtrEvent">multiple-pointer events</a>. + * @return X-Coord of the triggering pointer-index zero in pixel units. + */ public final int getX() { return x[0]; } + /** + * See details for <a href="#multiPtrEvent">multiple-pointer events</a>. + * @return Y-Coord of the triggering pointer-index zero in pixel units. + */ public final int getY() { return y[0]; } @@ -360,7 +373,7 @@ public class MouseEvent extends InputEvent /** * See details for <a href="#multiPtrEvent">multiple-pointer events</a>. * @param index pointer-index within [0 .. {@link #getPointerCount()}-1] - * @return X-Coord associated with the pointer-index. + * @return X-Coord associated with the pointer-index in pixel units. * @see getPointerId(index) */ public final int getX(final int index) { @@ -370,7 +383,7 @@ public class MouseEvent extends InputEvent /** * See details for <a href="#multiPtrEvent">multiple-pointer events</a>. * @param index pointer-index within [0 .. {@link #getPointerCount()}-1] - * @return Y-Coord associated with the pointer-index. + * @return Y-Coord associated with the pointer-index in pixel units. * @see getPointerId(index) */ public final int getY(final int index) { @@ -379,7 +392,7 @@ public class MouseEvent extends InputEvent /** * See details for <a href="#multiPtrEvent">multiple-pointer events</a>. - * @return array of all X-Coords for all pointers + * @return array of all X-Coords for all pointers in pixel units. */ public final int[] getAllX() { return x; @@ -387,7 +400,7 @@ public class MouseEvent extends InputEvent /** * See details for <a href="#multiPtrEvent">multiple-pointer events</a>. - * @return array of all Y-Coords for all pointers + * @return array of all Y-Coords for all pointers in pixel units. */ public final int[] getAllY() { return y; diff --git a/src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java b/src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java index 7d22128cf..1521036d6 100644 --- a/src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java +++ b/src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java @@ -173,7 +173,7 @@ public class PinchToZoomGesture implements GestureHandler { } final int eventType = pe.getEventType(); - final boolean useY = surface.getWidth() >= surface.getHeight(); // use smallest dimension + final boolean useY = surface.getSurfaceWidth() >= surface.getSurfaceHeight(); // use smallest dimension switch ( eventType ) { case MouseEvent.EVENT_MOUSE_PRESSED: { if( 1 == pointerDownCount ) { @@ -221,7 +221,7 @@ public class PinchToZoomGesture implements GestureHandler { } else if( zoomMode ) { final int d = Math.abs(edge0-edge1); final int dd = d - zoomLastEdgeDist; - final float screenEdge = useY ? surface.getHeight() : surface.getWidth(); + final float screenEdge = useY ? surface.getSurfaceHeight() : surface.getSurfaceWidth(); final float delta = dd / screenEdge; // [-1..1] if(DEBUG) { System.err.println("XXX2: id0 "+pIds[0]+" -> idx0 "+p0Idx+", id1 "+pIds[1]+" -> idx1 "+p1Idx); diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 4b740927b..c4a5fcab1 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -130,7 +130,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind @Override public void windowResized(WindowEvent e) { - defaultWindowResizedOp(getWidth(), getHeight()); + defaultWindowResizedOp(getSurfaceWidth(), getSurfaceHeight()); } }); @@ -353,13 +353,33 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind } @Override - public final int getWidth() { - return window.getWidth(); + public final int getWindowWidth() { + return window.getWindowWidth(); } @Override - public final int getHeight() { - return window.getHeight(); + public final int getWindowHeight() { + return window.getWindowHeight(); + } + + @Override + public final int[] getWindowUnitXY(int[] result, final int[] pixelUnitXY) { + return window.getWindowUnitXY(result, pixelUnitXY); + } + + @Override + public final int[] getPixelUnitXY(int[] result, final int[] windowUnitXY) { + return window.getPixelUnitXY(result, windowUnitXY); + } + + @Override + public final int getSurfaceWidth() { + return window.getSurfaceWidth(); + } + + @Override + public final int getSurfaceHeight() { + return window.getSurfaceHeight(); } @Override @@ -516,7 +536,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind t0 = 0; } - if (null == drawable && visible && 0 != window.getWindowHandle() && 0<getWidth()*getHeight()) { + if (null == drawable && visible && 0 != window.getWindowHandle() && 0<getSurfaceWidth()*getSurfaceHeight()) { if( ( null != context ) ) { throw new InternalError("GLWindow.LifecycleHook.setVisiblePost: "+WindowImpl.getThreadName()+" - Null drawable, but valid context - "+GLWindow.this); } @@ -626,7 +646,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind } finally { lock.unlock(); } - if( !done && ( 0 < getWidth() && 0 < getHeight() ) ) { + if( !done && ( 0 < getSurfaceWidth() && 0 < getSurfaceHeight() ) ) { // retry drawable and context creation, will itself issue resize -> display setVisible(true); } diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java index 6f4be75f5..ee01212cb 100644 --- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java +++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java @@ -460,12 +460,38 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { } @Override - public int getWidth() { + public int getWindowWidth() { + return getSurfaceWidth(); // FIXME: Use 'scale' or an actual window-width + } + + @Override + public int getWindowHeight() { + return getSurfaceHeight(); // FIXME: Use 'scale' or an actual window-width + } + + @Override + public final int[] getWindowUnitXY(int[] result, final int[] pixelUnitXY) { + final int scale = 1; // FIXME: Use 'scale' .. + result[0] = pixelUnitXY[0] / scale; + result[1] = pixelUnitXY[1] / scale; + return result; + } + + @Override + public final int[] getPixelUnitXY(int[] result, final int[] windowUnitXY) { + final int scale = 1; // FIXME: Use 'scale' .. + result[0] = windowUnitXY[0] * scale; + result[1] = windowUnitXY[1] * scale; + return result; + } + + @Override + public int getSurfaceWidth() { return clientArea.width; } @Override - public int getHeight() { + public int getSurfaceHeight() { return clientArea.height; } diff --git a/src/newt/classes/com/jogamp/newt/util/applet/JOGLNewtApplet3Run.java b/src/newt/classes/com/jogamp/newt/util/applet/JOGLNewtApplet3Run.java index 8123126ee..8a3e5616d 100644 --- a/src/newt/classes/com/jogamp/newt/util/applet/JOGLNewtApplet3Run.java +++ b/src/newt/classes/com/jogamp/newt/util/applet/JOGLNewtApplet3Run.java @@ -44,7 +44,7 @@ import javax.media.opengl.FPSCounter; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; -import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSizePos; +import com.jogamp.nativewindow.UpstreamWindowHookMutableSizePos; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Window; import com.jogamp.newt.opengl.GLWindow; @@ -103,7 +103,7 @@ public class JOGLNewtApplet3Run implements Applet3 { int glXd=Integer.MAX_VALUE, glYd=Integer.MAX_VALUE, glWidth=Integer.MAX_VALUE, glHeight=Integer.MAX_VALUE; Applet3Context ctx; boolean glStandalone = false; - UpstreamSurfaceHookMutableSizePos upstreamSizePosHook; + UpstreamWindowHookMutableSizePos upstreamSizePosHook; PointImmutable upstreamLocOnScreen; NativeWindow browserWin; @@ -147,8 +147,9 @@ public class JOGLNewtApplet3Run implements Applet3 { final AbstractGraphicsDevice aDevice = NativeWindowFactory.createDevice(upstreamWin.getDisplayConnection(), true /* own */); // open and own! (for upstreamLocOnScreen) final AbstractGraphicsScreen aScreen = NativeWindowFactory.createScreen(aDevice, upstreamWin.getScreenIndex()); - upstreamSizePosHook = new UpstreamSurfaceHookMutableSizePos(upstreamWin.getX(), upstreamWin.getY(), - upstreamWin.getWidth(), upstreamWin.getHeight()); + upstreamSizePosHook = new UpstreamWindowHookMutableSizePos(upstreamWin.getX(), upstreamWin.getY(), + upstreamWin.getWidth(), upstreamWin.getHeight(), + upstreamWin.getWidth(), upstreamWin.getHeight()); // FIXME: pixel-dim == window-dim 'for now' ? browserWin = NativeWindowFactory.createWrappedWindow(aScreen, 0 /* surfaceHandle */, upstreamWin.getWindowHandle(), upstreamSizePosHook); upstreamLocOnScreen = NativeWindowFactory.getLocationOnScreen(browserWin); @@ -171,7 +172,7 @@ public class JOGLNewtApplet3Run implements Applet3 { glWindow = GLWindow.create(w); glWindow.setUndecorated(glUndecorated); glWindow.setAlwaysOnTop(glAlwaysOnTop); - glWindow.setSize(browserWin.getWidth(), browserWin.getHeight()); + glWindow.setSize(browserWin.getSurfaceWidth(), browserWin.getSurfaceHeight()); return new NativeWindowDownstream() { @Override @@ -183,7 +184,7 @@ public class JOGLNewtApplet3Run implements Applet3 { @Override public void setSize(int width, int height) { - upstreamSizePosHook.setSize(width, height); + upstreamSizePosHook.setPixelSize(width, height); if( null != glWindow ) { glWindow.setSize(width, height); } @@ -226,7 +227,7 @@ public class JOGLNewtApplet3Run implements Applet3 { @Override public void notifyPositionChanged(NativeWindowUpstream nw) { - upstreamSizePosHook.setPos(nw.getX(), nw.getY()); + upstreamSizePosHook.setWinPos(nw.getX(), nw.getY()); if( null != glWindow ) { glWindow.setPosition(nw.getX(), nw.getY()); } diff --git a/src/newt/classes/com/jogamp/newt/util/applet/JOGLNewtAppletBase.java b/src/newt/classes/com/jogamp/newt/util/applet/JOGLNewtAppletBase.java index bbe6b8527..eee8ab23e 100644 --- a/src/newt/classes/com/jogamp/newt/util/applet/JOGLNewtAppletBase.java +++ b/src/newt/classes/com/jogamp/newt/util/applet/JOGLNewtAppletBase.java @@ -377,7 +377,7 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { new Thread() { public void run() { System.err.println("[set mouse pos pre]"); - glWindow.warpPointer(glWindow.getWidth()/2, glWindow.getHeight()/2); + glWindow.warpPointer(glWindow.getSurfaceWidth()/2, glWindow.getSurfaceHeight()/2); System.err.println("[set mouse pos post]"); } }.start(); } diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index afb1ad020..a9fc28a33 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -148,8 +148,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private volatile long windowHandle = 0; // lifecycle critical private volatile boolean visible = false; // lifecycle critical private volatile boolean hasFocus = false; - private volatile int width = 128, height = 128; // client-area size w/o insets, default: may be overwritten by user - private volatile int x = 64, y = 64; // client-area pos w/o insets + private volatile int pixWidth = 128, pixHeight = 128; // client-area size w/o insets in pixel units, default: may be overwritten by user + private volatile int winWidth = 128, winHeight = 128; // client-area size w/o insets in window units, default: may be overwritten by user + private volatile int x = 64, y = 64; // client-area pos w/o insets in window units private volatile Insets insets = new Insets(); // insets of decoration (if top-level && decorated) private boolean blockInsetsChange = false; // block insets change (from same thread) @@ -910,7 +911,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer @Override public final MonitorDevice getMainMonitor() { - return screen.getMainMonitor(new Rectangle(getX(), getY(), getWidth(), getHeight())); + return screen.getMainMonitor(new Rectangle(getX(), getY(), getSurfaceWidth(), getSurfaceHeight())); } protected final void setVisibleImpl(boolean visible, int x, int y, int width, int height) { @@ -934,7 +935,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } if(!isNativeValid() && visible) { - if( 0<getWidth()*getHeight() ) { + if( 0<getSurfaceWidth()*getSurfaceHeight() ) { nativeWindowCreated = createNative(); madeVisible = nativeWindowCreated; } @@ -942,7 +943,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer WindowImpl.this.visible = true; } else if(WindowImpl.this.visible != visible) { if(isNativeValid()) { - setVisibleImpl(visible, getX(), getY(), getWidth(), getHeight()); + setVisibleImpl(visible, getX(), getY(), getSurfaceWidth(), getSurfaceHeight()); WindowImpl.this.waitForVisible(visible, false); madeVisible = visible; } else { @@ -965,7 +966,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } if(DEBUG_IMPLEMENTATION) { - System.err.println("Window setVisible: END ("+getThreadName()+") "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible: "+WindowImpl.this.visible+", nativeWindowCreated: "+nativeWindowCreated+", madeVisible: "+madeVisible); + System.err.println("Window setVisible: END ("+getThreadName()+") "+getX()+"/"+getY()+" "+getSurfaceWidth()+"x"+getSurfaceHeight()+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible: "+WindowImpl.this.visible+", nativeWindowCreated: "+nativeWindowCreated+", madeVisible: "+madeVisible); } } finally { if(null!=lifecycleHook) { @@ -993,7 +994,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer @Override public final void setVisible(boolean wait, boolean visible) { if(DEBUG_IMPLEMENTATION) { - System.err.println("Window setVisible: START ("+getThreadName()+") "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible: "+this.visible+" -> "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+(null!=parentWindow)); + System.err.println("Window setVisible: START ("+getThreadName()+") "+getX()+"/"+getY()+" "+getSurfaceWidth()+"x"+getSurfaceHeight()+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible: "+this.visible+" -> "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+(null!=parentWindow)); } runOnEDTIfAvail(wait, new VisibleAction(visible)); } @@ -1018,9 +1019,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer final RecursiveLock _lock = windowLock; _lock.lock(); try { - if ( ( disregardFS || !isFullscreen() ) && ( getWidth() != width || getHeight() != height ) ) { + if ( ( disregardFS || !isFullscreen() ) && ( getSurfaceWidth() != width || getSurfaceHeight() != height ) ) { if(DEBUG_IMPLEMENTATION) { - System.err.println("Window setSize: START "+getWidth()+"x"+getHeight()+" -> "+width+"x"+height+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible "+visible); + System.err.println("Window setSize: START "+getSurfaceWidth()+"x"+getSurfaceHeight()+" -> "+width+"x"+height+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible "+visible); } int visibleAction; // 0 nop, 1 invisible, 2 visible (create) if ( visible && isNativeValid() && ( 0 >= width || 0 >= height ) ) { @@ -1040,7 +1041,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer defineSize(width, height); } if(DEBUG_IMPLEMENTATION) { - System.err.println("Window setSize: END "+getWidth()+"x"+getHeight()+", visibleAction "+visibleAction); + System.err.println("Window setSize: END "+getSurfaceWidth()+"x"+getSurfaceHeight()+", visibleAction "+visibleAction); } switch(visibleAction) { case 1: setVisibleActionImpl(false); break; @@ -1247,8 +1248,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // mirror pos/size so native change notification can get overwritten final int oldX = getX(); final int oldY = getY(); - final int oldWidth = getWidth(); - final int oldHeight = getHeight(); + final int oldWidth = getSurfaceWidth(); + final int oldHeight = getSurfaceHeight(); final int x, y; int width = oldWidth; int height = oldHeight; @@ -1299,11 +1300,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer y = 0; // refit if size is bigger than parent - if( width > newParentWindow.getWidth() ) { - width = newParentWindow.getWidth(); + if( width > newParentWindow.getSurfaceWidth() ) { + width = newParentWindow.getSurfaceWidth(); } - if( height > newParentWindow.getHeight() ) { - height = newParentWindow.getHeight(); + if( height > newParentWindow.getSurfaceHeight() ) { + height = newParentWindow.getSurfaceHeight(); } // Case: Child Window @@ -1510,7 +1511,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.reparent: END-1 ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+", visible: "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+ Display.hashCodeNullSafe(parentWindow)+" "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()); + System.err.println("Window.reparent: END-1 ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+", visible: "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+ Display.hashCodeNullSafe(parentWindow)+" "+getX()+"/"+getY()+" "+getSurfaceWidth()+"x"+getSurfaceHeight()); } } finally { if(null!=lifecycleHook) { @@ -1534,7 +1535,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.reparent: END-X ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+", visible: "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+ Display.hashCodeNullSafe(parentWindow)+" "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()); + System.err.println("Window.reparent: END-X ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+", visible: "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+ Display.hashCodeNullSafe(parentWindow)+" "+getX()+"/"+getY()+" "+getSurfaceWidth()+"x"+getSurfaceHeight()); } } } @@ -1611,8 +1612,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // Mirror pos/size so native change notification can get overwritten final int x = getX(); final int y = getY(); - final int width = getWidth(); - final int height = getHeight(); + final int width = getSurfaceWidth(); + final int height = getSurfaceHeight(); DisplayImpl display = (DisplayImpl) screen.getDisplay(); display.dispatchMessagesNative(); // status up2date @@ -1657,8 +1658,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // Mirror pos/size so native change notification can get overwritten final int x = getX(); final int y = getY(); - final int width = getWidth(); - final int height = getHeight(); + final int width = getSurfaceWidth(); + final int height = getSurfaceHeight(); DisplayImpl display = (DisplayImpl) screen.getDisplay(); display.dispatchMessagesNative(); // status up2date @@ -1823,7 +1824,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(!setVal) { if(confine) { requestFocus(); - warpPointer(getWidth()/2, getHeight()/2); + warpPointer(getSurfaceWidth()/2, getSurfaceHeight()/2); } setVal = confinePointerImpl(confine); if(confine) { @@ -1857,13 +1858,39 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public final int getWidth() { - return width; + public final int getSurfaceWidth() { + return pixWidth; } @Override - public final int getHeight() { - return height; + public final int getSurfaceHeight() { + return pixHeight; + } + + @Override + public final int getWindowWidth() { + return getSurfaceWidth(); // FIXME: Use 'scale' or an actual pixel-width + } + + @Override + public final int getWindowHeight() { + return getSurfaceHeight(); // FIXME: Use 'scale' or an actual pixel-width + } + + @Override + public final int[] getWindowUnitXY(int[] result, final int[] pixelUnitXY) { + final int scale = 1; // FIXME: Use 'scale' .. + result[0] = pixelUnitXY[0] / scale; + result[1] = pixelUnitXY[1] / scale; + return result; + } + + @Override + public final int[] getPixelUnitXY(int[] result, final int[] windowUnitXY) { + final int scale = 1; // FIXME: Use 'scale' .. + result[0] = windowUnitXY[0] * scale; + result[1] = windowUnitXY[1] * scale; + return result; } @Override @@ -1888,13 +1915,13 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer this.x = x; this.y = y; } - /** Sets the size fields {@link #width} and {@link #height} to the given values. */ + /** Sets the size fields {@link #pixWidth} and {@link #pixHeight} to the given values. */ protected final void defineSize(int width, int height) { if(DEBUG_IMPLEMENTATION) { - System.err.println("defineSize: "+this.width+"x"+this.height+" -> "+width+"x"+height); + System.err.println("defineSize: "+this.pixWidth+"x"+this.pixHeight+" -> "+width+"x"+height); // Thread.dumpStack(); } - this.width = width; this.height = height; + this.pixWidth = width; this.pixHeight = height; } @Override @@ -1965,7 +1992,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer "\n, ParentWindowHandle "+toHexString(parentWindowHandle)+" ("+(0!=getParentWindowHandle())+")"+ "\n, WindowHandle "+toHexString(getWindowHandle())+ "\n, SurfaceHandle "+toHexString(getSurfaceHandle())+ " (lockedExt window "+windowLock.isLockedByOtherThread()+", surface "+isSurfaceLockedByOtherThread()+")"+ - "\n, Pos "+getX()+"/"+getY()+" (auto "+autoPosition()+"), size "+getWidth()+"x"+getHeight()+ + "\n, Pos "+getX()+"/"+getY()+" (auto "+autoPosition()+"), size "+getSurfaceWidth()+"x"+getSurfaceHeight()+ "\n, Visible "+isVisible()+", focus "+hasFocus()+ "\n, Undecorated "+undecorated+" ("+isUndecorated()+")"+ "\n, AlwaysOnTop "+alwaysOnTop+", Fullscreen "+fullscreen+ @@ -2111,7 +2138,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if ( !isFullscreen() && ( getX() != x || getY() != y || null != getParent()) ) { if(isNativeValid()) { // this.x/this.y will be set by sizeChanged, triggered by windowing event system - reconfigureWindowImpl(x, y, getWidth(), getHeight(), getReconfigureFlags(0, isVisible())); + reconfigureWindowImpl(x, y, getSurfaceWidth(), getSurfaceHeight(), getReconfigureFlags(0, isVisible())); if( null == parentWindow ) { // Wait until custom position is reached within tolerances waitForPosition(true, x, y, Window.TIMEOUT_NATIVEWINDOW); @@ -2159,8 +2186,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer try { final int oldX = getX(); final int oldY = getY(); - final int oldWidth = getWidth(); - final int oldHeight = getHeight(); + final int oldWidth = getSurfaceWidth(); + final int oldHeight = getSurfaceHeight(); int x,y,w,h; @@ -2213,11 +2240,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer y = 0; // refit if size is bigger than parent - if( w > parentWindow.getWidth() ) { - w = parentWindow.getWidth(); + if( w > parentWindow.getSurfaceWidth() ) { + w = parentWindow.getSurfaceWidth(); } - if( h > parentWindow.getHeight() ) { - h = parentWindow.getHeight(); + if( h > parentWindow.getSurfaceHeight() ) { + h = parentWindow.getSurfaceHeight(); } } } @@ -2388,10 +2415,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // Simply move/resize window to fit in virtual screen if required final RectangleImmutable viewport = screen.getViewport(); if( viewport.getWidth() > 0 && viewport.getHeight() > 0 ) { // failsafe - final RectangleImmutable rect = new Rectangle(getX(), getY(), getWidth(), getHeight()); + final RectangleImmutable rect = new Rectangle(getX(), getY(), getSurfaceWidth(), getSurfaceHeight()); final RectangleImmutable isect = viewport.intersection(rect); - if ( getHeight() > isect.getHeight() || - getWidth() > isect.getWidth() ) { + if ( getSurfaceHeight() > isect.getHeight() || + getSurfaceWidth() > isect.getWidth() ) { if(DEBUG_IMPLEMENTATION) { System.err.println("Window.monitorModeChanged: fit window "+rect+" into screen viewport "+viewport+ ", due to minimal intersection "+isect); @@ -2414,7 +2441,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if( fullscreenMonitors.contains(md) ) { final RectangleImmutable viewport = MonitorDevice.unionOfViewports(new Rectangle(), fullscreenMonitors); if(DEBUG_IMPLEMENTATION) { - final RectangleImmutable rect = new Rectangle(getX(), getY(), getWidth(), getHeight()); + final RectangleImmutable rect = new Rectangle(getX(), getY(), getSurfaceWidth(), getSurfaceHeight()); System.err.println("Window.monitorModeChanged: FS Monitor Match: Fit window "+rect+" into new viewport union "+viewport+", provoked by "+md); } definePosition(viewport.getX(), viewport.getY()); // set pos for setVisible(..) or createNative(..) - reduce EDT roundtrip @@ -2735,7 +2762,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // int x = pX[0]; int y = pY[0]; - final boolean insideWindow = x >= 0 && y >= 0 && x < getWidth() && y < getHeight(); + final boolean insideWindow = x >= 0 && y >= 0 && x < getSurfaceWidth() && y < getSurfaceHeight(); final Point movePositionP0 = pState1.getMovePosition(pID[0]); switch( eventType ) { case MouseEvent.EVENT_MOUSE_EXITED: @@ -2774,8 +2801,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return; } // clip coordinates to window dimension - x = Math.min(Math.max(x, 0), getWidth()-1); - y = Math.min(Math.max(y, 0), getHeight()-1); + x = Math.min(Math.max(x, 0), getSurfaceWidth()-1); + y = Math.min(Math.max(y, 0), getSurfaceHeight()-1); break; case MouseEvent.EVENT_MOUSE_MOVED: @@ -2938,7 +2965,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer int y = pe.getY(); if(DEBUG_MOUSE_EVENT) { - System.err.println("consumePointerEvent.in: "+pe+", "+pState0+", pos "+x+"/"+y+" clientSize["+getWidth()+"x"+getHeight()+"]"); + System.err.println("consumePointerEvent.in: "+pe+", "+pState0+", pos "+x+"/"+y+", win["+getX()+"/"+getY()+" "+getWindowWidth()+"x"+getWindowHeight()+ + "], pixel["+getSurfaceWidth()+"x"+getSurfaceHeight()+"]"); } // @@ -2962,8 +2990,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // Fall through intended ! case MouseEvent.EVENT_MOUSE_ENTERED: // clip coordinates to window dimension - x = Math.min(Math.max(x, 0), getWidth()-1); - y = Math.min(Math.max(y, 0), getHeight()-1); + x = Math.min(Math.max(x, 0), getSurfaceWidth()-1); + y = Math.min(Math.max(y, 0), getSurfaceHeight()-1); pState0.clearButton(); if( eventType == MouseEvent.EVENT_MOUSE_ENTERED ) { insideWindow = true; @@ -2986,20 +3014,20 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // Fall through intended ! default: - insideWindow = x >= 0 && y >= 0 && x < getWidth() && y < getHeight(); + insideWindow = x >= 0 && y >= 0 && x < getSurfaceWidth() && y < getWindowHeight(); if( pe.getPointerType(0) == PointerType.Mouse ) { if( !pState0.insideWindow && insideWindow ) { // ENTER .. use clipped coordinates eEntered = new MouseEvent(MouseEvent.EVENT_MOUSE_ENTERED, pe.getSource(), pe.getWhen(), pe.getModifiers(), - Math.min(Math.max(x, 0), getWidth()-1), - Math.min(Math.max(y, 0), getHeight()-1), + Math.min(Math.max(x, 0), getSurfaceWidth()-1), + Math.min(Math.max(y, 0), getSurfaceHeight()-1), (short)0, (short)0, pe.getRotation(), pe.getRotationScale()); pState0.exitSent = false; } else if( !insideWindow && eExitAllowed ) { // EXIT .. use clipped coordinates eExited = new MouseEvent(MouseEvent.EVENT_MOUSE_EXITED, pe.getSource(), pe.getWhen(), pe.getModifiers(), - Math.min(Math.max(x, 0), getWidth()-1), - Math.min(Math.max(y, 0), getHeight()-1), + Math.min(Math.max(x, 0), getSurfaceWidth()-1), + Math.min(Math.max(y, 0), getSurfaceHeight()-1), (short)0, (short)0, pe.getRotation(), pe.getRotationScale()); pState0.exitSent = true; } @@ -3505,7 +3533,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer protected void consumeWindowEvent(WindowEvent e) { if(DEBUG_IMPLEMENTATION) { - System.err.println("consumeWindowEvent: "+e+", visible "+isVisible()+" "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()); + System.err.println("consumeWindowEvent: "+e+", visible "+isVisible()+" "+getX()+"/"+getY()+", win["+getX()+"/"+getY()+" "+getWindowWidth()+"x"+getWindowHeight()+ + "], pixel["+getSurfaceWidth()+"x"+getSurfaceHeight()+"]"); } for(int i = 0; !e.isConsumed() && i < windowListeners.size(); i++ ) { WindowListener l = windowListeners.get(i); @@ -3597,9 +3626,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer /** Triggered by implementation's WM events to update the client-area size w/o insets/decorations. */ protected void sizeChanged(boolean defer, int newWidth, int newHeight, boolean force) { - if(force || getWidth() != newWidth || getHeight() != newHeight) { + if(force || getSurfaceWidth() != newWidth || getSurfaceHeight() != newHeight) { if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.sizeChanged: ("+getThreadName()+"): (defer: "+defer+") force "+force+", "+getWidth()+"x"+getHeight()+" -> "+newWidth+"x"+newHeight+" - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)); + System.err.println("Window.sizeChanged: ("+getThreadName()+"): (defer: "+defer+") force "+force+", "+getSurfaceWidth()+"x"+getSurfaceHeight()+" -> "+newWidth+"x"+newHeight+" - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)); } if(0>newWidth || 0>newHeight) { throw new NativeWindowException("Illegal width or height "+newWidth+"x"+newHeight+" (must be >= 0)"); @@ -3619,12 +3648,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer final DisplayImpl display = (DisplayImpl) screen.getDisplay(); display.dispatchMessagesNative(); // status up2date long sleep; - for(sleep = timeOut; 0<sleep && w!=getWidth() && h!=getHeight(); sleep-=10 ) { + for(sleep = timeOut; 0<sleep && w!=getSurfaceWidth() && h!=getSurfaceHeight(); sleep-=10 ) { try { Thread.sleep(10); } catch (InterruptedException ie) {} display.dispatchMessagesNative(); // status up2date } if(0 >= sleep) { - final String msg = "Size/Pos not reached as requested within "+timeOut+"ms : requested "+w+"x"+h+", is "+getWidth()+"x"+getHeight(); + final String msg = "Size/Pos not reached as requested within "+timeOut+"ms : requested "+w+"x"+h+", is "+getSurfaceWidth()+"x"+getSurfaceHeight(); if(failFast) { throw new NativeWindowException(msg); } else if (DEBUG_IMPLEMENTATION) { @@ -3775,10 +3804,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer /** * Triggered by implementation's WM events to update the content + * @param defer if true sent event later, otherwise wait until processed. + * @param x dirty-region y-pos in pixels + * @param y dirty-region x-pos in pixels + * @param width dirty-region width in pixels + * @param height dirty-region height in pixels */ protected final void windowRepaint(boolean defer, int x, int y, int width, int height) { - width = ( 0 >= width ) ? getWidth() : width; - height = ( 0 >= height ) ? getHeight() : height; + width = ( 0 >= width ) ? getSurfaceWidth() : width; + height = ( 0 >= height ) ? getSurfaceHeight() : height; if(DEBUG_IMPLEMENTATION) { System.err.println("Window.windowRepaint "+getThreadName()+" (defer: "+defer+") "+x+"/"+y+" "+width+"x"+height); } diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java index 770502326..8b6bb95a9 100644 --- a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java +++ b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java @@ -124,7 +124,7 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt final int cw = comp.getWidth(); final int ch = comp.getHeight(); if( 0 < cw && 0 < ch ) { - if( newtChild.getWidth() != cw || newtChild.getHeight() != ch ) { + if( newtChild.getSurfaceWidth() != cw || newtChild.getSurfaceHeight() != ch ) { newtChild.setSize(cw, ch); final boolean v = comp.isShowing(); // compute showing-state throughout hierarchy if(v != newtChild.isVisible()) { diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java index 76eb890e2..5fe378f2c 100644 --- a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java +++ b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java @@ -228,8 +228,8 @@ public class NewtBaseActivity extends Activity { androidWindow.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } - if(newtWindow.getWidth()>0 && newtWindow.getHeight()>0 && !newtWindow.isFullscreen()) { - androidWindow.setLayout(newtWindow.getWidth(), newtWindow.getHeight()); + if(newtWindow.getSurfaceWidth()>0 && newtWindow.getSurfaceHeight()>0 && !newtWindow.isFullscreen()) { + androidWindow.setLayout(newtWindow.getSurfaceWidth(), newtWindow.getSurfaceHeight()); } } diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java index 259acb8f3..09de62326 100644 --- a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java +++ b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java @@ -83,7 +83,7 @@ public class NewtVersionActivity extends NewtBaseActivity { glWindow.setSize(32, 32); glWindow.setPosition(0, 0); final android.view.View androidGLView = ((WindowDriver)glWindow.getDelegatedWindow()).getAndroidView(); - viewGroup.addView(androidGLView, new android.widget.FrameLayout.LayoutParams(glWindow.getWidth(), glWindow.getHeight(), Gravity.BOTTOM|Gravity.RIGHT)); + viewGroup.addView(androidGLView, new android.widget.FrameLayout.LayoutParams(glWindow.getSurfaceWidth(), glWindow.getSurfaceHeight(), Gravity.BOTTOM|Gravity.RIGHT)); registerNEWTWindow(glWindow); glWindow.addGLEventListener(new GLEventListener() { diff --git a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java index 9af455445..20163f96c 100644 --- a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java @@ -304,7 +304,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { if(null == androidView) { setupAndroidView( StaticContext.getContext() ); } - viewGroup.addView(androidView, new android.widget.FrameLayout.LayoutParams(getWidth(), getHeight(), Gravity.BOTTOM|Gravity.RIGHT)); + viewGroup.addView(androidView, new android.widget.FrameLayout.LayoutParams(getSurfaceWidth(), getSurfaceHeight(), Gravity.BOTTOM|Gravity.RIGHT)); Log.d(MD.TAG, "canCreateNativeImpl: added to static ViewGroup - on thread "+Thread.currentThread().getName()); } }); for(long sleep = TIMEOUT_NATIVEWINDOW; 0<sleep && 0 == surfaceHandle; sleep-=10 ) { @@ -334,7 +334,9 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { final DefaultGraphicsScreen eglScreen = new DefaultGraphicsScreen(eglDevice, aScreen.getIndex()); Log.d(MD.TAG, "createNativeImpl 0 - eglDevice 0x"+Integer.toHexString(eglDevice.hashCode())+", "+eglDevice+", surfaceHandle 0x"+Long.toHexString(surfaceHandle)+ - ", format [a "+androidFormat+", n "+nativeFormat+"], "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()+" - on thread "+Thread.currentThread().getName()); + ", format [a "+androidFormat+", n "+nativeFormat+"], win["+getX()+"/"+getY()+" "+getWindowWidth()+"x"+getWindowHeight()+ + "], pixel["+getSurfaceWidth()+"x"+getSurfaceHeight()+ + "] - on thread "+Thread.currentThread().getName()); if(0!=getParentWindowHandle()) { throw new NativeWindowException("Window parenting not supported (yet)"); @@ -379,7 +381,9 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { Log.d(MD.TAG, "closeNativeImpl 0 - eglDevice 0x"+Integer.toHexString(eglDevice.hashCode())+", "+eglDevice+", surfaceHandle 0x"+Long.toHexString(surfaceHandle)+ ", eglSurfaceHandle 0x"+Long.toHexString(eglSurface)+ - ", format [a "+androidFormat+", n "+nativeFormat+"], "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()+" - on thread "+Thread.currentThread().getName()); + ", format [a "+androidFormat+", n "+nativeFormat+"], win["+getX()+"/"+getY()+" "+getWindowWidth()+"x"+getWindowHeight()+ + "], pixel["+getSurfaceWidth()+"x"+getSurfaceHeight()+"],"+ + " - on thread "+Thread.currentThread().getName()); if(WindowImpl.DEBUG_IMPLEMENTATION) { Thread.dumpStack(); } @@ -458,7 +462,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { Log.d(MD.TAG, "reconfigureWindowImpl.setFullscreen post creation (setContentView()) n/a"); return false; } - if(getWidth() != width || getHeight() != height) { + if(getSurfaceWidth() != width || getSurfaceHeight() != height) { if(0!=getWindowHandle()) { Log.d(MD.TAG, "reconfigureWindowImpl.setSize n/a"); res = false; @@ -544,7 +548,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { @Override public final void surfaceCreated(SurfaceHolder holder) { - Log.d(MD.TAG, "surfaceCreated: "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()+" - on thread "+Thread.currentThread().getName()); + Log.d(MD.TAG, "surfaceCreated: "+getX()+"/"+getY()+" "+getSurfaceWidth()+"x"+getSurfaceHeight()+" - on thread "+Thread.currentThread().getName()); } @Override @@ -611,7 +615,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { @Override public final void surfaceRedrawNeeded(SurfaceHolder holder) { Log.d(MD.TAG, "surfaceRedrawNeeded - on thread "+Thread.currentThread().getName()); - windowRepaint(0, 0, getWidth(), getHeight()); + windowRepaint(0, 0, getSurfaceWidth(), getSurfaceHeight()); } protected boolean handleKeyCodeBack(KeyEvent.DispatcherState state, android.view.KeyEvent event) { diff --git a/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java index 9854524d9..965426d4e 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java @@ -132,7 +132,7 @@ public class WindowDriver extends WindowImpl { new AWTWindowAdapter(new LocalWindowListener(), this).addTo(awtCanvas); // fwd all AWT Window events to here } - reconfigureWindowImpl(getX(), getY(), getWidth(), getHeight(), getReconfigureFlags(FLAG_CHANGE_VISIBILITY | FLAG_CHANGE_DECORATION, true)); + reconfigureWindowImpl(getX(), getY(), getSurfaceWidth(), getSurfaceHeight(), getReconfigureFlags(FLAG_CHANGE_VISIBILITY | FLAG_CHANGE_DECORATION, true)); // throws exception if failed .. final NativeWindow nw = awtCanvas.getNativeWindow(); @@ -297,7 +297,7 @@ public class WindowDriver extends WindowImpl { System.err.println("Window Resized: "+awtCanvas); } WindowDriver.this.sizeChanged(false, awtCanvas.getWidth(), awtCanvas.getHeight(), true); - WindowDriver.this.windowRepaint(false, 0, 0, getWidth(), getHeight()); + WindowDriver.this.windowRepaint(false, 0, 0, getSurfaceWidth(), getSurfaceHeight()); } } @Override @@ -322,7 +322,7 @@ public class WindowDriver extends WindowImpl { if(DEBUG_IMPLEMENTATION) { System.err.println("Window Repaint: "+awtCanvas); } - WindowDriver.this.windowRepaint(false, 0, 0, getWidth(), getHeight()); + WindowDriver.this.windowRepaint(false, 0, 0, getSurfaceWidth(), getSurfaceHeight()); } } } diff --git a/src/newt/classes/jogamp/newt/driver/bcm/egl/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/WindowDriver.java index 39f168e0f..5b0d21c66 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/egl/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/WindowDriver.java @@ -67,7 +67,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl { setGraphicsConfiguration(cfg); setSizeImpl(getScreen().getWidth(), getScreen().getHeight()); - setWindowHandle(realizeWindow(true, getWidth(), getHeight())); + setWindowHandle(realizeWindow(true, getSurfaceWidth(), getSurfaceHeight())); if (0 == getWindowHandle()) { throw new NativeWindowException("Error native Window Handle is null"); } @@ -108,7 +108,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl { // n/a in BroadcomEGL System.err.println("BCEGL Window.setSizeImpl n/a in BroadcomEGL with realized window"); } else { - defineSize((width>0)?width:getWidth(), (height>0)?height:getHeight()); + defineSize((width>0)?width:getSurfaceWidth(), (height>0)?height:getSurfaceHeight()); } } if(x>=0 || y>=0) { diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java index c3cb8a84c..817ce3aeb 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java @@ -110,7 +110,7 @@ public class WindowDriver extends WindowImpl { chosenCaps.setBackgroundOpaque(capsRequested.isBackgroundOpaque()); } setGraphicsConfiguration(cfg); - nativeWindowHandle = CreateWindow0(display.getBCMHandle(), layer, getX(), getY(), getWidth(), getHeight(), + nativeWindowHandle = CreateWindow0(display.getBCMHandle(), layer, getX(), getY(), getSurfaceWidth(), getSurfaceHeight(), chosenCaps.isBackgroundOpaque(), chosenCaps.getAlphaBits()); if (nativeWindowHandle == 0) { throw new NativeWindowException("Error creating egl window: "+cfg); diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java index 0e96c65d0..d86cf7471 100644 --- a/src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java @@ -66,7 +66,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl { synchronized(WindowDriver.class) { setWindowHandle(nextWindowHandle++); // just a marker - surfaceHandle = CreateSurface(aDevice.getHandle(), getScreen().getWidth(), getScreen().getHeight(), getX(), getY(), getWidth(), getHeight()); + surfaceHandle = CreateSurface(aDevice.getHandle(), getScreen().getWidth(), getScreen().getHeight(), getX(), getY(), getSurfaceWidth(), getSurfaceHeight()); if (surfaceHandle == 0) { throw new NativeWindowException("Error creating window"); } diff --git a/src/newt/classes/jogamp/newt/driver/kd/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/kd/WindowDriver.java index 158e6ab2f..35e9227d3 100644 --- a/src/newt/classes/jogamp/newt/driver/kd/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/kd/WindowDriver.java @@ -112,8 +112,8 @@ public class WindowDriver extends WindowImpl { } // int _x=(x>=0)?x:this.x; // int _y=(x>=0)?y:this.y; - width=(width>0)?width:getWidth(); - height=(height>0)?height:getHeight(); + width=(width>0)?width:getSurfaceWidth(); + height=(height>0)?height:getSurfaceHeight(); if(width>0 || height>0) { setSize0(eglWindowHandle, width, height); } @@ -158,7 +158,7 @@ public class WindowDriver extends WindowImpl { @Override protected void sizeChanged(boolean defer, int newWidth, int newHeight, boolean force) { if(isFullscreen()) { - ((ScreenDriver)getScreen()).sizeChanged(getWidth(), getHeight()); + ((ScreenDriver)getScreen()).sizeChanged(getSurfaceWidth(), getSurfaceHeight()); } super.sizeChanged(defer, newWidth, newHeight, force); } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index e2a57debc..8f3eb1e89 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -70,7 +70,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); } setGraphicsConfiguration(cfg); - reconfigureWindowImpl(getX(), getY(), getWidth(), getHeight(), getReconfigureFlags(FLAG_CHANGE_VISIBILITY, true)); + reconfigureWindowImpl(getX(), getY(), getSurfaceWidth(), getSurfaceHeight(), getReconfigureFlags(FLAG_CHANGE_VISIBILITY, true)); if (0 == getWindowHandle()) { throw new NativeWindowException("Error creating window"); } @@ -236,7 +236,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl if( 0 != handle && !isOffscreenInstance ) { final NativeWindow parent = getParent(); final boolean useParent = useParent(parent); - if( useParent && ( getWidth() != newWidth || getHeight() != newHeight ) ) { + if( useParent && ( getSurfaceWidth() != newWidth || getSurfaceHeight() != newHeight ) ) { final int x=getX(), y=getY(); final Point p0S = getLocationOnScreenImpl(x, y, parent, useParent); if(DEBUG_IMPLEMENTATION) { diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index a48fe2f62..0fc38f92d 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -145,7 +145,7 @@ public class WindowDriver extends WindowImpl { ( FLAG_IS_ALWAYSONTOP | FLAG_IS_UNDECORATED ) ; final long _windowHandle = CreateWindow0(DisplayDriver.getHInstance(), display.getWindowClassName(), display.getWindowClassName(), winVer.getMajor(), winVer.getMinor(), - getParentWindowHandle(), getX(), getY(), getWidth(), getHeight(), autoPosition(), flags); + getParentWindowHandle(), getX(), getY(), getSurfaceWidth(), getSurfaceHeight(), autoPosition(), flags); if ( 0 == _windowHandle ) { throw new NativeWindowException("Error creating window"); } @@ -252,7 +252,7 @@ public class WindowDriver extends WindowImpl { public void run() { final Point p0 = getLocationOnScreenImpl(0, 0); res[0] = Boolean.valueOf(confinePointer0(getWindowHandle(), confine, - p0.getX(), p0.getY(), p0.getX()+getWidth(), p0.getY()+getHeight())); + p0.getX(), p0.getY(), p0.getX()+getSurfaceWidth(), p0.getY()+getSurfaceHeight())); } }); return res[0].booleanValue(); diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java index 0eda37eac..2f4ccbfea 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java @@ -129,7 +129,7 @@ public class WindowDriver extends WindowImpl { setWindowHandle(CreateWindow(getParentWindowHandle(), edtDevice.getHandle(), screen.getIndex(), visualID, display.getJavaObjectAtom(), display.getWindowDeleteAtom(), - getX(), getY(), getWidth(), getHeight(), autoPosition(), flags, + getX(), getY(), getSurfaceWidth(), getSurfaceHeight(), autoPosition(), flags, defaultIconDataSize, defaultIconData)); } finally { edtDevice.unlock(); @@ -238,7 +238,7 @@ public class WindowDriver extends WindowImpl { public Object run(long dpy) { reconfigureWindow0( dpy, getScreenIndex(), getParentWindowHandle(), getWindowHandle(), display.getWindowDeleteAtom(), - getX(), getY(), getWidth(), getHeight(), flags); + getX(), getY(), getSurfaceWidth(), getSurfaceHeight(), flags); return null; } }); |