diff options
author | Sven Gothel <[email protected]> | 2015-02-17 01:14:49 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2015-02-17 01:14:49 +0100 |
commit | 559ecad2a2387ba0aa34ce9e35ca8a2c5a31e655 (patch) | |
tree | a9ba7f77524851deb54269fc455aa529edfbd018 /src/newt/classes/com/jogamp | |
parent | 42d88f99cfa62304943a7b37700653e627b13e61 (diff) |
NEWT MonitorDevice: Identify cloned devices (fully covered) ; Windows: Iterate-over and identify all adapter:monitor. (Bug 1129)
- Identify cloned devices (fully covered)
- MonitorDevice gets 'isCloned()' to identify whether
it is a cloned device, i.e. fully covered by another monitor.
This detection may happen natively but will always performed
platform agnostic.
- getMainMonitor(..) now exclude 'cloned' devices
- Windows: Iterate-over and identify all adapter:monitor
- Since we also list cloned monitor,
we need to iterate over all adapter and all it's monitor-devices.
- The native monitor-id is now defined as: ( adapter-idx << 8 ) | monitor-idx.
- Bug 1129 <- listed under this bug entry for convenience
Diffstat (limited to 'src/newt/classes/com/jogamp')
-rw-r--r-- | src/newt/classes/com/jogamp/newt/MonitorDevice.java | 23 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/Screen.java | 16 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/opengl/GLWindow.java | 4 |
3 files changed, 27 insertions, 16 deletions
diff --git a/src/newt/classes/com/jogamp/newt/MonitorDevice.java b/src/newt/classes/com/jogamp/newt/MonitorDevice.java index 4d9c6493a..9c12dcb58 100644 --- a/src/newt/classes/com/jogamp/newt/MonitorDevice.java +++ b/src/newt/classes/com/jogamp/newt/MonitorDevice.java @@ -65,15 +65,17 @@ public abstract class MonitorDevice { protected final DimensionImmutable sizeMM; // in [mm] protected final MonitorMode originalMode; protected final ArrayHashSet<MonitorMode> supportedModes; // FIXME: May need to support mutable mode, i.e. adding modes on the fly! - protected MonitorMode currentMode; - protected boolean modeChanged; protected final float[] pixelScale; protected final Rectangle viewportPU; // in pixel units protected final Rectangle viewportWU; // in window units + protected boolean isClone; + protected MonitorMode currentMode; + protected boolean modeChanged; /** * @param screen associated {@link Screen} * @param nativeId unique monitor device ID + * @param isClone flag * @param sizeMM size in millimeters * @param currentMode * @param pixelScale pre-fetched current pixel-scale, maybe {@code null} for {@link ScalableSurface#IDENTITY_PIXELSCALE}. @@ -81,19 +83,21 @@ public abstract class MonitorDevice { * @param viewportWU viewport in window-units * @param supportedModes all supported {@link MonitorMode}s */ - protected MonitorDevice(final Screen screen, final int nativeId, final DimensionImmutable sizeMM, - final MonitorMode currentMode, - final float[] pixelScale, final Rectangle viewportPU, final Rectangle viewportWU, - final ArrayHashSet<MonitorMode> supportedModes) { + protected MonitorDevice(final Screen screen, final int nativeId, final boolean isClone, + final DimensionImmutable sizeMM, + final MonitorMode currentMode, final float[] pixelScale, final Rectangle viewportPU, + final Rectangle viewportWU, final ArrayHashSet<MonitorMode> supportedModes) { this.screen = screen; this.nativeId = nativeId; this.sizeMM = sizeMM; this.originalMode = currentMode; this.supportedModes = supportedModes; - this.currentMode = currentMode; this.pixelScale = null != pixelScale ? pixelScale : new float[] { 1.0f, 1.0f }; this.viewportPU = viewportPU; this.viewportWU = viewportWU; + + this.isClone = isClone; + this.currentMode = currentMode; this.modeChanged = false; } @@ -134,6 +138,9 @@ public abstract class MonitorDevice { /** @return the immutable unique native Id of this monitor device. */ public final int getId() { return nativeId; } + /** @return {@code true} if this device represents a <i>clone</i>, otherwise return {@code false}. */ + public final boolean isClone() { return isClone; } + /** * @return the immutable monitor size in millimeters. */ @@ -323,7 +330,7 @@ public abstract class MonitorDevice { @Override public String toString() { - return "Monitor[Id "+Display.toHexString(nativeId)+", "+sizeMM+" mm, pixelScale ["+pixelScale[0]+", "+pixelScale[1]+ + return "Monitor[Id "+Display.toHexString(nativeId)+", clone "+isClone+", "+sizeMM+" mm, pixelScale ["+pixelScale[0]+", "+pixelScale[1]+ "], viewport "+viewportPU+ " [pixels], "+viewportWU+" [window], orig "+originalMode+", curr "+currentMode+ ", modeChanged "+modeChanged+", modeCount "+supportedModes.size()+"]"; } diff --git a/src/newt/classes/com/jogamp/newt/Screen.java b/src/newt/classes/com/jogamp/newt/Screen.java index 65031a565..0e6895d4b 100644 --- a/src/newt/classes/com/jogamp/newt/Screen.java +++ b/src/newt/classes/com/jogamp/newt/Screen.java @@ -210,7 +210,8 @@ public abstract class Screen { /** * Returns the {@link MonitorDevice} with the highest {@link MonitorDevice#getViewportInWindowUnits() viewport} - * {@link RectangleImmutable#coverage(RectangleImmutable) coverage} of the given rectangle in window units. + * {@link RectangleImmutable#coverage(RectangleImmutable) coverage} of the given rectangle in window units, + * which is not a {@link MonitorDevice#isClone() clone}. * <p> * If no coverage is detected the first {@link MonitorDevice} is returned. * </p> @@ -220,12 +221,15 @@ public abstract class Screen { MonitorDevice res = null; float maxCoverage = Float.MIN_VALUE; final List<MonitorDevice> monitors = getMonitorDevices(); - for(int i=monitors.size()-1; i>=0; i--) { + final int monitorCount = monitors.size(); + for(int i=0; i<monitorCount; i++) { final MonitorDevice monitor = monitors.get(i); - final float coverage = monitor.getViewportInWindowUnits().coverage(r); - if( coverage > maxCoverage ) { - maxCoverage = coverage; - res = monitor; + if( !monitor.isClone() ) { + final float coverage = monitor.getViewportInWindowUnits().coverage(r); + if( coverage > maxCoverage ) { + maxCoverage = coverage; + res = monitor; + } } } if( maxCoverage > 0.0f && null != res ) { diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index e15f52730..3ef017d1b 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -1007,8 +1007,8 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind final MonitorDevice monitor = glWindow.getMainMonitor(); System.err.println("Main Monitor: "+monitor); final float[] pixelPerMM = monitor.getPixelsPerMM(new float[2]); - System.err.println(" pp/mm ["+pixelPerMM[0]+", "+pixelPerMM[1]+"]"); - System.err.println(" pp/in ["+pixelPerMM[0]*25.4f+", "+pixelPerMM[1]*25.4f+"]"); + System.err.println(" pixel/mm ["+pixelPerMM[0]+", "+pixelPerMM[1]+"]"); + System.err.println(" pixel/in ["+pixelPerMM[0]*25.4f+", "+pixelPerMM[1]*25.4f+"]"); final GL gl = drawable.getGL(); System.err.println(JoglVersion.getGLInfo(gl, null)); System.err.println("Requested: "+drawable.getNativeSurface().getGraphicsConfiguration().getRequestedCapabilities()); |