diff options
Diffstat (limited to 'src/newt')
12 files changed, 153 insertions, 80 deletions
diff --git a/src/newt/classes/com/jogamp/newt/MonitorDevice.java b/src/newt/classes/com/jogamp/newt/MonitorDevice.java index 1198f7681..af0ce0146 100644 --- a/src/newt/classes/com/jogamp/newt/MonitorDevice.java +++ b/src/newt/classes/com/jogamp/newt/MonitorDevice.java @@ -170,7 +170,7 @@ public abstract class MonitorDevice { /** * Returns the {@link RectangleImmutable rectangular} portion - * of the rotated virtual {@link Screen} size in screen/window units + * of the rotated virtual {@link Screen} size in pixel units * represented by this monitor. */ public final RectangleImmutable getViewport() { @@ -178,10 +178,12 @@ public abstract class MonitorDevice { } /** - * Returns <code>true</code> if given screen coordinates in screen/window units + * Returns <code>true</code> if given screen coordinates in pixel units * are contained by this {@link #getViewport() viewport}, otherwise <code>false</code>. + * @param x x-coord in pixel units + * @param y y-coord in pixel units */ - public final boolean contains(int x, int y) { + public final boolean contains(final int x, final int y) { return x >= viewport.getX() && x < viewport.getX() + viewport.getWidth() && y >= viewport.getY() && @@ -189,7 +191,8 @@ public abstract class MonitorDevice { } /** - * Returns the coverage of given rectangle w/ this this {@link #getViewport() viewport}, i.e. between <code>0.0</code> and <code>1.0</code>. + * Returns the coverage of given rectangle in pixel units + * w/ this {@link #getViewport() viewport}, i.e. between <code>0.0</code> and <code>1.0</code>. * <p> * Coverage is computed by: * <pre> @@ -197,16 +200,17 @@ public abstract class MonitorDevice { * coverage = area( isect ) / area( viewport ) ; * </pre> * </p> + * @param r {@link RectangleImmutable rectangle} in pixel units */ - public final float coverage(RectangleImmutable r) { + public final float coverage(final RectangleImmutable r) { return viewport.coverage(r); } /** - * Returns the union of the given monitor's {@link #getViewport() viewport}. + * Returns the union of the given monitor's {@link #getViewport() viewport} in pixel units. * @param result storage for result, will be returned * @param monitors given list of monitors - * @return viewport representing the union of given monitor's viewport. + * @return viewport representing the union of given monitor's viewport in pixel units, i.e. result storage for chaining */ public static Rectangle unionOfViewports(final Rectangle result, final List<MonitorDevice> monitors) { int x1=Integer.MAX_VALUE, y1=Integer.MAX_VALUE; diff --git a/src/newt/classes/com/jogamp/newt/MonitorMode.java b/src/newt/classes/com/jogamp/newt/MonitorMode.java index 9690f18db..ba21df22a 100644 --- a/src/newt/classes/com/jogamp/newt/MonitorMode.java +++ b/src/newt/classes/com/jogamp/newt/MonitorMode.java @@ -51,7 +51,7 @@ import com.jogamp.newt.util.MonitorModeUtil; * <ul> * <li>A List of all {@link MonitorDevice}s is accessible via {@link Screen#getMonitorDevices()}.</li> * <li>The main monitor used by a windows is accessible via {@link Window#getMainMonitor()}.</li> - * <li>The main monitor covering an arbitrary rectnagle is accessible via {@link Screen#getMainMonitor(RectangleImmutable)}.</li> + * <li>The main monitor covering an arbitrary rectangle is accessible via {@link Screen#getMainMonitor(RectangleImmutable)}.</li> * </ul></li> * <li>The current MonitorMode can be obtained via {@link MonitorDevice#getCurrentMode()}.</li> * <li>The original MonitorMode can be obtained via {@link MonitorDevice#getOriginalMode()}.</li> @@ -88,8 +88,8 @@ import com.jogamp.newt.util.MonitorModeUtil; MonitorMode mmCurrent = monitor.queryCurrentMode(); MonitorMode mmOrig = monitor.getOriginalMode(); - // Target resolution - Dimension res = new Dimension(800, 600); + // Target resolution in pixel units + DimensionImmutable res = new Dimension(800, 600); // Target refresh rate shall be similar to current one .. float freq = mmCurrent.getRefreshRate(); @@ -136,7 +136,7 @@ public class MonitorMode implements Comparable<MonitorMode> { * </ul> */ public static class SizeAndRRate implements Comparable<SizeAndRRate> { - /** Non rotated surface size */ + /** Non rotated surface size in pixel units */ public final SurfaceSize surfaceSize; /** Mode bitfield flags, i.e. {@link #FLAG_DOUBLESCAN}, {@link #FLAG_INTERLACE}, .. */ public final int flags; @@ -349,7 +349,7 @@ public class MonitorMode implements Comparable<MonitorMode> { return rotation; } - /** Returns the rotated screen width, + /** Returns the rotated screen width in pixel units, * derived from <code>getMonitorMode().getSurfaceSize().getResolution()</code> * and <code>getRotation()</code> */ @@ -357,7 +357,7 @@ public class MonitorMode implements Comparable<MonitorMode> { return getRotatedWH(true); } - /** Returns the rotated screen height, + /** Returns the rotated screen height in pixel units, * derived from <code>getMonitorMode().getSurfaceSize().getResolution()</code> * and <code>getRotation()</code> */ diff --git a/src/newt/classes/com/jogamp/newt/Screen.java b/src/newt/classes/com/jogamp/newt/Screen.java index 2a713c538..919b98b45 100644 --- a/src/newt/classes/com/jogamp/newt/Screen.java +++ b/src/newt/classes/com/jogamp/newt/Screen.java @@ -131,31 +131,42 @@ public abstract class Screen { public abstract int getIndex(); /** - * @return the x position of the virtual viewport's top-left origin in screen/window units. + * @return the x position of the virtual viewport's top-left origin in pixel units. */ public abstract int getX(); /** - * @return the y position of the virtual viewport's top-left origin in screen/window units. + * @return the y position of the virtual viewport's top-left origin in pixel units. */ public abstract int getY(); /** - * @return the <b>rotated</b> virtual viewport's width in screen/window units. + * @return the <b>rotated</b> virtual viewport's width in pixel units. */ public abstract int getWidth(); /** - * @return the <b>rotated</b> virtual viewport's height in screen/window units. + * @return the <b>rotated</b> virtual viewport's height in pixel units. */ public abstract int getHeight(); /** - * @return the <b>rotated</b> virtual viewport, i.e. origin and size in screen/window units. + * @return the <b>rotated</b> virtual viewport, i.e. origin and size in pixel units. + * @see #getViewportInWindowUnits(Window) */ public abstract RectangleImmutable getViewport(); /** + * Returns a newly created {@link Rectangle} containing the <b>rotated</b> virtual viewport + * in window units of the given {@link Window} instance. + * @return rotated viewport values, i.e. origin and size, in pixel units. + * @see #getViewport() + */ + public final Rectangle getViewportInWindowUnits(final Window win) { + return win.convertToWindowUnits( (Rectangle) getViewport().cloneMutable() ); + } + + /** * @return the associated Display */ public abstract Display getDisplay(); @@ -181,14 +192,14 @@ public abstract class Screen { public abstract List<MonitorDevice> getMonitorDevices(); /** - * Returns the {@link MonitorDevice} which {@link MonitorDevice#getViewport() viewport} - * {@link MonitorDevice#coverage(RectangleImmutable) covers} the given rectangle the most. + * Returns the {@link MonitorDevice} with the highest {@link MonitorDevice#getViewport() viewport} + * {@link MonitorDevice#coverage(RectangleImmutable) coverage} of the given rectangle in pixel units. * <p> * If no coverage is detected the first {@link MonitorDevice} is returned. * </p> - * @param r arbitrary rectangle in screen/window units + * @param r arbitrary rectangle in pixel units */ - public final MonitorDevice getMainMonitor(RectangleImmutable r) { + public final MonitorDevice getMainMonitor(final RectangleImmutable r) { MonitorDevice res = null; float maxCoverage = Float.MIN_VALUE; final List<MonitorDevice> monitors = getMonitorDevices(); @@ -207,7 +218,7 @@ public abstract class Screen { } /** - * Returns the union of all monitor's {@link MonitorDevice#getViewport() viewport} in screen/window units. + * Returns the union of all monitor's {@link MonitorDevice#getViewport() viewport} in pixel 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. diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index b733406e8..872d67087 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -47,6 +47,7 @@ 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.Rectangle; import javax.media.nativewindow.util.RectangleImmutable; /** @@ -233,6 +234,18 @@ public interface Window extends NativeWindow, WindowClosingProtocol { // /** + * Returns a newly created {@link Rectangle} containing window origin, {@link #getX()} & {@link #getY()}, + * and size, {@link #getWidth()} & {@link #getHeight()}, in window units. + */ + Rectangle getBounds(); + + /** + * Returns a newly created {@link Rectangle} containing the scaled window origin, {@link #getX()} & {@link #getY()}, + * and size, {@link #getSurfaceWidth()} & {@link #getSurfaceHeight()}, in pixel units. + */ + Rectangle getSurfaceBounds(); + + /** * Sets the size of the window's client area in window units, excluding decorations. * * <p> @@ -329,19 +342,19 @@ public interface Window extends NativeWindow, WindowClosingProtocol { /** * Converts the given pixel units into window units <i>in place</i>. - * @param pixelUnitsAndResult point storage holding the pixel units to convert + * @param pixelUnitsAndResult rectangle storage holding the pixel units to convert * and the resulting conversion. - * @return resulting point storage pixelUnitsAndResult for chaining holding the converted values + * @return resulting rectangle storage pixelUnitsAndResult for chaining holding the converted values */ - Point convertToWindowUnits(final Point pixelUnitsAndResult); + Rectangle convertToWindowUnits(final Rectangle pixelUnitsAndResult); /** * Converts the given window units into pixel units <i>in place</i>. - * @param windowUnitsAndResult point storage holding the window units to convert + * @param windowUnitsAndResult rectangle storage holding the window units to convert * and the resulting conversion. - * @return resulting point storage windowUnitsAndResult for chaining holding the converted values + * @return resulting rectangle storage windowUnitsAndResult for chaining holding the converted values */ - Point convertToPixelUnits(final Point windowUnitsAndResult); + Rectangle convertToPixelUnits(final Rectangle windowUnitsAndResult); void setUndecorated(boolean value); diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 7ba4bddf0..ecd50aa5f 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -47,6 +47,7 @@ import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.SurfaceUpdatedListener; import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; +import javax.media.nativewindow.util.Rectangle; import javax.media.opengl.FPSCounter; import javax.media.opengl.GL; import javax.media.opengl.GL3; @@ -363,33 +364,43 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind } @Override - public final int[] convertToWindowUnits(final int[] pixelUnitsAndResult) { - return window.convertToWindowUnits(pixelUnitsAndResult); + public final Rectangle getBounds() { + return window.getBounds(); } @Override - public final int[] convertToPixelUnits(final int[] windowUnitsAndResult) { - return window.convertToPixelUnits(windowUnitsAndResult); + public final int getSurfaceWidth() { + return window.getSurfaceWidth(); + } + + @Override + public final int getSurfaceHeight() { + return window.getSurfaceHeight(); } @Override - public final Point convertToWindowUnits(final Point pixelUnitsAndResult) { + public final Rectangle getSurfaceBounds() { + return window.getSurfaceBounds(); + } + + @Override + public final int[] convertToWindowUnits(final int[] pixelUnitsAndResult) { return window.convertToWindowUnits(pixelUnitsAndResult); } @Override - public final Point convertToPixelUnits(final Point windowUnitsAndResult) { + public final int[] convertToPixelUnits(final int[] windowUnitsAndResult) { return window.convertToPixelUnits(windowUnitsAndResult); } @Override - public final int getSurfaceWidth() { - return window.getSurfaceWidth(); + public final Rectangle convertToWindowUnits(final Rectangle pixelUnitsAndResult) { + return window.convertToWindowUnits(pixelUnitsAndResult); } @Override - public final int getSurfaceHeight() { - return window.getSurfaceHeight(); + public final Rectangle convertToPixelUnits(final Rectangle windowUnitsAndResult) { + return window.convertToPixelUnits(windowUnitsAndResult); } @Override diff --git a/src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java b/src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java index fdd7985fe..e019068f5 100644 --- a/src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java +++ b/src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java @@ -157,7 +157,7 @@ public class MonitorModeUtil { /** * @param monitorModes - * @param resolution + * @param resolution in pixel units * @return modes with nearest resolution, or matching ones. May return zero sized list for non. */ public static List<MonitorMode> filterByResolution(List<MonitorMode> monitorModes, DimensionImmutable resolution) { diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index b127426a8..6a5fc5de0 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -912,7 +912,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer @Override public final MonitorDevice getMainMonitor() { - return screen.getMainMonitor(new Rectangle(getX(), getY(), getWindowWidth(), getWindowHeight())); + return screen.getMainMonitor( getSurfaceBounds() ); } /** @@ -1071,8 +1071,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override public final void setSurfaceSize(final int pixelWidth, final int pixelHeight) { - final int[] winSize = convertToWindowUnits(new int[]{pixelWidth, pixelHeight}); - setSize(winSize[0], winSize[1]); + // FIXME HiDPI: Shortcut, may need to adjust if we change scaling methodology + setSize(pixelWidth * getPixelScaleX(), pixelHeight * getPixelScaleY()); } @Override public final void setTopLevelSize(final int width, final int height) { @@ -1877,13 +1877,13 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public final int getSurfaceWidth() { - return pixWidth; + public final int getX() { + return x; } @Override - public final int getSurfaceHeight() { - return pixHeight; + public final int getY() { + return y; } @Override @@ -1897,6 +1897,27 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override + public final Rectangle getBounds() { + return new Rectangle(x, y, winWidth, winHeight); + } + + @Override + public final int getSurfaceWidth() { + return pixWidth; + } + + @Override + public final int getSurfaceHeight() { + return pixHeight; + } + + @Override + public final Rectangle getSurfaceBounds() { + // FIXME HiDPI: Shortcut, may need to adjust if we change scaling methodology + return new Rectangle(x * getPixelScaleX(), y * getPixelScaleY(), pixWidth, pixHeight); + } + + @Override public final int[] convertToWindowUnits(final int[] pixelUnitsAndResult) { pixelUnitsAndResult[0] /= getPixelScaleX(); pixelUnitsAndResult[1] /= getPixelScaleY(); @@ -1910,29 +1931,29 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return windowUnitsAndResult; } - @Override - public final Point convertToWindowUnits(final Point pixelUnitsAndResult) { + protected final Point convertToWindowUnits(final Point pixelUnitsAndResult) { return pixelUnitsAndResult.scaleInv(getPixelScaleX(), getPixelScaleY()); } - @Override - public final Point convertToPixelUnits(final Point windowUnitsAndResult) { + protected 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; + public final Rectangle convertToWindowUnits(final Rectangle pixelUnitsAndResult) { + return pixelUnitsAndResult.scaleInv(getPixelScaleX(), getPixelScaleY()); } @Override - public final int getY() { - return y; + public final Rectangle convertToPixelUnits(final Rectangle windowUnitsAndResult) { + return windowUnitsAndResult.scale(getPixelScaleX(), getPixelScaleY()); } + /** HiDPI: We currently base scaling of window units to pixel units on an integer scale factor per component. */ + protected int getPixelScaleX() { return 1; } + /** HiDPI: We currently base scaling of window units to pixel units on an integer scale factor per component. */ + protected int getPixelScaleY() { return 1; } + protected final boolean autoPosition() { return autoPosition; } /** Sets the position fields {@link #x} and {@link #y} in window units to the given values and {@link #autoPosition} to false. */ @@ -1950,14 +1971,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * 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 }); + final int pixWidth = winWidth * getPixelScaleX(); // FIXME HiDPI: Shortcut, may need to adjust if we change scaling methodology + final int pixHeight = winHeight * getPixelScaleY(); if(DEBUG_IMPLEMENTATION) { System.err.println("defineSize: win["+this.winWidth+"x"+this.winHeight+" -> "+winWidth+"x"+winHeight+ - "], pixel["+this.pixWidth+"x"+this.pixHeight+" -> "+pixelSize[0]+"x"+pixelSize[1]+"]"); + "], pixel["+this.pixWidth+"x"+this.pixHeight+" -> "+pixWidth+"x"+pixHeight+"]"); // Thread.dumpStack(); } this.winWidth = winWidth; this.winHeight = winHeight; - this.pixWidth = pixelSize[0]; this.pixHeight = pixelSize[0]; + this.pixWidth = pixWidth; this.pixHeight = pixHeight; } @Override @@ -2227,7 +2249,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer int x,y,w,h; - final RectangleImmutable sviewport = screen.getViewport(); + final RectangleImmutable sviewport = screen.getViewportInWindowUnits(WindowImpl.this); final RectangleImmutable viewport; final int fs_span_flag; final boolean alwaysOnTopChange; @@ -2240,7 +2262,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer fullscreenMonitors = getScreen().getMonitorDevices(); } } - viewport = MonitorDevice.unionOfViewports(new Rectangle(), fullscreenMonitors); + viewport = convertToWindowUnits(MonitorDevice.unionOfViewports(new Rectangle(), fullscreenMonitors)); if( isReconfigureFlagSupported(FLAG_IS_FULLSCREEN_SPAN) && ( fullscreenMonitors.size() > 1 || sviewport.compareTo(viewport) > 0 ) ) { fs_span_flag = FLAG_IS_FULLSCREEN_SPAN; @@ -2292,7 +2314,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(DEBUG_IMPLEMENTATION) { System.err.println("Window fs: "+_fullscreen+" "+x+"/"+y+" "+w+"x"+h+", "+isUndecorated()+ - ", virtl-screenSize: "+sviewport+", monitorsViewport "+viewport+ + ", virtl-screenSize: "+sviewport+" [wu], monitorsViewport "+viewport+" [wu]"+ ", spanning "+(0!=fs_span_flag)+ ", alwaysOnTop "+alwaysOnTop+(alwaysOnTopChange?"*":"")+ ", wasVisible "+wasVisible+", tempInvisible "+tempInvisible+ @@ -2449,7 +2471,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } if( !fullscreen && !fullscreenPaused ) { // Simply move/resize window to fit in virtual screen if required - final RectangleImmutable viewport = screen.getViewport(); + final RectangleImmutable viewport = screen.getViewportInWindowUnits(WindowImpl.this); if( viewport.getWidth() > 0 && viewport.getHeight() > 0 ) { // failsafe final RectangleImmutable rect = new Rectangle(getX(), getY(), getWindowWidth(), getWindowHeight()); final RectangleImmutable isect = viewport.intersection(rect); @@ -2475,7 +2497,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // If changed monitor is part of this fullscreen mode, reset size! (Bug 771) final MonitorDevice md = me.getMonitor(); if( fullscreenMonitors.contains(md) ) { - final RectangleImmutable viewport = MonitorDevice.unionOfViewports(new Rectangle(), fullscreenMonitors); + final RectangleImmutable viewport = convertToWindowUnits(MonitorDevice.unionOfViewports(new Rectangle(), fullscreenMonitors)); if(DEBUG_IMPLEMENTATION) { 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); diff --git a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java index 93ff0c1e0..7a571318b 100644 --- a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java @@ -41,6 +41,7 @@ import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.VisualIDHolder; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.Point; +import javax.media.nativewindow.util.Rectangle; import javax.media.nativewindow.util.RectangleImmutable; import javax.media.opengl.GLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesImmutable; @@ -54,7 +55,6 @@ import jogamp.opengl.egl.EGL; import jogamp.opengl.egl.EGLDisplayUtil; import jogamp.opengl.egl.EGLGraphicsConfiguration; import jogamp.opengl.egl.EGLGraphicsConfigurationFactory; - import android.app.Activity; import android.content.Context; import android.content.Intent; @@ -286,9 +286,10 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { if( isFullscreen() ) { final MonitorDevice mainMonitor = getMainMonitor(); - final RectangleImmutable viewport = mainMonitor.getViewport(); - definePosition(viewport.getX(), viewport.getY()); - defineSize(viewport.getWidth(), viewport.getHeight()); + final RectangleImmutable screenRect = mainMonitor.getViewport(); + final RectangleImmutable winRect = this.convertToWindowUnits((Rectangle)screenRect.cloneMutable()); + definePosition(winRect.getX(), winRect.getY()); + defineSize(winRect.getWidth(), winRect.getHeight()); } final boolean b; 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 be7e8fd07..4cbff69c1 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/egl/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/WindowDriver.java @@ -65,7 +65,8 @@ public class WindowDriver extends jogamp.newt.WindowImpl { throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); } setGraphicsConfiguration(cfg); - setSizeImpl(getScreen().getWidth(), getScreen().getHeight()); + final int[] winSize = convertToWindowUnits(new int[] {getScreen().getWidth(), getScreen().getHeight()}); + setSizeImpl(winSize[0], winSize[1]); setWindowHandle(realizeWindow(true, getWindowWidth(), getWindowHeight())); if (0 == getWindowHandle()) { 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 7e15d0258..cf169f1c7 100644 --- a/src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java @@ -67,7 +67,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl { setWindowHandle(nextWindowHandle++); // just a marker surfaceHandle = CreateSurface(aDevice.getHandle(), getScreen().getWidth(), getScreen().getHeight(), - getX(), getY(), getWindowWidth(), getWindowHeight()); + getX(), getY(), getSurfaceWidth(), getSurfaceHeight()); if (surfaceHandle == 0) { throw new NativeWindowException("Error creating window"); } @@ -89,6 +89,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl { protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { ScreenDriver screen = (ScreenDriver) getScreen(); + // Note for GDL: window units == pixel units if(width>screen.getWidth()) { width=screen.getWidth(); } diff --git a/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java b/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java index 9d7b8931b..3663ef0d4 100644 --- a/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java +++ b/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java @@ -36,6 +36,7 @@ import java.io.InputStream; import jogamp.newt.WindowImpl; +import com.jogamp.newt.Screen; import com.jogamp.newt.Window; import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.event.WindowEvent; @@ -178,13 +179,20 @@ public class LinuxMouseTracker implements WindowListener { } if(null != focusedWindow) { - if( x >= focusedWindow.getScreen().getWidth() ) { - x = focusedWindow.getScreen().getWidth() - 1; - } - if( y >= focusedWindow.getScreen().getHeight() ) { - y = focusedWindow.getScreen().getHeight() - 1; + // Clip to Screen Size + { + final Screen focusedScreen = focusedWindow.getScreen(); + final int sw = focusedScreen.getWidth(); + final int sh = focusedScreen.getHeight(); + if( x >= sw ) { + x = sw - 1; + } + if( y >= sh ) { + y = sh - 1; + } } - final int wx = x - focusedWindow.getX(), wy = y - focusedWindow.getY(); + final int[] winScreenPos = focusedWindow.convertToPixelUnits(new int[] { focusedWindow.getX(), focusedWindow.getY() }); + final int wx = x - winScreenPos[0], wy = y - winScreenPos[1]; if(old_x != x || old_y != y) { // mouse moved lastFocusedX = wx; diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index 541247efd..00f935f86 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -253,7 +253,8 @@ public class WindowDriver extends WindowImpl { public void run() { final Point p0 = convertToPixelUnits( getLocationOnScreenImpl(0, 0) ); res[0] = Boolean.valueOf(confinePointer0(getWindowHandle(), confine, - p0.getX(), p0.getY(), p0.getX()+getSurfaceWidth(), p0.getY()+getSurfaceHeight())); + p0.getX(), p0.getY(), + p0.getX()+getSurfaceWidth(), p0.getY()+getSurfaceHeight())); } }); return res[0].booleanValue(); @@ -264,7 +265,7 @@ public class WindowDriver extends WindowImpl { this.runOnEDTIfAvail(true, new Runnable() { @Override public void run() { - final Point sPos = getLocationOnScreenImpl(x, y); + final Point sPos = convertToPixelUnits( getLocationOnScreenImpl(x, y) ); warpPointer0(getWindowHandle(), sPos.getX(), sPos.getY()); } }); |