aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-05-22 07:09:23 +0200
committerSven Gothel <[email protected]>2014-05-22 07:09:23 +0200
commitfb57c652fee6be133990cd7afbbd2fdfc084afaa (patch)
tree7993fe001b291eb83519bf02f34639502f2afb22 /src/newt
parentf9a00b91dcd146c72a50237b62270f33bd0da98e (diff)
Bug 742 HiDPI: [Core API Change] Distinguish window-units and pixel-units: Refine commit f9a00b91dcd146c72a50237b62270f33bd0da98e
- Using comment tag 'FIXME HiDPI' to locate remaining issues - Fix remaining 'getPixel*(..)' -> 'getSurface*(..)' - UpstreamSurfaceHook - Fix usage (one by one) of - NativeWindow: getWindowWidth() / getWindowHeight() - NativeSurface/GLDrawable: getSurfaceWidth() / getSurfaceHeight() - mention window- or pixel units in API doc where required - use 'setSurfaceSize(..)' where appropriate to match 'getSurface*()' - GLFBODrawable - GLOffscreenAutoDrawable - UpstreamSurfaceHook.MutableSize - NativeWindow's Point: Add API doc and 'Point scaleInv(..)' - NativeSurface Simplify new conversion methods and use single in-place storage - 'int[] getWindowUnitXY(int[], int[])' -> 'int[] convertToWindowUnits(int[], int[])' - 'int[] getPixelUnitXY(int[], int[])' -> 'int[] convertToPixelUnits(int[], int[])' - NEWT Screen/Monitor - Assume screen/window units - TODO: Refine semantics - Monitor resolution probably is in pixel units ?! - Including the Rectangle/Monitor association etc etc - NEWT Window - Add setSurfaceSize(..) for convenience - Add 'Point convertToWindowUnits(final Point pixelUnitsAndResult)', etc .. - All window ops are using window units (size, pos, ..), but methods operating on the surface/drawable: windowRepaint(..) .. - TODO: Consider changing method names 'window*(..)' to 'surface*(..)' actually operating on surface/drawable - Window.windowRepaint(..) - GLAutoDrawableDelegate.windowResizedOp(..) (maybe all similar methods in here) - NEWT Mouse/Pointer Events - Using pixel units
Diffstat (limited to 'src/newt')
-rw-r--r--src/newt/classes/com/jogamp/newt/MonitorDevice.java11
-rw-r--r--src/newt/classes/com/jogamp/newt/NewtFactory.java2
-rw-r--r--src/newt/classes/com/jogamp/newt/Screen.java15
-rw-r--r--src/newt/classes/com/jogamp/newt/Window.java44
-rw-r--r--src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java2
-rw-r--r--src/newt/classes/com/jogamp/newt/opengl/GLWindow.java22
-rw-r--r--src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java14
-rw-r--r--src/newt/classes/com/jogamp/newt/util/applet/JOGLNewtApplet3Run.java4
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java236
-rw-r--r--src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java2
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java120
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/WindowDriver.java17
-rw-r--r--src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java2
-rw-r--r--src/newt/classes/jogamp/newt/driver/bcm/egl/WindowDriver.java4
-rw-r--r--src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java2
-rw-r--r--src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java3
-rw-r--r--src/newt/classes/jogamp/newt/driver/kd/WindowDriver.java6
-rw-r--r--src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java14
-rw-r--r--src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java5
-rw-r--r--src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java4
20 files changed, 320 insertions, 209 deletions
diff --git a/src/newt/classes/com/jogamp/newt/MonitorDevice.java b/src/newt/classes/com/jogamp/newt/MonitorDevice.java
index 2d1d912c7..1198f7681 100644
--- a/src/newt/classes/com/jogamp/newt/MonitorDevice.java
+++ b/src/newt/classes/com/jogamp/newt/MonitorDevice.java
@@ -168,12 +168,19 @@ public abstract class MonitorDevice {
return supportedModes.getData();
}
- /** Returns the {@link RectangleImmutable rectangular} portion of the rotated virtual {@link Screen} size represented by this monitor. */
+ /**
+ * Returns the {@link RectangleImmutable rectangular} portion
+ * of the rotated virtual {@link Screen} size in screen/window units
+ * represented by this monitor.
+ */
public final RectangleImmutable getViewport() {
return viewport;
}
- /** Returns <code>true</code> if given coordinates are contained by this {@link #getViewport() viewport}, otherwise <code>false</code>. */
+ /**
+ * Returns <code>true</code> if given screen coordinates in screen/window units
+ * are contained by this {@link #getViewport() viewport}, otherwise <code>false</code>.
+ */
public final boolean contains(int x, int y) {
return x >= viewport.getX() &&
x < viewport.getX() + viewport.getWidth() &&
diff --git a/src/newt/classes/com/jogamp/newt/NewtFactory.java b/src/newt/classes/com/jogamp/newt/NewtFactory.java
index 3b31861f0..4443c70c9 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.getSurfaceWidth(), parentWindow.getSurfaceHeight());
+ win.setSize(parentWindow.getWindowWidth(), parentWindow.getWindowHeight());
if ( null != newtParentWindow ) {
newtParentWindow.addChild(win);
win.setVisible(newtParentWindow.isVisible());
diff --git a/src/newt/classes/com/jogamp/newt/Screen.java b/src/newt/classes/com/jogamp/newt/Screen.java
index ef62ec95d..2a713c538 100644
--- a/src/newt/classes/com/jogamp/newt/Screen.java
+++ b/src/newt/classes/com/jogamp/newt/Screen.java
@@ -131,27 +131,27 @@ public abstract class Screen {
public abstract int getIndex();
/**
- * @return the x position of the virtual viewport's top-left origin.
+ * @return the x position of the virtual viewport's top-left origin in screen/window units.
*/
public abstract int getX();
/**
- * @return the y position of the virtual viewport's top-left origin.
+ * @return the y position of the virtual viewport's top-left origin in screen/window units.
*/
public abstract int getY();
/**
- * @return the <b>rotated</b> virtual viewport's width.
+ * @return the <b>rotated</b> virtual viewport's width in screen/window units.
*/
public abstract int getWidth();
/**
- * @return the <b>rotated</b> virtual viewport's height.
+ * @return the <b>rotated</b> virtual viewport's height in screen/window units.
*/
public abstract int getHeight();
/**
- * @return the <b>rotated</b> virtual viewport, i.e. origin and size.
+ * @return the <b>rotated</b> virtual viewport, i.e. origin and size in screen/window units.
*/
public abstract RectangleImmutable getViewport();
@@ -186,6 +186,7 @@ public abstract class Screen {
* <p>
* If no coverage is detected the first {@link MonitorDevice} is returned.
* </p>
+ * @param r arbitrary rectangle in screen/window units
*/
public final MonitorDevice getMainMonitor(RectangleImmutable r) {
MonitorDevice res = null;
@@ -206,7 +207,7 @@ public abstract class Screen {
}
/**
- * Returns the union of all monitor's {@link MonitorDevice#getViewport() viewport}.
+ * Returns the union of all monitor's {@link MonitorDevice#getViewport() viewport} in screen/window units.
* <p>
* Should be equal to {@link #getX()}, {@link #getY()}, {@link #getWidth()} and {@link #getHeight()},
* however, some native toolkits may choose a different virtual screen area.
@@ -257,7 +258,7 @@ public abstract class Screen {
synchronized(screenList) {
int i = fromIndex >= 0 ? fromIndex : screenList.size() - 1 ;
while( ( incr > 0 ) ? i < screenList.size() : i >= 0 ) {
- final Screen screen = (Screen) screenList.get(i).get();
+ final Screen screen = screenList.get(i).get();
if( null == screen ) {
// Clear GC'ed dead reference entry!
screenList.remove(i);
diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java
index 9cf67c56f..b733406e8 100644
--- a/src/newt/classes/com/jogamp/newt/Window.java
+++ b/src/newt/classes/com/jogamp/newt/Window.java
@@ -46,6 +46,7 @@ import javax.media.nativewindow.CapabilitiesChooser;
import javax.media.nativewindow.CapabilitiesImmutable;
import javax.media.nativewindow.NativeWindow;
import javax.media.nativewindow.WindowClosingProtocol;
+import javax.media.nativewindow.util.Point;
import javax.media.nativewindow.util.RectangleImmutable;
/**
@@ -251,11 +252,38 @@ public interface Window extends NativeWindow, WindowClosingProtocol {
* @param width of the window's client area in window units
* @param height of the window's client area in window units
*
+ * @see #setSurfaceSize(int, int)
+ * @see #setTopLevelSize(int, int)
* @see #getInsets()
*/
void setSize(int width, int height);
/**
+ * Sets the size of the window's surface in pixel units which claims the window's client area excluding decorations.
+ *
+ * <p>
+ * Zero size semantics are respected, see {@link #setVisible(boolean)}:<br>
+ * <pre>
+ * if ( visible && 0 != windowHandle && ( 0 &ge; width || 0 &ge; height ) ) {
+ * setVisible(false);
+ * } else if ( visible && 0 == windowHandle && 0 &lt; width && 0 &lt; height ) {
+ * setVisible(true);
+ * } else {
+ * // as expected ..
+ * }
+ * </pre></p>
+ * <p>
+ * This call is ignored if in fullscreen mode.<br></p>
+ *
+ * @param pixelWidth of the window's client area in pixel units
+ * @param pixelHeight of the window's client area in pixel units
+ *
+ * @see #setSize(int, int)
+ * @see #getInsets()
+ */
+ void setSurfaceSize(int pixelWidth, int pixelHeight);
+
+ /**
* Sets the size of the top-level window including insets (window decorations) in window units.
*
* <p>
@@ -299,6 +327,22 @@ public interface Window extends NativeWindow, WindowClosingProtocol {
*/
void setTopLevelPosition(int x, int y);
+ /**
+ * Converts the given pixel units into window units <i>in place</i>.
+ * @param pixelUnitsAndResult point storage holding the pixel units to convert
+ * and the resulting conversion.
+ * @return resulting point storage pixelUnitsAndResult for chaining holding the converted values
+ */
+ Point convertToWindowUnits(final Point pixelUnitsAndResult);
+
+ /**
+ * Converts the given window units into pixel units <i>in place</i>.
+ * @param windowUnitsAndResult point storage holding the window units to convert
+ * and the resulting conversion.
+ * @return resulting point storage windowUnitsAndResult for chaining holding the converted values
+ */
+ Point convertToPixelUnits(final Point windowUnitsAndResult);
+
void setUndecorated(boolean value);
boolean isUndecorated();
diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
index 891843cb7..0d70b5f8c 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.getSurfaceWidth(), w.getSurfaceHeight());
+ java.awt.Dimension minSize = new java.awt.Dimension(w.getWindowWidth(), w.getWindowHeight());
setMinimumSize(minSize);
setPreferredSize(minSize);
}
diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
index c4a5fcab1..7ba4bddf0 100644
--- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
@@ -363,13 +363,23 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind
}
@Override
- public final int[] getWindowUnitXY(int[] result, final int[] pixelUnitXY) {
- return window.getWindowUnitXY(result, pixelUnitXY);
+ public final int[] convertToWindowUnits(final int[] pixelUnitsAndResult) {
+ return window.convertToWindowUnits(pixelUnitsAndResult);
}
@Override
- public final int[] getPixelUnitXY(int[] result, final int[] windowUnitXY) {
- return window.getPixelUnitXY(result, windowUnitXY);
+ public final int[] convertToPixelUnits(final int[] windowUnitsAndResult) {
+ return window.convertToPixelUnits(windowUnitsAndResult);
+ }
+
+ @Override
+ public final Point convertToWindowUnits(final Point pixelUnitsAndResult) {
+ return window.convertToWindowUnits(pixelUnitsAndResult);
+ }
+
+ @Override
+ public final Point convertToPixelUnits(final Point windowUnitsAndResult) {
+ return window.convertToPixelUnits(windowUnitsAndResult);
}
@Override
@@ -471,6 +481,10 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind
window.setSize(width, height);
}
@Override
+ public final void setSurfaceSize(int pixelWidth, int pixelHeight) {
+ window.setSurfaceSize(pixelWidth, pixelHeight);
+ }
+ @Override
public void setTopLevelSize(int width, int height) {
window.setTopLevelSize(width, height);
}
diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java
index ee01212cb..b627fa1ad 100644
--- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java
+++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java
@@ -470,19 +470,13 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol {
}
@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;
+ public final int[] convertToWindowUnits(final int[] pixelUnitsAndResult) {
+ return pixelUnitsAndResult; // FIXME HiDPI: use 'pixelScale'
}
@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;
+ public final int[] convertToPixelUnits(final int[] windowUnitsAndResult) {
+ return windowUnitsAndResult; // FIXME HiDPI: use 'pixelScale'
}
@Override
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 8a3e5616d..7b6a1c8cd 100644
--- a/src/newt/classes/com/jogamp/newt/util/applet/JOGLNewtApplet3Run.java
+++ b/src/newt/classes/com/jogamp/newt/util/applet/JOGLNewtApplet3Run.java
@@ -172,7 +172,7 @@ public class JOGLNewtApplet3Run implements Applet3 {
glWindow = GLWindow.create(w);
glWindow.setUndecorated(glUndecorated);
glWindow.setAlwaysOnTop(glAlwaysOnTop);
- glWindow.setSize(browserWin.getSurfaceWidth(), browserWin.getSurfaceHeight());
+ glWindow.setSize(browserWin.getWindowWidth(), browserWin.getWindowHeight());
return new NativeWindowDownstream() {
@Override
@@ -184,7 +184,7 @@ public class JOGLNewtApplet3Run implements Applet3 {
@Override
public void setSize(int width, int height) {
- upstreamSizePosHook.setPixelSize(width, height);
+ upstreamSizePosHook.setWinSize(width, height);
if( null != glWindow ) {
glWindow.setSize(width, height);
}
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index a9fc28a33..b127426a8 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -195,7 +195,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
/** from event passing: {@link WindowImpl#consumePointerEvent(MouseEvent)}. */
private static class PointerState0 {
/** Pointer entered window - is inside the window (may be synthetic) */
- boolean insideWindow = false;
+ boolean insideSurface = false;
/** Mouse EXIT has been sent (only for MOUSE type enter/exit)*/
boolean exitSent = false;
@@ -208,7 +208,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
void clearButton() {
lastButtonPressTime = 0;
}
- public String toString() { return "PState0[inside "+insideWindow+", exitSent "+exitSent+", lastPress "+lastButtonPressTime+", dragging "+dragging+"]"; }
+ public String toString() { return "PState0[inside "+insideSurface+", exitSent "+exitSent+", lastPress "+lastButtonPressTime+", dragging "+dragging+"]"; }
}
private final PointerState0 pState0 = new PointerState0();
@@ -242,7 +242,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
return null;
}
- public final String toString() { return "PState1[inside "+insideWindow+", exitSent "+exitSent+", lastPress "+lastButtonPressTime+
+ public final String toString() { return "PState1[inside "+insideSurface+", exitSent "+exitSent+", lastPress "+lastButtonPressTime+
", pressed [button "+buttonPressed+", mask "+buttonPressedMask+", dragging "+dragging+", clickCount "+lastButtonClickCount+"]"; }
}
private final PointerState1 pState1 = new PointerState1();
@@ -633,10 +633,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
* to insets and positioning a decorated window to 0/0, which would place the frame
* outside of the screen.</p>
*
- * @param x client-area position, or <0 if unchanged
- * @param y client-area position, or <0 if unchanged
- * @param width client-area size, or <=0 if unchanged
- * @param height client-area size, or <=0 if unchanged
+ * @param x client-area position in window units, or <0 if unchanged
+ * @param y client-area position in window units, or <0 if unchanged
+ * @param width client-area size in window units, or <=0 if unchanged
+ * @param height client-area size in window units, or <=0 if unchanged
* @param flags bitfield of change and status flags
*
* @see #sizeChanged(int,int)
@@ -709,7 +709,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
/**
* Translates the given window client-area coordinates with top-left origin
- * to screen coordinates.
+ * to screen coordinates in window units.
* <p>
* Since the position reflects the client area, it does not include the insets.
* </p>
@@ -722,7 +722,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
*/
protected abstract Point getLocationOnScreenImpl(int x, int y);
- /** Triggered by user via {@link #getInsets()}.<br>
+ /**
+ * Triggered by user via {@link #getInsets()}.<br>
* Implementations may implement this hook to update the insets.<br>
* However, they may prefer the event driven path via {@link #insetsChanged(boolean, int, int, int, int)}.
*
@@ -911,9 +912,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
@Override
public final MonitorDevice getMainMonitor() {
- return screen.getMainMonitor(new Rectangle(getX(), getY(), getSurfaceWidth(), getSurfaceHeight()));
+ return screen.getMainMonitor(new Rectangle(getX(), getY(), getWindowWidth(), getWindowHeight()));
}
+ /**
+ * @param visible
+ * @param x client-area position in window units, or <0 if unchanged
+ * @param y client-area position in window units, or <0 if unchanged
+ * @param width client-area size in window units, or <=0 if unchanged
+ * @param height client-area size in window units, or <=0 if unchanged
+ */
protected final void setVisibleImpl(boolean visible, int x, int y, int width, int height) {
reconfigureWindowImpl(x, y, width, height, getReconfigureFlags(FLAG_CHANGE_VISIBILITY, visible));
}
@@ -935,7 +943,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
}
if(!isNativeValid() && visible) {
- if( 0<getSurfaceWidth()*getSurfaceHeight() ) {
+ if( 0<getWindowWidth()*getWindowHeight() ) {
nativeWindowCreated = createNative();
madeVisible = nativeWindowCreated;
}
@@ -943,7 +951,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
WindowImpl.this.visible = true;
} else if(WindowImpl.this.visible != visible) {
if(isNativeValid()) {
- setVisibleImpl(visible, getX(), getY(), getSurfaceWidth(), getSurfaceHeight());
+ setVisibleImpl(visible, getX(), getY(), getWindowWidth(), getWindowHeight());
WindowImpl.this.waitForVisible(visible, false);
madeVisible = visible;
} else {
@@ -966,7 +974,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
}
if(DEBUG_IMPLEMENTATION) {
- 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);
+ System.err.println("Window setVisible: END ("+getThreadName()+") "+getX()+"/"+getY()+" "+getWindowWidth()+"x"+getWindowHeight()+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible: "+WindowImpl.this.visible+", nativeWindowCreated: "+nativeWindowCreated+", madeVisible: "+madeVisible);
}
} finally {
if(null!=lifecycleHook) {
@@ -994,7 +1002,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()+" "+getSurfaceWidth()+"x"+getSurfaceHeight()+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible: "+this.visible+" -> "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+(null!=parentWindow));
+ System.err.println("Window setVisible: START ("+getThreadName()+") "+getX()+"/"+getY()+" "+getWindowWidth()+"x"+getWindowHeight()+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible: "+this.visible+" -> "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+(null!=parentWindow));
}
runOnEDTIfAvail(wait, new VisibleAction(visible));
}
@@ -1019,9 +1027,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
final RecursiveLock _lock = windowLock;
_lock.lock();
try {
- if ( ( disregardFS || !isFullscreen() ) && ( getSurfaceWidth() != width || getSurfaceHeight() != height ) ) {
+ if ( ( disregardFS || !isFullscreen() ) && ( getWindowWidth() != width || getWindowHeight() != height ) ) {
if(DEBUG_IMPLEMENTATION) {
- System.err.println("Window setSize: START "+getSurfaceWidth()+"x"+getSurfaceHeight()+" -> "+width+"x"+height+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible "+visible);
+ System.err.println("Window setSize: START "+getWindowWidth()+"x"+getWindowHeight()+" -> "+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 ) ) {
@@ -1041,7 +1049,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
defineSize(width, height);
}
if(DEBUG_IMPLEMENTATION) {
- System.err.println("Window setSize: END "+getSurfaceWidth()+"x"+getSurfaceHeight()+", visibleAction "+visibleAction);
+ System.err.println("Window setSize: END "+getWindowWidth()+"x"+getWindowHeight()+", visibleAction "+visibleAction);
}
switch(visibleAction) {
case 1: setVisibleActionImpl(false); break;
@@ -1054,15 +1062,20 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
}
- private void setFullscreenSize(int width, int height) {
+ private void setFullscreenSize(final int width, final int height) {
runOnEDTIfAvail(true, new SetSizeAction(width, height, true));
}
@Override
- public final void setSize(int width, int height) {
+ public final void setSize(final int width, final int height) {
runOnEDTIfAvail(true, new SetSizeAction(width, height, false));
}
@Override
- public final void setTopLevelSize(int width, int height) {
+ public final void setSurfaceSize(final int pixelWidth, final int pixelHeight) {
+ final int[] winSize = convertToWindowUnits(new int[]{pixelWidth, pixelHeight});
+ setSize(winSize[0], winSize[1]);
+ }
+ @Override
+ public final void setTopLevelSize(final int width, final int height) {
setSize(width - getInsets().getTotalWidth(), height - getInsets().getTotalHeight());
}
@@ -1248,8 +1261,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 = getSurfaceWidth();
- final int oldHeight = getSurfaceHeight();
+ final int oldWidth = getWindowWidth();
+ final int oldHeight = getWindowHeight();
final int x, y;
int width = oldWidth;
int height = oldHeight;
@@ -1300,11 +1313,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
y = 0;
// refit if size is bigger than parent
- if( width > newParentWindow.getSurfaceWidth() ) {
- width = newParentWindow.getSurfaceWidth();
+ if( width > newParentWindow.getWindowWidth() ) {
+ width = newParentWindow.getWindowWidth();
}
- if( height > newParentWindow.getSurfaceHeight() ) {
- height = newParentWindow.getSurfaceHeight();
+ if( height > newParentWindow.getWindowHeight() ) {
+ height = newParentWindow.getWindowHeight();
}
// Case: Child Window
@@ -1511,7 +1524,10 @@ 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()+" "+getSurfaceWidth()+"x"+getSurfaceHeight());
+ System.err.println("Window.reparent: END-1 ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+
+ ", visible: "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+
+ ", parentWindow "+ Display.hashCodeNullSafe(parentWindow)+" "+
+ getX()+"/"+getY()+" "+getWindowWidth()+"x"+getWindowHeight());
}
} finally {
if(null!=lifecycleHook) {
@@ -1535,7 +1551,10 @@ 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()+" "+getSurfaceWidth()+"x"+getSurfaceHeight());
+ System.err.println("Window.reparent: END-X ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+
+ ", visible: "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+
+ ", parentWindow "+ Display.hashCodeNullSafe(parentWindow)+" "+
+ getX()+"/"+getY()+" "+getWindowWidth()+"x"+getWindowHeight());
}
}
}
@@ -1612,8 +1631,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 = getSurfaceWidth();
- final int height = getSurfaceHeight();
+ final int width = getWindowWidth();
+ final int height = getWindowHeight();
DisplayImpl display = (DisplayImpl) screen.getDisplay();
display.dispatchMessagesNative(); // status up2date
@@ -1658,8 +1677,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 = getSurfaceWidth();
- final int height = getSurfaceHeight();
+ final int width = getWindowWidth();
+ final int height = getWindowHeight();
DisplayImpl display = (DisplayImpl) screen.getDisplay();
display.dispatchMessagesNative(); // status up2date
@@ -1869,31 +1888,42 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
@Override
public final int getWindowWidth() {
- return getSurfaceWidth(); // FIXME: Use 'scale' or an actual pixel-width
+ return winWidth;
}
@Override
public final int getWindowHeight() {
- return getSurfaceHeight(); // FIXME: Use 'scale' or an actual pixel-width
+ return winHeight;
+ }
+
+ @Override
+ public final int[] convertToWindowUnits(final int[] pixelUnitsAndResult) {
+ pixelUnitsAndResult[0] /= getPixelScaleX();
+ pixelUnitsAndResult[1] /= getPixelScaleY();
+ return pixelUnitsAndResult;
}
@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;
+ public final int[] convertToPixelUnits(final int[] windowUnitsAndResult) {
+ windowUnitsAndResult[0] *= getPixelScaleX();
+ windowUnitsAndResult[1] *= getPixelScaleY();
+ return windowUnitsAndResult;
}
@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;
+ public final Point convertToWindowUnits(final Point pixelUnitsAndResult) {
+ return pixelUnitsAndResult.scaleInv(getPixelScaleX(), getPixelScaleY());
}
@Override
+ public final Point convertToPixelUnits(final Point windowUnitsAndResult) {
+ return windowUnitsAndResult.scale(getPixelScaleX(), getPixelScaleY());
+ }
+
+ protected int getPixelScaleX() { return 1; }
+ protected int getPixelScaleY() { return 1; }
+
+ @Override
public final int getX() {
return x;
}
@@ -1905,7 +1935,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
protected final boolean autoPosition() { return autoPosition; }
- /** Sets the position fields {@link #x} and {@link #y} to the given values and {@link #autoPosition} to false. */
+ /** Sets the position fields {@link #x} and {@link #y} in window units to the given values and {@link #autoPosition} to false. */
protected final void definePosition(int x, int y) {
if(DEBUG_IMPLEMENTATION) {
System.err.println("definePosition: "+this.x+"/"+this.y+" -> "+x+"/"+y);
@@ -1915,13 +1945,19 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
this.x = x; this.y = y;
}
- /** Sets the size fields {@link #pixWidth} and {@link #pixHeight} to the given values. */
- protected final void defineSize(int width, int height) {
+ /**
+ * Sets the size fields {@link #winWidth} and {@link #winHeight} in window units to the given values
+ * and {@link #pixWidth} and {@link #pixHeight} in pixel units according to {@link #convertToPixelUnits(int[])}.
+ */
+ protected final void defineSize(int winWidth, int winHeight) {
+ final int[] pixelSize = convertToPixelUnits(new int[] { winWidth, winHeight });
if(DEBUG_IMPLEMENTATION) {
- System.err.println("defineSize: "+this.pixWidth+"x"+this.pixHeight+" -> "+width+"x"+height);
+ System.err.println("defineSize: win["+this.winWidth+"x"+this.winHeight+" -> "+winWidth+"x"+winHeight+
+ "], pixel["+this.pixWidth+"x"+this.pixHeight+" -> "+pixelSize[0]+"x"+pixelSize[1]+"]");
// Thread.dumpStack();
}
- this.pixWidth = width; this.pixHeight = height;
+ this.winWidth = winWidth; this.winHeight = winHeight;
+ this.pixWidth = pixelSize[0]; this.pixHeight = pixelSize[0];
}
@Override
@@ -1987,17 +2023,17 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
StringBuilder sb = new StringBuilder();
sb.append(getClass().getName()+"[Config "+config+
- "\n, "+screen+
- "\n, ParentWindow "+parentWindow+
- "\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 "+getSurfaceWidth()+"x"+getSurfaceHeight()+
- "\n, Visible "+isVisible()+", focus "+hasFocus()+
- "\n, Undecorated "+undecorated+" ("+isUndecorated()+")"+
- "\n, AlwaysOnTop "+alwaysOnTop+", Fullscreen "+fullscreen+
- "\n, WrappedSurface "+getWrappedSurface()+
- "\n, ChildWindows "+childWindows.size());
+ ",\n "+screen+
+ ",\n ParentWindow "+parentWindow+
+ ",\n ParentWindowHandle "+toHexString(parentWindowHandle)+" ("+(0!=getParentWindowHandle())+")"+
+ ",\n WindowHandle "+toHexString(getWindowHandle())+
+ ",\n SurfaceHandle "+toHexString(getSurfaceHandle())+ " (lockedExt window "+windowLock.isLockedByOtherThread()+", surface "+isSurfaceLockedByOtherThread()+")"+
+ ",\n window["+getX()+"/"+getY()+" (auto "+autoPosition()+") "+getWindowWidth()+"x"+getWindowHeight()+"], pixel["+getSurfaceWidth()+"x"+getSurfaceHeight()+
+ "],\n Visible "+isVisible()+", focus "+hasFocus()+
+ ",\n Undecorated "+undecorated+" ("+isUndecorated()+")"+
+ ",\n AlwaysOnTop "+alwaysOnTop+", Fullscreen "+fullscreen+
+ ",\n WrappedSurface "+getWrappedSurface()+
+ ",\n ChildWindows "+childWindows.size());
sb.append(", SurfaceUpdatedListeners num "+surfaceUpdatedHelper.size()+" [");
for (int i = 0; i < surfaceUpdatedHelper.size(); i++ ) {
@@ -2138,7 +2174,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, getSurfaceWidth(), getSurfaceHeight(), getReconfigureFlags(0, isVisible()));
+ reconfigureWindowImpl(x, y, getWindowWidth(), getWindowHeight(), getReconfigureFlags(0, isVisible()));
if( null == parentWindow ) {
// Wait until custom position is reached within tolerances
waitForPosition(true, x, y, Window.TIMEOUT_NATIVEWINDOW);
@@ -2186,8 +2222,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
try {
final int oldX = getX();
final int oldY = getY();
- final int oldWidth = getSurfaceWidth();
- final int oldHeight = getSurfaceHeight();
+ final int oldWidth = getWindowWidth();
+ final int oldHeight = getWindowHeight();
int x,y,w,h;
@@ -2240,11 +2276,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
y = 0;
// refit if size is bigger than parent
- if( w > parentWindow.getSurfaceWidth() ) {
- w = parentWindow.getSurfaceWidth();
+ if( w > parentWindow.getWindowWidth() ) {
+ w = parentWindow.getWindowWidth();
}
- if( h > parentWindow.getSurfaceHeight() ) {
- h = parentWindow.getSurfaceHeight();
+ if( h > parentWindow.getWindowHeight() ) {
+ h = parentWindow.getWindowHeight();
}
}
}
@@ -2415,10 +2451,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(), getSurfaceWidth(), getSurfaceHeight());
+ final RectangleImmutable rect = new Rectangle(getX(), getY(), getWindowWidth(), getWindowHeight());
final RectangleImmutable isect = viewport.intersection(rect);
- if ( getSurfaceHeight() > isect.getHeight() ||
- getSurfaceWidth() > isect.getWidth() ) {
+ if ( getWindowHeight() > isect.getHeight() ||
+ getWindowWidth() > isect.getWidth() ) {
if(DEBUG_IMPLEMENTATION) {
System.err.println("Window.monitorModeChanged: fit window "+rect+" into screen viewport "+viewport+
", due to minimal intersection "+isect);
@@ -2441,7 +2477,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(), getSurfaceWidth(), getSurfaceHeight());
+ final RectangleImmutable rect = new Rectangle(getX(), getY(), getWindowWidth(), getWindowHeight());
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
@@ -2762,7 +2798,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
//
int x = pX[0];
int y = pY[0];
- final boolean insideWindow = x >= 0 && y >= 0 && x < getSurfaceWidth() && y < getSurfaceHeight();
+ final boolean insideSurface = x >= 0 && y >= 0 && x < getSurfaceWidth() && y < getSurfaceHeight();
final Point movePositionP0 = pState1.getMovePosition(pID[0]);
switch( eventType ) {
case MouseEvent.EVENT_MOUSE_EXITED:
@@ -2786,10 +2822,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
case MouseEvent.EVENT_MOUSE_ENTERED:
if( eventType == MouseEvent.EVENT_MOUSE_ENTERED ) {
- pState1.insideWindow = true;
+ pState1.insideSurface = true;
pState1.exitSent = false;
} else {
- pState1.insideWindow = false;
+ pState1.insideSurface = false;
pState1.exitSent = true;
}
pState1.clearButton();
@@ -2821,10 +2857,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
// Fall through intended !
default:
- if( pState1.insideWindow != insideWindow ) {
+ if( pState1.insideSurface != insideSurface ) {
// ENTER/EXIT!
- pState1.insideWindow = insideWindow;
- if( insideWindow ) {
+ pState1.insideSurface = insideSurface;
+ if( insideSurface ) {
pState1.exitSent = false;
}
pState1.clearButton();
@@ -2835,10 +2871,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
// Drop exterior events if not dragging pointer and not EXIT event
// Safeguard for non compliant implementations!
//
- if( !pState1.dragging && !insideWindow && MouseEvent.EVENT_MOUSE_EXITED != eventType ) {
+ if( !pState1.dragging && !insideSurface && MouseEvent.EVENT_MOUSE_EXITED != eventType ) {
if(DEBUG_MOUSE_EVENT) {
System.err.println("doPointerEvent: drop: "+MouseEvent.getEventTypeString(eventType)+
- ", mod "+modifiers+", pos "+x+"/"+y+", button "+button+", lastMousePosition: "+movePositionP0+", insideWindow "+insideWindow+", "+pState1);
+ ", mod "+modifiers+", pos "+x+"/"+y+", button "+button+", lastMousePosition: "+movePositionP0+", insideWindow "+insideSurface+", "+pState1);
}
return; // .. invalid ..
}
@@ -2976,7 +3012,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
//
final long when = pe.getWhen();
final int eventType = pe.getEventType();
- final boolean insideWindow;
+ final boolean insideSurface;
boolean eExitAllowed = false;
MouseEvent eEntered = null, eExited = null;
switch( eventType ) {
@@ -2994,13 +3030,13 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
y = Math.min(Math.max(y, 0), getSurfaceHeight()-1);
pState0.clearButton();
if( eventType == MouseEvent.EVENT_MOUSE_ENTERED ) {
- insideWindow = true;
- pState0.insideWindow = true;
+ insideSurface = true;
+ pState0.insideSurface = true;
pState0.exitSent = false;
pState0.dragging = false;
} else {
- insideWindow = false;
- pState0.insideWindow = false;
+ insideSurface = false;
+ pState0.insideSurface = false;
pState0.exitSent = true;
}
break;
@@ -3014,16 +3050,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
// Fall through intended !
default:
- insideWindow = x >= 0 && y >= 0 && x < getSurfaceWidth() && y < getWindowHeight();
+ insideSurface = x >= 0 && y >= 0 && x < getSurfaceWidth() && y < getSurfaceHeight();
if( pe.getPointerType(0) == PointerType.Mouse ) {
- if( !pState0.insideWindow && insideWindow ) {
+ if( !pState0.insideSurface && insideSurface ) {
// ENTER .. use clipped coordinates
eEntered = new MouseEvent(MouseEvent.EVENT_MOUSE_ENTERED, pe.getSource(), pe.getWhen(), pe.getModifiers(),
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 ) {
+ } else if( !insideSurface && eExitAllowed ) {
// EXIT .. use clipped coordinates
eExited = new MouseEvent(MouseEvent.EVENT_MOUSE_EXITED, pe.getSource(), pe.getWhen(), pe.getModifiers(),
Math.min(Math.max(x, 0), getSurfaceWidth()-1),
@@ -3032,17 +3068,17 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
pState0.exitSent = true;
}
}
- if( pState0.insideWindow != insideWindow || null != eEntered || null != eExited) {
+ if( pState0.insideSurface != insideSurface || null != eEntered || null != eExited) {
pState0.clearButton();
}
- pState0.insideWindow = insideWindow;
+ pState0.insideSurface = insideSurface;
}
if( null != eEntered ) {
if(DEBUG_MOUSE_EVENT) {
System.err.println("consumePointerEvent.send.0: "+eEntered+", "+pState0);
}
dispatchMouseEvent(eEntered);
- } else if( DEBUG_MOUSE_EVENT && !insideWindow ) {
+ } else if( DEBUG_MOUSE_EVENT && !insideSurface ) {
System.err.println("INFO consumePointerEvent.exterior: "+pState0+", "+pe);
}
@@ -3624,11 +3660,13 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
}
- /** Triggered by implementation's WM events to update the client-area size w/o insets/decorations. */
+ /** Triggered by implementation's WM events to update the client-area size in window units w/o insets/decorations. */
protected void sizeChanged(boolean defer, int newWidth, int newHeight, boolean force) {
- if(force || getSurfaceWidth() != newWidth || getSurfaceHeight() != newHeight) {
+ if(force || getWindowWidth() != newWidth || getWindowHeight() != newHeight) {
if(DEBUG_IMPLEMENTATION) {
- System.err.println("Window.sizeChanged: ("+getThreadName()+"): (defer: "+defer+") force "+force+", "+getSurfaceWidth()+"x"+getSurfaceHeight()+" -> "+newWidth+"x"+newHeight+" - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle));
+ System.err.println("Window.sizeChanged: ("+getThreadName()+"): (defer: "+defer+") force "+force+", "+
+ getWindowWidth()+"x"+getWindowHeight()+" -> "+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)");
@@ -3648,12 +3686,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!=getSurfaceWidth() && h!=getSurfaceHeight(); sleep-=10 ) {
+ for(sleep = timeOut; 0<sleep && w!=getWindowWidth() && h!=getWindowHeight(); 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 "+getSurfaceWidth()+"x"+getSurfaceHeight();
+ final String msg = "Size/Pos not reached as requested within "+timeOut+"ms : requested "+w+"x"+h+", is "+getWindowWidth()+"x"+getWindowHeight();
if(failFast) {
throw new NativeWindowException(msg);
} else if (DEBUG_IMPLEMENTATION) {
@@ -3805,10 +3843,10 @@ 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
+ * @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
*/
protected final void windowRepaint(boolean defer, int x, int y, int width, int height) {
width = ( 0 >= width ) ? getSurfaceWidth() : width;
diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java
index 8b6bb95a9..26faa4550 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.getSurfaceWidth() != cw || newtChild.getSurfaceHeight() != ch ) {
+ if( newtChild.getWindowWidth() != cw || newtChild.getWindowHeight() != 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 5fe378f2c..22294a212 100644
--- a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java
+++ b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,7 +20,7 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
@@ -50,21 +50,21 @@ import android.view.WindowManager;
public class NewtBaseActivity extends Activity {
List<Window> newtWindows = new ArrayList<Window>();
List<GLAutoDrawable> glAutoDrawables = new ArrayList<GLAutoDrawable>();
-
+
GLAnimatorControl animator = null;
-
+
boolean isDelegatedActivity;
Activity rootActivity;
boolean setThemeCalled = false;
-
+
protected void startAnimation(boolean start) {
if(null != animator) {
final boolean res;
if( start ) {
- if( animator.isPaused() ) {
- res = animator.resume();
- } else {
- res = animator.start();
+ if( animator.isPaused() ) {
+ res = animator.resume();
+ } else {
+ res = animator.start();
}
} else {
res = animator.stop();
@@ -76,10 +76,10 @@ public class NewtBaseActivity extends Activity {
if(null != anim) {
final boolean res;
if( start ) {
- if( anim.isPaused() ) {
- res = anim.resume();
- } else {
- res = anim.start();
+ if( anim.isPaused() ) {
+ res = anim.resume();
+ } else {
+ res = anim.start();
}
} else {
res = anim.stop();
@@ -88,32 +88,32 @@ public class NewtBaseActivity extends Activity {
}
}
}
-
+
public NewtBaseActivity() {
super();
isDelegatedActivity = false;
rootActivity = this;
}
-
+
public void setRootActivity(Activity rootActivity) {
this.rootActivity = rootActivity;
this.isDelegatedActivity = this != rootActivity;
}
-
+
public final boolean isDelegatedActivity() {
return isDelegatedActivity;
}
-
+
public final Activity getActivity() {
return rootActivity;
- }
-
+ }
+
/**
* This is one of the three registration methods (see below).
* <p>
* This methods issues {@link android.view.Window#setContentView(android.view.View, android.view.ViewGroup.LayoutParams) androidWindow.setContenView(newtWindow.getAndroidView())}
* and finally calls {@link #registerNEWTWindow(Window)}.
- * </p>
+ * </p>
* @param androidWindow
* @param newtWindow
* @throws IllegalArgumentException if the <code>newtWindow</code>'s {@link Window#getDelegatedWindow() delegate} is not an AndroidDriver.
@@ -128,7 +128,7 @@ public class NewtBaseActivity extends Activity {
final WindowDriver newtAWindow = (WindowDriver)delegateWindow;
androidWindow.setContentView(newtAWindow.getAndroidView());
} else {
- throw new IllegalArgumentException("Given NEWT Window is not an Android Window: "+newtWindow.getClass().getName());
+ throw new IllegalArgumentException("Given NEWT Window is not an Android Window: "+newtWindow.getClass().getName());
}
registerNEWTWindow(newtWindow);
}
@@ -137,7 +137,7 @@ public class NewtBaseActivity extends Activity {
* <p>
* This methods issues {@link android.view.Window#addContentView(android.view.View, android.view.ViewGroup.LayoutParams) androidWindow.addContenView(newtWindow.getAndroidView(), params)}
* and finally calls {@link #registerNEWTWindow(Window)}.
- * </p>
+ * </p>
* @param androidWindow
* @param newtWindow
* @param params
@@ -151,8 +151,8 @@ public class NewtBaseActivity extends Activity {
final WindowDriver newtAWindow = (WindowDriver)delegateWindow;
androidWindow.addContentView(newtAWindow.getAndroidView(), params);
} else {
- throw new IllegalArgumentException("Given NEWT Window's Delegate is not an Android Window: "+delegateWindow.getClass().getName());
- }
+ throw new IllegalArgumentException("Given NEWT Window's Delegate is not an Android Window: "+delegateWindow.getClass().getName());
+ }
registerNEWTWindow(newtWindow);
}
/**
@@ -161,15 +161,15 @@ public class NewtBaseActivity extends Activity {
* This methods registers the given NEWT window to ensure it's destruction at {@link #onDestroy()}.
* </p>
* <p>
- * If adding a {@link GLAutoDrawable} implementation, the {@link GLAnimatorControl} retrieved by {@link GLAutoDrawable#getAnimator()}
+ * If adding a {@link GLAutoDrawable} implementation, the {@link GLAnimatorControl} retrieved by {@link GLAutoDrawable#getAnimator()}
* will be used for {@link #onPause()} and {@link #onResume()}.
* </p>
* <p>
- * If adding a {@link GLAutoDrawable} implementation, the {@link GLEventListenerState} will preserve it's state
- * when {@link #onPause()} is being called while not {@link #isFinishing()}. A later {@link #onResume()} will
+ * If adding a {@link GLAutoDrawable} implementation, the {@link GLEventListenerState} will preserve it's state
+ * when {@link #onPause()} is being called while not {@link #isFinishing()}. A later {@link #onResume()} will
* reinstate the {@link GLEventListenerState}.
* </p>
- *
+ *
* @param newtWindow
* @throws IllegalArgumentException if the <code>newtWindow</code>'s {@link Window#getDelegatedWindow() delegate} is not an AndroidDriver.
* @see #setContentView(android.view.Window, Window)
@@ -182,8 +182,8 @@ public class NewtBaseActivity extends Activity {
final WindowDriver newtAWindow = (WindowDriver)delegateWindow;
newtAWindow.registerActivity(getActivity());
} else {
- throw new IllegalArgumentException("Given NEWT Window's Delegate is not an Android Window: "+delegateWindow.getClass().getName());
- }
+ throw new IllegalArgumentException("Given NEWT Window's Delegate is not an Android Window: "+delegateWindow.getClass().getName());
+ }
newtWindows.add(newtWindow);
if(newtWindow instanceof GLAutoDrawable) {
glAutoDrawables.add((GLAutoDrawable)newtWindow);
@@ -203,9 +203,9 @@ public class NewtBaseActivity extends Activity {
startAnimation(true);
}
};
-
+
/**
- * Convenient method to set the Android window's flags to fullscreen or size-layout depending on the given NEWT window.
+ * Convenient method to set the Android window's flags to fullscreen or size-layout depending on the given NEWT window.
* <p>
* Must be called before creating the view and adding any content, i.e. setContentView() !
* </p>
@@ -216,7 +216,7 @@ public class NewtBaseActivity extends Activity {
if(null == androidWindow || null == newtWindow) {
throw new IllegalArgumentException("Android or NEWT Window null");
}
-
+
if( newtWindow.isFullscreen() || newtWindow.isUndecorated() ) {
androidWindow.requestFeature(android.view.Window.FEATURE_NO_TITLE);
}
@@ -225,16 +225,16 @@ public class NewtBaseActivity extends Activity {
androidWindow.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
} else {
androidWindow.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
- androidWindow.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ androidWindow.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ }
+
+ if(newtWindow.getWindowWidth()>0 && newtWindow.getWindowHeight()>0 && !newtWindow.isFullscreen()) {
+ androidWindow.setLayout(newtWindow.getWindowWidth(), newtWindow.getWindowHeight());
}
-
- if(newtWindow.getSurfaceWidth()>0 && newtWindow.getSurfaceHeight()>0 && !newtWindow.isFullscreen()) {
- androidWindow.setLayout(newtWindow.getSurfaceWidth(), newtWindow.getSurfaceHeight());
- }
}
/**
- * Convenient method to set the Android window's flags to fullscreen or size-layout depending on the given NEWT window.
+ * Convenient method to set the Android window's flags to fullscreen or size-layout depending on the given NEWT window.
* <p>
* Must be called before creating the view and adding any content, i.e. setContentView() !
* </p>
@@ -245,7 +245,7 @@ public class NewtBaseActivity extends Activity {
if(null == androidWindow) {
throw new IllegalArgumentException("Android or Window null");
}
-
+
if( fullscreen ) {
androidWindow.requestFeature(android.view.Window.FEATURE_NO_TITLE);
androidWindow.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
@@ -255,9 +255,9 @@ public class NewtBaseActivity extends Activity {
androidWindow.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
-
+
/**
- * Convenient method to set this context's theme to transparency depending on {@link CapabilitiesImmutable#isBackgroundOpaque()}.
+ * Convenient method to set this context's theme to transparency depending on {@link CapabilitiesImmutable#isBackgroundOpaque()}.
* <p>
* Must be called before creating the view and adding any content, i.e. setContentView() !
* </p>
@@ -267,7 +267,7 @@ public class NewtBaseActivity extends Activity {
setTransparencyTheme();
}
}
-
+
/**
* Convenient method to set this context's theme to transparency.
* <p>
@@ -279,12 +279,12 @@ public class NewtBaseActivity extends Activity {
* </p>
* <p>
* Can be called only once.
- * </p>
+ * </p>
*/
public void setTransparencyTheme() {
if(!setThemeCalled) {
setThemeCalled = true;
- final Context ctx = getActivity().getApplicationContext();
+ final Context ctx = getActivity().getApplicationContext();
final String frn = ctx.getPackageName()+":style/Theme.Transparent";
final int resID = ctx.getResources().getIdentifier("Theme.Transparent", "style", ctx.getPackageName());
if(0 == resID) {
@@ -295,14 +295,14 @@ public class NewtBaseActivity extends Activity {
}
}
}
-
+
/**
* Setting up a global {@Link GLAnimatorControl} for {@link #onPause()} and {@link #onResume()}.
* <p>
* Note that if adding a {@link GLAutoDrawable} implementation via {@link #registerNEWTWindow(Window)},
* {@link #setContentView(android.view.Window, Window)} or {@link #addContentView(android.view.Window, Window, android.view.ViewGroup.LayoutParams)}
* their {@link GLAnimatorControl} retrieved by {@link GLAutoDrawable#getAnimator()} will be used as well.
- * In this case, using this global {@Link GLAnimatorControl} is redundant.
+ * In this case, using this global {@Link GLAnimatorControl} is redundant.
* </p>
* @see #registerNEWTWindow(Window)
* @see #setContentView(android.view.Window, Window)
@@ -315,7 +315,7 @@ public class NewtBaseActivity extends Activity {
}
animator.pause();
}
-
+
@Override
public android.view.Window getWindow() {
if( isDelegatedActivity() ) {
@@ -324,22 +324,22 @@ public class NewtBaseActivity extends Activity {
return super.getWindow();
}
}
-
+
@Override
public void onCreate(Bundle savedInstanceState) {
Log.d(MD.TAG, "onCreate.0");
if(!isDelegatedActivity()) {
super.onCreate(savedInstanceState);
}
- // Extraordinary cleanup, for cases of 'onCreate()' calls w/ valid states,
+ // Extraordinary cleanup, for cases of 'onCreate()' calls w/ valid states,
// i.e. w/o having onDestroy() being called.
// Could happened due to spec when App process is killed for memory exhaustion or other reasons.
cleanup();
-
+
jogamp.common.os.android.StaticContext.init(rootActivity.getApplicationContext());
Log.d(MD.TAG, "onCreate.X");
}
-
+
@Override
public void onStart() {
Log.d(MD.TAG, "onStart.0");
@@ -348,7 +348,7 @@ public class NewtBaseActivity extends Activity {
}
Log.d(MD.TAG, "onStart.X");
}
-
+
@Override
public void onRestart() {
Log.d(MD.TAG, "onRestart.0");
@@ -407,11 +407,11 @@ public class NewtBaseActivity extends Activity {
win.setVisible(false);
}
if( !isDelegatedActivity() ) {
- super.onStop();
+ super.onStop();
}
Log.d(MD.TAG, "onStop.X");
}
-
+
/**
* Performs cleaning up all references,
* <p>
@@ -450,14 +450,14 @@ public class NewtBaseActivity extends Activity {
jogamp.common.os.android.StaticContext.clear();
Log.d(MD.TAG, "cleanup.X");
}
-
+
@Override
public void onDestroy() {
Log.d(MD.TAG, "onDestroy.0");
cleanup(); // normal cleanup
if(!isDelegatedActivity()) {
- super.onDestroy();
+ super.onDestroy();
}
Log.d(MD.TAG, "onDestroy.X");
- }
+ }
}
diff --git a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java
index 20163f96c..93ff0c1e0 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(getSurfaceWidth(), getSurfaceHeight(), Gravity.BOTTOM|Gravity.RIGHT));
+ viewGroup.addView(androidView, new android.widget.FrameLayout.LayoutParams(getWindowWidth(), getWindowHeight(), 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 ) {
@@ -462,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(getSurfaceWidth() != width || getSurfaceHeight() != height) {
+ if(getWindowWidth() != width || getWindowHeight() != height) {
if(0!=getWindowHandle()) {
Log.d(MD.TAG, "reconfigureWindowImpl.setSize n/a");
res = false;
@@ -548,7 +548,8 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 {
@Override
public final void surfaceCreated(SurfaceHolder holder) {
- Log.d(MD.TAG, "surfaceCreated: "+getX()+"/"+getY()+" "+getSurfaceWidth()+"x"+getSurfaceHeight()+" - on thread "+Thread.currentThread().getName());
+ Log.d(MD.TAG, "surfaceCreated: win["+getX()+"/"+getY()+" "+getWindowWidth()+"x"+getWindowHeight()+
+ "], pixels["+" "+getSurfaceWidth()+"x"+getSurfaceHeight()+"] - on thread "+Thread.currentThread().getName());
}
@Override
@@ -586,15 +587,15 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 {
nativeFormat = getSurfaceVisualID0(surfaceHandle);
Log.d(MD.TAG, "surfaceChanged: androidFormat "+androidFormat+" -- (set-native "+aNativeWindowFormat+") --> nativeFormat "+nativeFormat);
- final int nWidth = getWidth0(surfaceHandle);
- final int nHeight = getHeight0(surfaceHandle);
+ final int[] newSurfSize = { getWidth0(surfaceHandle), getHeight0(surfaceHandle) };
+ final int[] newWinSize = convertToWindowUnits(new int[]{ newSurfSize[0], newSurfSize[1] }); // HiDPI: Not necessary yet ..
capsByFormat = (GLCapabilitiesImmutable) fixCaps(true /* matchFormatPrecise */, nativeFormat, getRequestedCapabilities());
- sizeChanged(false, nWidth, nHeight, false);
+ sizeChanged(false, newWinSize[0], newWinSize[1], false);
Log.d(MD.TAG, "surfaceRealized: isValid: "+surface.isValid()+
", new surfaceHandle 0x"+Long.toHexString(surfaceHandle)+
- ", format [a "+androidFormat+"/n "+nativeFormat+"], "+
- getX()+"/"+getY()+" "+nWidth+"x"+nHeight+", visible: "+isVisible());
+ ", format [a "+androidFormat+"/n "+nativeFormat+"], win["+
+ getX()+"/"+getY()+" "+newWinSize[0]+"x"+newWinSize[1]+"], pixel["+newSurfSize[0]+"x"+newSurfSize[1]+"], visible: "+isVisible());
if(isVisible()) {
setVisible(false, true);
diff --git a/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java
index 965426d4e..f99476851 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(), getSurfaceWidth(), getSurfaceHeight(), getReconfigureFlags(FLAG_CHANGE_VISIBILITY | FLAG_CHANGE_DECORATION, true));
+ reconfigureWindowImpl(getX(), getY(), getWindowWidth(), getWindowHeight(), getReconfigureFlags(FLAG_CHANGE_VISIBILITY | FLAG_CHANGE_DECORATION, true));
// throws exception if failed ..
final NativeWindow nw = awtCanvas.getNativeWindow();
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 5b0d21c66..be7e8fd07 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, getSurfaceWidth(), getSurfaceHeight()));
+ setWindowHandle(realizeWindow(true, getWindowWidth(), getWindowHeight()));
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:getSurfaceWidth(), (height>0)?height:getSurfaceHeight());
+ defineSize((width>0)?width:getWindowWidth(), (height>0)?height:getWindowHeight());
}
}
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 817ce3aeb..1c927acc4 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(), getSurfaceWidth(), getSurfaceHeight(),
+ nativeWindowHandle = CreateWindow0(display.getBCMHandle(), layer, getX(), getY(), getWindowWidth(), getWindowHeight(),
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 d86cf7471..7e15d0258 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,8 @@ 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(), getSurfaceWidth(), getSurfaceHeight());
+ surfaceHandle = CreateSurface(aDevice.getHandle(), getScreen().getWidth(), getScreen().getHeight(),
+ getX(), getY(), getWindowWidth(), getWindowHeight());
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 35e9227d3..0b909bc08 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:getSurfaceWidth();
- height=(height>0)?height:getSurfaceHeight();
+ width=(width>0)?width:getWindowWidth();
+ height=(height>0)?height:getWindowHeight();
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(getSurfaceWidth(), getSurfaceHeight());
+ ((ScreenDriver)getScreen()).sizeChanged(getWindowWidth(), getWindowHeight());
}
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 8f3eb1e89..eebf280de 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(), getSurfaceWidth(), getSurfaceHeight(), getReconfigureFlags(FLAG_CHANGE_VISIBILITY, true));
+ reconfigureWindowImpl(getX(), getY(), getWindowWidth(), getWindowHeight(), getReconfigureFlags(FLAG_CHANGE_VISIBILITY, true));
if (0 == getWindowHandle()) {
throw new NativeWindowException("Error creating window");
}
@@ -210,6 +210,16 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
private boolean useParent(NativeWindow parent) { return null != parent && 0 != parent.getWindowHandle(); }
@Override
+ protected final int getPixelScaleX() {
+ return 1; // FIXME HiDPI: Use pixelScale
+ }
+
+ @Override
+ protected final int getPixelScaleY() {
+ return 1; // FIXME HiDPI: Use pixelScale
+ }
+
+ @Override
public void updatePosition(int x, int y) {
final long handle = getWindowHandle();
if( 0 != handle && !isOffscreenInstance ) {
@@ -236,7 +246,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
if( 0 != handle && !isOffscreenInstance ) {
final NativeWindow parent = getParent();
final boolean useParent = useParent(parent);
- if( useParent && ( getSurfaceWidth() != newWidth || getSurfaceHeight() != newHeight ) ) {
+ if( useParent && ( getWindowWidth() != newWidth || getWindowHeight() != 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 0fc38f92d..541247efd 100644
--- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java
@@ -145,7 +145,8 @@ 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(), getSurfaceWidth(), getSurfaceHeight(), autoPosition(), flags);
+ getParentWindowHandle(),
+ getX(), getY(), getWindowWidth(), getWindowHeight(), autoPosition(), flags);
if ( 0 == _windowHandle ) {
throw new NativeWindowException("Error creating window");
}
@@ -250,7 +251,7 @@ public class WindowDriver extends WindowImpl {
this.runOnEDTIfAvail(true, new Runnable() {
@Override
public void run() {
- final Point p0 = getLocationOnScreenImpl(0, 0);
+ final Point p0 = convertToPixelUnits( getLocationOnScreenImpl(0, 0) );
res[0] = Boolean.valueOf(confinePointer0(getWindowHandle(), confine,
p0.getX(), p0.getY(), p0.getX()+getSurfaceWidth(), p0.getY()+getSurfaceHeight()));
}
diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java
index 2f4ccbfea..9538f31a2 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(), getSurfaceWidth(), getSurfaceHeight(), autoPosition(), flags,
+ getX(), getY(), getWindowWidth(), getWindowHeight(), 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(), getSurfaceWidth(), getSurfaceHeight(), flags);
+ getX(), getY(), getWindowWidth(), getWindowHeight(), flags);
return null;
}
});