summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xmake/scripts/tests-win.bat15
-rwxr-xr-xmake/scripts/tests-x64-dbg.bat4
-rw-r--r--make/scripts/tests.sh4
-rw-r--r--src/newt/classes/com/jogamp/newt/MonitorDevice.java42
-rw-r--r--src/newt/classes/com/jogamp/newt/Screen.java7
-rw-r--r--src/newt/classes/jogamp/newt/MonitorDeviceImpl.java23
-rw-r--r--src/newt/classes/jogamp/newt/MonitorModeProps.java36
-rw-r--r--src/newt/classes/jogamp/newt/ScreenImpl.java23
-rw-r--r--src/newt/classes/jogamp/newt/ScreenMonitorState.java9
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/ScreenDriver.java1
-rw-r--r--src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java1
-rw-r--r--src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java1
-rw-r--r--src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java1
-rw-r--r--src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java1
-rw-r--r--src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java1
-rw-r--r--src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java6
-rw-r--r--src/newt/classes/jogamp/newt/driver/x11/RandR11.java1
-rw-r--r--src/newt/classes/jogamp/newt/driver/x11/RandR13.java1
-rw-r--r--src/newt/native/MacWindow.m3
-rw-r--r--src/newt/native/ScreenMode.h12
-rw-r--r--src/newt/native/WindowsWindow.c66
-rw-r--r--src/newt/native/X11RandR13.c29
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00aNEWT.java107
23 files changed, 282 insertions, 112 deletions
diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat
index e64e14b09..88545b857 100755
--- a/make/scripts/tests-win.bat
+++ b/make/scripts/tests-win.bat
@@ -167,7 +167,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAn
REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.nativewindow.TestRecursiveToolkitLockCORE
-REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00aNEWT %*
+scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00aNEWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00bNEWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00cNEWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01aNEWT %*
@@ -175,7 +175,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01bN
REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01cNEWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01dNEWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT %*
-scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT %*
+REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.ManualScreenMode03sNEWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT
@@ -209,12 +209,11 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.graph.TestRegionRendererNE
REM scripts\java-win.bat com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT01
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState02NEWT
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState02NEWT
-REM scripts\java-win.bat com.jogamp.opengl.test.junit.graph.demos.ui.UINewtDemo01
-REM scripts\java-win.bat com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtDemo01
-REM scripts\java-win.bat com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtDemo02
-REM scripts\java-win.bat com.jogamp.opengl.test.junit.graph.demos.GPURegionNewtDemo01
-REM scripts\java-win.bat com.jogamp.opengl.test.junit.graph.demos.GPURegionNewtDemo02
-
+REM scripts\java-win.bat com.jogamp.opengl.test.junit.graph.demos.ui.UINewtDemo01 %*
+REM scripts\java-win.bat com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtDemo %*
+REM scripts\java-win.bat com.jogamp.opengl.test.junit.graph.demos.GPURegionNewtDemo %*
+REM scripts\java-win.bat com.jogamp.opengl.test.junit.graph.demos.GPUUISceneNewtDemo %*
+REM scripts\java-win.bat com.jogamp.opengl.test.junit.graph.demos.GPUUISceneNewtCanvasAWTDemo %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01
diff --git a/make/scripts/tests-x64-dbg.bat b/make/scripts/tests-x64-dbg.bat
index 55c1288dd..bcc546efe 100755
--- a/make/scripts/tests-x64-dbg.bat
+++ b/make/scripts/tests-x64-dbg.bat
@@ -67,7 +67,7 @@ REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.Til
REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.TileRenderer"
REM set D_ARGS="-Djogl.debug.GLContext" "-Djogl.debug.GLJPanel"
REM set D_ARGS="-Djogl.gljpanel.noverticalflip"
-REM set D_ARGS="-Dnewt.debug=all"
+set D_ARGS="-Dnewt.debug=all"
REM set D_ARGS="-Dnewt.debug.Window"
REM set D_ARGS="-Dnewt.debug.Window.KeyEvent"
REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Window.KeyEvent" "-Dnewt.debug.EDT"
@@ -82,7 +82,7 @@ REM set D_ARGS="-Dnativewindow.debug.TraceLock"
REM set D_ARGS="-Dnewt.debug.Display" "-Dnewt.debug.EDT" "-Dnewt.debug.Window"
REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" "-Dnewt.debug.EDT" "-Djogl.debug.GLContext"
REM set D_ARGS="-Dnewt.debug.Screen" "-Dnewt.debug.EDT" "-Dnativewindow.debug=all"
-set D_ARGS="-Dnewt.debug.Screen"
+REM set D_ARGS="-Dnewt.debug.Screen"
REM set D_ARGS="-Dnewt.debug.Screen" "-Dnewt.debug.Window"
REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" "-Dnewt.test.Window.reparent.incompatible=true"
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index b5e8cee6f..2bf1414f6 100644
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -613,7 +613,7 @@ function testawtswt() {
#testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT
#testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT
#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $*
-#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00aNEWT $*
+testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00aNEWT $*
#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00bNEWT $*
#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00cNEWT $*
#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01aNEWT $*
@@ -621,7 +621,7 @@ function testawtswt() {
#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01cNEWT $*
#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01dNEWT $*
#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT $*
-testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT $*
+#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT $*
#testnoawt com.jogamp.opengl.test.junit.newt.mm.ManualScreenMode03aNEWT $*
#testnoawt -Djava.awt.headless=true com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $*
#testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowWarpPointer01NEWT $*
diff --git a/src/newt/classes/com/jogamp/newt/MonitorDevice.java b/src/newt/classes/com/jogamp/newt/MonitorDevice.java
index ec38ce3c3..88f8376c7 100644
--- a/src/newt/classes/com/jogamp/newt/MonitorDevice.java
+++ b/src/newt/classes/com/jogamp/newt/MonitorDevice.java
@@ -68,6 +68,7 @@ public abstract class MonitorDevice {
protected final Rectangle viewportPU; // in pixel units
protected final Rectangle viewportWU; // in window units
protected boolean isClone;
+ protected boolean isPrimary;
protected MonitorMode currentMode;
protected boolean modeChanged;
@@ -75,6 +76,7 @@ public abstract class MonitorDevice {
* @param screen associated {@link Screen}
* @param nativeId unique monitor device ID
* @param isClone flag
+ * @param isPrimary flag
* @param sizeMM size in millimeters
* @param currentMode
* @param pixelScale pre-fetched current pixel-scale, maybe {@code null} for {@link ScalableSurface#IDENTITY_PIXELSCALE}.
@@ -82,10 +84,10 @@ 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 boolean isClone,
- 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 boolean isPrimary,
+ 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;
@@ -96,6 +98,7 @@ public abstract class MonitorDevice {
this.viewportWU = viewportWU;
this.isClone = isClone;
+ this.isPrimary = isPrimary;
this.currentMode = currentMode;
this.modeChanged = false;
}
@@ -141,6 +144,12 @@ public abstract class MonitorDevice {
public final boolean isClone() { return isClone; }
/**
+ * Returns {@code true} if this device represents the <i>primary device</i>, otherwise return {@code false}.
+ * @see Screen#getPrimaryMonitor()
+ */
+ public final boolean isPrimary() { return isPrimary; }
+
+ /**
* @return the immutable monitor size in millimeters.
*/
public final DimensionImmutable getSizeMM() {
@@ -331,9 +340,28 @@ public abstract class MonitorDevice {
@Override
public String toString() {
- 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()+"]";
+ boolean preComma = false;
+ final StringBuilder sb = new StringBuilder();
+ sb.append("Monitor[Id ").append(Display.toHexString(nativeId)).append(", options[");
+ {
+ if( isClone() ) {
+ sb.append("clone");
+ preComma = true;
+ }
+ if( isPrimary() ) {
+ if( preComma ) {
+ sb.append(", ");
+ }
+ sb.append("primary");
+ }
+ }
+ preComma = false;
+ sb.append("], ").append(sizeMM).append(" mm, pixelScale [").append(pixelScale[0]).append(", ")
+ .append(pixelScale[1]).append("], viewport ").append(viewportPU).append(" [pixels], ").append(viewportWU)
+ .append(" [window], orig ").append(originalMode).append(", curr ")
+ .append(currentMode).append(", modeChanged ").append(modeChanged).append(", modeCount ")
+ .append(supportedModes.size()).append("]");
+ return sb.toString();
}
}
diff --git a/src/newt/classes/com/jogamp/newt/Screen.java b/src/newt/classes/com/jogamp/newt/Screen.java
index b8f096fc3..9b2a280f9 100644
--- a/src/newt/classes/com/jogamp/newt/Screen.java
+++ b/src/newt/classes/com/jogamp/newt/Screen.java
@@ -209,6 +209,13 @@ public abstract class Screen {
public abstract List<MonitorDevice> getMonitorDevices();
/**
+ * Returns the windowing manager's primary {@link MonitorDevice},
+ * which holds the system menu bar, etc.
+ * @see MonitorDevice#isPrimary()
+ */
+ public abstract MonitorDevice getPrimaryMonitor();
+
+ /**
* Returns the {@link MonitorDevice} with the highest {@link MonitorDevice#getViewportInWindowUnits() viewport}
* {@link RectangleImmutable#coverage(RectangleImmutable) coverage} of the given rectangle in window units,
* which is not a {@link MonitorDevice#isClone() clone}.
diff --git a/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java b/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java
index 3f039a9f4..9f458d215 100644
--- a/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java
+++ b/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java
@@ -41,7 +41,8 @@ public class MonitorDeviceImpl extends MonitorDevice {
/**
* @param screen associated {@link Screen}
* @param nativeId unique monitor device ID
- * @param isClone TODO
+ * @param isClone flag
+ * @param isPrimary flag
* @param sizeMM size in millimeters
* @param currentMode
* @param pixelScale pre-fetched current pixel-scale, maybe {@code null} for {@link ScalableSurface#IDENTITY_PIXELSCALE}.
@@ -49,11 +50,11 @@ public class MonitorDeviceImpl extends MonitorDevice {
* @param viewportWU viewport in window-units
* @param supportedModes all supported {@link MonitorMode}s
*/
- public MonitorDeviceImpl(final ScreenImpl 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) {
- super(screen, nativeId, isClone, sizeMM, currentMode, pixelScale, viewportPU, viewportWU, supportedModes);
+ public MonitorDeviceImpl(final ScreenImpl screen, final int nativeId,
+ final boolean isClone, final boolean isPrimary,
+ final DimensionImmutable sizeMM, final MonitorMode currentMode, final float[] pixelScale,
+ final Rectangle viewportPU, final Rectangle viewportWU, final ArrayHashSet<MonitorMode> supportedModes) {
+ super(screen, nativeId, isClone, isPrimary, sizeMM, currentMode, pixelScale, viewportPU, viewportWU, supportedModes);
}
@Override
@@ -80,7 +81,7 @@ public class MonitorDeviceImpl extends MonitorDevice {
}
// if mode has changed somehow, update it ..
if( getCurrentMode().hashCode() != mmU.hashCode() ) {
- setCurrentModeValue(mmU);
+ setCurrentModeValue(mmU, isPrimary);
sms.fireMonitorModeChanged(this, mmU, true);
}
return mmU;
@@ -139,7 +140,7 @@ public class MonitorDeviceImpl extends MonitorDevice {
}
}
if( success ) {
- setCurrentModeValue(mmU);
+ setCurrentModeValue(mmU, isPrimary);
modeChanged = !isOriginalMode();
}
sms.fireMonitorModeChanged(this, mmU, success);
@@ -152,8 +153,9 @@ public class MonitorDeviceImpl extends MonitorDevice {
}
}
- private final void setCurrentModeValue(final MonitorMode currentMode) {
+ private final void setCurrentModeValue(final MonitorMode currentMode, final boolean isPrimary) {
this.currentMode = currentMode;
+ this.isPrimary = isPrimary;
}
/* pp */ final Rectangle getMutuableViewportPU() { return viewportPU; }
@@ -166,4 +168,7 @@ public class MonitorDeviceImpl extends MonitorDevice {
/* pp */ final void setIsClone(final boolean isClone) {
this.isClone = isClone;
}
+ /* pp */ final void setIsPrimary(final boolean isPrimary) {
+ this.isPrimary = isPrimary;
+ }
}
diff --git a/src/newt/classes/jogamp/newt/MonitorModeProps.java b/src/newt/classes/jogamp/newt/MonitorModeProps.java
index 873b9edc3..073a9a355 100644
--- a/src/newt/classes/jogamp/newt/MonitorModeProps.java
+++ b/src/newt/classes/jogamp/newt/MonitorModeProps.java
@@ -133,6 +133,7 @@ public class MonitorModeProps {
* <li>count</li>
* <li>id</li>
* <li>IsClone</li>
+ * <li>IsPrimary</li>
* <li>ScreenSizeMM[width, height] (2 elements)</li>
* <li>Rotated Viewport pixel-units (4 elements)</li>
* <li>Rotated Viewport window-units (4 elements)</li>
@@ -141,17 +142,18 @@ public class MonitorModeProps {
* <li>SupportedModeId+</li>
* </ul>
* <p>
- * Viewport := [x, y, width, height] (4 elements)
+ * with Viewport := [x, y, width, height] (4 elements)
* </p>
* <p>
* WARNING: must be synchronized with ScreenMode.h, native implementation
* </p>
*/
- public static final int MIN_MONITOR_DEVICE_PROPERTIES = 16;
+ public static final int MIN_MONITOR_DEVICE_PROPERTIES = 17;
public static final int IDX_MONITOR_DEVICE_VIEWPORT = 1 // count
+ 1 // native mode
+ 1 // isClone
+ + 1 // isPrimary
+ MonitorModeProps.NUM_RESOLUTION_PROPERTIES // sizeMM
;
@@ -161,6 +163,10 @@ public class MonitorModeProps {
public final ArrayHashSet<MonitorMode.SizeAndRRate> sizeAndRates = new ArrayHashSet<MonitorMode.SizeAndRRate>();
public final ArrayHashSet<MonitorMode> monitorModes = new ArrayHashSet<MonitorMode>();
public final ArrayHashSet<MonitorDevice> monitorDevices = new ArrayHashSet<MonitorDevice>();
+
+ public final void setPrimary(final MonitorDevice p) { primary = p; }
+ public final MonitorDevice getPrimary() { return primary;}
+ private MonitorDevice primary = null;
}
/** WARNING: must be synchronized with ScreenMode.h, native implementation */
@@ -292,6 +298,7 @@ public class MonitorModeProps {
final List<MonitorMode> allMonitorModes = cache.monitorModes.getData();
final int id = monitorProperties[offset++];
final boolean isClone = 0 == monitorProperties[offset++] ? false : true;
+ final boolean isPrimary = 0 == monitorProperties[offset++] ? false : true;
final DimensionImmutable sizeMM = streamInResolution(monitorProperties, offset); offset+=NUM_RESOLUTION_PROPERTIES;
final Rectangle viewportPU = new Rectangle(monitorProperties[offset++], monitorProperties[offset++], monitorProperties[offset++], monitorProperties[offset++]);
final Rectangle viewportWU = new Rectangle(monitorProperties[offset++], monitorProperties[offset++], monitorProperties[offset++], monitorProperties[offset++]);
@@ -311,9 +318,14 @@ public class MonitorModeProps {
}
}
}
- MonitorDevice monitorDevice = new MonitorDeviceImpl(screen, id, isClone, sizeMM, currentMode, pixelScale, viewportPU, viewportWU, supportedModes);
+ MonitorDevice monitorDevice = new MonitorDeviceImpl(screen, id, isClone, isPrimary,
+ sizeMM, currentMode, pixelScale,
+ viewportPU, viewportWU, supportedModes);
if(null!=cache) {
monitorDevice = cache.monitorDevices.getOrAdd(monitorDevice);
+ if( monitorDevice.isPrimary() ) {
+ cache.setPrimary(monitorDevice);
+ }
}
if( null != monitor_idx ) {
final int _monitorIdx = cache.monitorDevices.indexOf(monitorDevice);
@@ -373,12 +385,18 @@ public class MonitorModeProps {
offset++;
final int id = monitorProperties[offset++];
final boolean isClone = 0 == monitorProperties[offset++] ? false : true;
+ final boolean isPrimary = 0 == monitorProperties[offset++] ? false : true;
final DimensionImmutable sizeMM = streamInResolution(monitorProperties, offset); offset+=NUM_RESOLUTION_PROPERTIES;
final Rectangle viewportPU = new Rectangle(monitorProperties[offset++], monitorProperties[offset++], monitorProperties[offset++], monitorProperties[offset++]);
final Rectangle viewportWU = new Rectangle(monitorProperties[offset++], monitorProperties[offset++], monitorProperties[offset++], monitorProperties[offset++]);
- MonitorDevice monitorDevice = new MonitorDeviceImpl(screen, id, isClone, sizeMM, currentMode, pixelScale, viewportPU, viewportWU, supportedModes);
+ MonitorDevice monitorDevice = new MonitorDeviceImpl(screen, id, isClone, isPrimary,
+ sizeMM, currentMode, pixelScale,
+ viewportPU, viewportWU, supportedModes);
if(null!=cache) {
monitorDevice = cache.monitorDevices.getOrAdd(monitorDevice);
+ if( monitorDevice.isPrimary() ) {
+ cache.setPrimary(monitorDevice);
+ }
}
if( null != monitor_idx ) {
final int _monitorIdx = cache.monitorDevices.indexOf(monitorDevice);
@@ -402,6 +420,7 @@ public class MonitorModeProps {
data[idx++] = data.length;
data[idx++] = monitorDevice.getId();
data[idx++] = monitorDevice.isClone() ? 1 : 0;
+ data[idx++] = monitorDevice.isPrimary() ? 1 : 0;
data[idx++] = monitorDevice.getSizeMM().getWidth();
data[idx++] = monitorDevice.getSizeMM().getHeight();
data[idx++] = monitorDevice.getViewport().getX();
@@ -424,8 +443,13 @@ public class MonitorModeProps {
return data;
}
- /** Identify monitor devices in <i>cloned</i> mode, i.e. consecutive devices being 100% covered by preceding devices. */
- /* pp */ static void identifyClonedMonitorDevices(final MonitorModeProps.Cache cache) {
+ /**
+ * Identify monitor devices:
+ * <ul>
+ * <li><i>cloned</i> mode, i.e. consecutive devices being 100% covered by preceding devices.</li>
+ * </ul>
+ */
+ /* pp */ static void identifyMonitorDevices(final MonitorModeProps.Cache cache) {
final ArrayList<MonitorDevice> monitors = cache.monitorDevices.toArrayList();
final int monitorCount = monitors.size();
for(int i=0; i<monitorCount; i++) {
diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java
index 36e42e52c..c96a2e06e 100644
--- a/src/newt/classes/jogamp/newt/ScreenImpl.java
+++ b/src/newt/classes/jogamp/newt/ScreenImpl.java
@@ -406,6 +406,12 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener {
return null != sms ? sms.getMonitorDevices().getData() : null;
}
+ @Override
+ public MonitorDevice getPrimaryMonitor() {
+ final ScreenMonitorState sms = getScreenMonitorStatus(false);
+ return null != sms ? sms.getPrimaryMonitorDevice() : null;
+ }
+
final ScreenMonitorState getScreenMonitorStatus(final boolean throwException) {
final String key = this.getFQName();
final ScreenMonitorState res = ScreenMonitorState.getScreenMonitorState(key);
@@ -501,6 +507,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener {
props[i++] = MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES;
props[i++] = monitorId;
props[i++] = 0; // is-clone
+ props[i++] = 0 == monitorId ? 1 : 0; // is-primary
props[i++] = default_sm_widthmm;
props[i++] = default_sm_heightmm;
props[i++] = 0; // rotated viewport x pixel-units
@@ -562,7 +569,18 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener {
final MonitorMode mode = getVirtualMonitorMode(cache, 0);
cache.monitorModes.getOrAdd(mode);
final MonitorDevice monitor = getVirtualMonitorDevice(cache, 0, mode);
+ ((MonitorDeviceImpl)monitor).setIsPrimary(true);
cache.monitorDevices.getOrAdd(monitor);
+ cache.setPrimary(monitor);
+ }
+ if( null == cache.getPrimary() ) {
+ // Fallback ..
+ final MonitorDevice p = cache.monitorDevices.get(0);
+ ((MonitorDeviceImpl)p).setIsPrimary(true);
+ cache.setPrimary(p);
+ if( DEBUG ) {
+ System.err.println("WARNING: Fallback primary: "+p);
+ }
}
// Sort MonitorModes (all and per device) in descending order - default!
MonitorModeUtil.sort(cache.monitorModes.getData(), false ); // descending order
@@ -583,8 +601,9 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener {
System.err.println("["+i+"]["+j+"]: "+iMode.next());
}
}
+ System.err.println("Primary: "+cache.getPrimary());
}
- sms = new ScreenMonitorState(cache.monitorDevices, cache.monitorModes);
+ sms = new ScreenMonitorState(cache.monitorDevices, cache.monitorModes, cache.getPrimary());
ScreenMonitorState.mapScreenMonitorState(this.getFQName(), sms);
}
} finally {
@@ -609,7 +628,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener {
private final int collectNativeMonitorModes(final MonitorModeProps.Cache cache) {
if(!DEBUG_TEST_SCREENMODE_DISABLED) {
collectNativeMonitorModesAndDevicesImpl(cache);
- MonitorModeProps.identifyClonedMonitorDevices(cache);
+ MonitorModeProps.identifyMonitorDevices(cache);
}
// filter out insufficient modes
for(int i=cache.monitorModes.size()-1; i>=0; i--) {
diff --git a/src/newt/classes/jogamp/newt/ScreenMonitorState.java b/src/newt/classes/jogamp/newt/ScreenMonitorState.java
index ae982414b..fd1329f91 100644
--- a/src/newt/classes/jogamp/newt/ScreenMonitorState.java
+++ b/src/newt/classes/jogamp/newt/ScreenMonitorState.java
@@ -46,6 +46,7 @@ public class ScreenMonitorState {
private final RecursiveLock lock = LockFactory.createRecursiveLock();
private final ArrayHashSet<MonitorDevice> allMonitors;
private final ArrayHashSet<MonitorMode> allMonitorModes;
+ private final MonitorDevice primaryMonitor;
private final ArrayList<MonitorModeListener> listener = new ArrayList<MonitorModeListener>();
private static HashMap<String, ScreenMonitorState> screenFQN2ScreenMonitorState = new HashMap<String, ScreenMonitorState>();
@@ -107,15 +108,21 @@ public class ScreenMonitorState {
}
public ScreenMonitorState(final ArrayHashSet<MonitorDevice> allMonitors,
- final ArrayHashSet<MonitorMode> allMonitorModes) {
+ final ArrayHashSet<MonitorMode> allMonitorModes,
+ final MonitorDevice primaryMonitor) {
this.allMonitors = allMonitors;
this.allMonitorModes = allMonitorModes;
+ this.primaryMonitor = primaryMonitor;
}
protected ArrayHashSet<MonitorDevice> getMonitorDevices() {
return allMonitors;
}
+ protected MonitorDevice getPrimaryMonitorDevice() {
+ return primaryMonitor;
+ }
+
protected ArrayHashSet<MonitorMode> getMonitorModes() {
return allMonitorModes;
}
diff --git a/src/newt/classes/jogamp/newt/driver/android/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/android/ScreenDriver.java
index 60e6e7d5f..a95b3d429 100644
--- a/src/newt/classes/jogamp/newt/driver/android/ScreenDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/android/ScreenDriver.java
@@ -105,6 +105,7 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl {
props[i++] = props.length;
props[i++] = 0; // crt_idx
props[i++] = 0; // is-clone
+ props[i++] = 1; // is-primary
i = getScreenSizeMM(outMetrics, props, i); // sizeMM
props[i++] = 0; // rotated viewport x pixel-units
props[i++] = 0; // rotated viewport y pixel-units
diff --git a/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java
index aba7a1ab9..69bbef06c 100644
--- a/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java
@@ -110,6 +110,7 @@ public class ScreenDriver extends ScreenImpl {
props[i++] = props.length;
props[i++] = 0; // crt_idx
props[i++] = 0; // is-clone
+ props[i++] = 1; // is-primary
props[i++] = ScreenImpl.default_sm_widthmm; // FIXME
props[i++] = ScreenImpl.default_sm_heightmm; // FIXME
props[i++] = 0; // rotated viewport x pixel-units
diff --git a/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java
index 704fad73f..9c68c1528 100644
--- a/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java
@@ -85,6 +85,7 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl {
props[i++] = props.length;
props[i++] = 0; // crt_idx
props[i++] = 0; // is-clone
+ props[i++] = 1; // is-primary
props[i++] = ScreenImpl.default_sm_widthmm; // FIXME
props[i++] = ScreenImpl.default_sm_heightmm; // FIXME
props[i++] = 0; // rotated viewport x pixel-units
diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java
index 8d46adeab..f236edd6b 100644
--- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java
@@ -78,6 +78,7 @@ public class ScreenDriver extends ScreenImpl {
props[i++] = props.length;
props[i++] = 0; // crt_idx
props[i++] = 0; // is-clone
+ props[i++] = 1; // is-primary
props[i++] = ScreenImpl.default_sm_widthmm; // FIXME
props[i++] = ScreenImpl.default_sm_heightmm; // FIXME
props[i++] = 0; // rotated viewport x pixel-units
diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java
index b55378459..5c29c4e37 100644
--- a/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java
@@ -87,6 +87,7 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl {
props[i++] = props.length;
props[i++] = 0; // crt_idx
props[i++] = 0; // is-clone
+ props[i++] = 1; // is-primary
props[i++] = ScreenImpl.default_sm_widthmm; // FIXME
props[i++] = ScreenImpl.default_sm_heightmm; // FIXME
props[i++] = 0; // rotated viewport x pixel-units
diff --git a/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java
index 1e878bc3a..328523ad4 100644
--- a/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java
@@ -83,6 +83,7 @@ public class ScreenDriver extends ScreenImpl {
props[i++] = props.length;
props[i++] = 0; // crt_idx
props[i++] = 0; // is-clone
+ props[i++] = 1; // is-primary
props[i++] = ScreenImpl.default_sm_widthmm; // FIXME
props[i++] = ScreenImpl.default_sm_heightmm; // FIXME
props[i++] = 0; // rotated viewport x pixel-units
diff --git a/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java
index 013f9f9ca..ea3e76eb3 100644
--- a/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java
@@ -119,7 +119,7 @@ public class ScreenDriver extends ScreenImpl {
// has at least one mode -> add device
final MonitorMode currentMode = getMonitorModeImpl(cache, adapterName, -1);
if ( null != currentMode ) { // enabled
- final int[] monitorProps = getMonitorDevice0(adapterName, adapterIdx, monitorIdx, getMonitorId(adapterIdx, monitorIdx));
+ final int[] monitorProps = getMonitorDevice0(adapterIdx, monitorIdx, getMonitorId(adapterIdx, monitorIdx));
// merge monitor-props + supported modes
MonitorModeProps.streamInMonitorDevice(cache, this, currentMode, null, supportedModes, monitorProps, 0, null);
@@ -139,7 +139,7 @@ public class ScreenDriver extends ScreenImpl {
final String adapterName = getAdapterName(adapterIdx);
if( null != adapterName ) {
if( null != getMonitorName(adapterName, monitorIdx, true) ) {
- final int[] monitorProps = getMonitorDevice0(adapterName, adapterIdx, monitorIdx, getMonitorId(adapterIdx, monitorIdx));
+ final int[] monitorProps = getMonitorDevice0(adapterIdx, monitorIdx, getMonitorId(adapterIdx, monitorIdx));
int offset = MonitorModeProps.IDX_MONITOR_DEVICE_VIEWPORT;
viewportPU.set(monitorProps[offset++], monitorProps[offset++], monitorProps[offset++], monitorProps[offset++]);
viewportWU.set(monitorProps[offset++], monitorProps[offset++], monitorProps[offset++], monitorProps[offset++]);
@@ -187,6 +187,6 @@ public class ScreenDriver extends ScreenImpl {
private native String getAdapterName0(int adapter_idx);
private native String getMonitorName0(String adapterName, int monitor_idx, boolean onlyActive);
private native int[] getMonitorMode0(String adapterName, int mode_idx);
- private native int[] getMonitorDevice0(String adapterName, int adapter_idx, int monitor_idx, int monitorId);
+ private native int[] getMonitorDevice0(int adapter_idx, int monitor_idx, int monitorId);
private native boolean setMonitorMode0(int adapter_idx, int x, int y, int width, int height, int bits, int freq, int flags, int rot);
}
diff --git a/src/newt/classes/jogamp/newt/driver/x11/RandR11.java b/src/newt/classes/jogamp/newt/driver/x11/RandR11.java
index a4c578b26..e9cb95548 100644
--- a/src/newt/classes/jogamp/newt/driver/x11/RandR11.java
+++ b/src/newt/classes/jogamp/newt/driver/x11/RandR11.java
@@ -187,6 +187,7 @@ class RandR11 implements RandR {
props[i++] = props.length;
props[i++] = crt_idx;
props[i++] = 0; // is-clone
+ props[i++] = 0 == crt_idx ? 1 : 0; // is-primary
props[i++] = widthMM;
props[i++] = heightMM;
props[i++] = 0; // rotated viewport x pixel-units
diff --git a/src/newt/classes/jogamp/newt/driver/x11/RandR13.java b/src/newt/classes/jogamp/newt/driver/x11/RandR13.java
index b6d8f13a1..2f7110b5c 100644
--- a/src/newt/classes/jogamp/newt/driver/x11/RandR13.java
+++ b/src/newt/classes/jogamp/newt/driver/x11/RandR13.java
@@ -247,7 +247,6 @@ class RandR13 implements RandR {
try {
setScreenViewport0(dpy, screen_idx, screenResources, viewport.getX(), viewport.getY(), viewport.getWidth(), viewport.getHeight());
} finally {
- dumpInfo0(dpy, screen_idx, screenResources);
releaseScreenResourceHandle(screenResources);
}
}
diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m
index 690aaa505..fbac6b37e 100644
--- a/src/newt/native/MacWindow.m
+++ b/src/newt/native/MacWindow.m
@@ -517,7 +517,8 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getMonit
int offset = 0;
prop[offset++] = propCount;
prop[offset++] = crt_idx;
- prop[offset++] = 0; // is-clone
+ prop[offset++] = 0; // isClone
+ prop[offset++] = 0 == crt_idx ? 1 : 0; // isPrimary
prop[offset++] = (jint) sizeMM.width;
prop[offset++] = (jint) sizeMM.height;
prop[offset++] = (jint) dBounds.origin.x; // rotated viewport x (pixel units, will be fixed in java code)
diff --git a/src/newt/native/ScreenMode.h b/src/newt/native/ScreenMode.h
index 18e773107..5ae865b8e 100644
--- a/src/newt/native/ScreenMode.h
+++ b/src/newt/native/ScreenMode.h
@@ -40,8 +40,16 @@
#define NUM_MONITOR_MODE_PROPERTIES_ALL 8 /* count + the above */
-#define MIN_MONITOR_DEVICE_PROPERTIES 16 /* count + id + is_clone, ScreenSizeMM[width, height], rotated Viewport pixel-units, rotated Viewport pixel-units, currentMonitorModeId, rotation, supportedModeId+ */
- /* Viewport := [x, y, width, height] (4 elements) */
+#define MIN_MONITOR_DEVICE_PROPERTIES 17 /* count + id + isClone + isPrimary,
+ ScreenSizeMM[width, height],
+ rotated Viewport pixel-units,
+ rotated Viewport pixel-units,
+ currentMonitorModeId,
+ rotation,
+ supportedModeId+
+
+ with Viewport := [x, y, width, height] (4 elements)
+ */
#define FLAG_INTERLACE ( 1 << 0 )
#define FLAG_DOUBLESCAN ( 1 << 1 )
diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c
index 7e15cd925..8c29978f0 100644
--- a/src/newt/native/WindowsWindow.c
+++ b/src/newt/native/WindowsWindow.c
@@ -124,9 +124,28 @@
#ifndef EDS_ROTATEDMODE
#define EDS_ROTATEDMODE 0x00000004
#endif
+
+// #define DISPLAY_DEVICE_ATTACHED_TO_DESKTOP 0x00000001
+// #define DISPLAY_DEVICE_MULTI_DRIVER 0x00000002
+#ifndef DISPLAY_DEVICE_PRIMARY_DEVICE
+#define DISPLAY_DEVICE_PRIMARY_DEVICE 0x00000004
+#endif
+#ifndef DISPLAY_DEVICE_MIRRORING_DRIVER
+#define DISPLAY_DEVICE_MIRRORING_DRIVER 0x00000008
+#endif
+// #define DISPLAY_DEVICE_VGA_COMPATIBLE 0x00000010
+// #define DISPLAY_DEVICE_REMOVABLE 0x00000020
+// #define DISPLAY_DEVICE_MODESPRUNED 0x08000000
+// #define DISPLAY_DEVICE_REMOTE 0x04000000
+// #define DISPLAY_DEVICE_DISCONNECT 0x02000000
+
#ifndef DISPLAY_DEVICE_ACTIVE
#define DISPLAY_DEVICE_ACTIVE 0x00000001
#endif
+#ifndef DISPLAY_DEVICE_ATTACHED
+#define DISPLAY_DEVICE_ATTACHED 0x00000002
+#endif
+
#ifndef DM_INTERLACED
#define DM_INTERLACED 2
#endif
@@ -1704,8 +1723,10 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_dumpMonitorI
int i = 0, j;
LPCTSTR aName, dName;
while(NULL != (aName = NewtScreen_getAdapterName(&aDevice, i))) {
- STD_PRINT("*** [%02d:__]: deviceName <%s> flags 0x%X active %d\n",
- i, aDevice.DeviceName, aDevice.StateFlags, ( 0 != ( aDevice.StateFlags & DISPLAY_DEVICE_ACTIVE ) ) );
+ STD_PRINT("*** [%02d:__]: deviceName <%s>, flags 0x%X, active %d, primary %d\n",
+ i, aDevice.DeviceName, aDevice.StateFlags,
+ ( 0 != ( aDevice.StateFlags & DISPLAY_DEVICE_ACTIVE ) ),
+ ( 0 != ( aDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE ) ));
STD_PRINT(" deviceString <%s> \n", aDevice.DeviceString);
STD_PRINT(" deviceID <%s> \n", aDevice.DeviceID);
j=0;
@@ -1858,27 +1879,30 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getMoni
* Signature: (Ljava/lang/String;II)[I
*/
JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getMonitorDevice0
- (JNIEnv *env, jobject obj, jstring jAdapterName, jint adapter_idx, jint monitor_idx, jint monitor_id)
+ (JNIEnv *env, jobject obj, jint adapter_idx, jint monitor_idx, jint monitor_id)
{
- LPCTSTR adapterName;
- {
-#ifdef UNICODE
- adapterName = NewtCommon_GetNullTerminatedStringChars(env, jAdapterName);
-#else
- adapterName = (*env)->GetStringUTFChars(env, jAdapterName, NULL);
-#endif
- }
+ int gotsize = 0;
+ int widthmm, heightmm;
+ DISPLAY_DEVICE adapterDevice, monitorDevice;
+ LPCTSTR monitorName = NULL;
+ LPCTSTR adapterName = NULL;
+ adapterName = NewtScreen_getAdapterName(&adapterDevice, adapter_idx);
+ if( NULL == adapterName ) {
+ DBG_PRINT("ERROR WindowsWindow: adapter[idx %d]: NULL\n", adapter_idx);
+ return (*env)->NewIntArray(env, 0);
+ }
DBG_PRINT("*** WindowsWindow: adapter[name %s, idx %d], monitor[idx %d, id %d], EDID-avail %d\n",
adapterName, adapter_idx, monitor_idx, monitor_id, NewtEDID_avail);
- int gotsize = 0;
- int widthmm, heightmm;
- DISPLAY_DEVICE monitorDevice;
- LPCTSTR monitorName = NewtScreen_getMonitorName(adapterName, &monitorDevice, monitor_idx, TRUE);
+
+ monitorName = NewtScreen_getMonitorName(adapterName, &monitorDevice, monitor_idx, TRUE);
+ if( NULL == monitorName ) {
+ DBG_PRINT("ERROR WindowsWindow: monitor[idx %d]: NULL\n", monitor_idx);
+ return (*env)->NewIntArray(env, 0);
+ }
if( NewtEDID_avail ) {
int widthcm, heightcm;
- if( NULL != monitorName &&
- NewtEDID_GetMonitorSizeFromEDIDByDevice(&monitorDevice, &widthmm, &heightmm, &widthcm, &heightcm) ) {
+ if( NewtEDID_GetMonitorSizeFromEDIDByDevice(&monitorDevice, &widthmm, &heightmm, &widthcm, &heightcm) ) {
DBG_PRINT("*** WindowsWindow: EDID %d x %d [mm], %d x %d [cm]\n", widthmm, heightmm, widthcm, heightcm);
if( 0 <= widthmm && 0 <= heightmm ) {
gotsize = 1; // got mm values
@@ -1908,11 +1932,6 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getMoni
int res = EnumDisplaySettingsEx(adapterName, devModeID, &dm, 0);
DBG_PRINT("*** WindowsWindow: getMonitorDevice.EnumDisplaySettingsEx(%s, devModeID %d) -> %d\n", adapterName, devModeID, res);
-#ifdef UNICODE
- free((void*) adapterName);
-#else
- (*env)->ReleaseStringUTFChars(env, jAdapterName, adapterName);
-#endif
if (0 == res) {
return (*env)->NewIntArray(env, 0);
}
@@ -1923,7 +1942,8 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getMoni
prop[propIndex++] = propCount;
prop[propIndex++] = monitor_id;
- prop[propIndex++] = NULL != monitorName && 0 != ( monitorDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER );
+ prop[propIndex++] = 0 != ( monitorDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER ); // isClone
+ prop[propIndex++] = 0 != ( adapterDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE ); // isPrimary
prop[propIndex++] = widthmm;
prop[propIndex++] = heightmm;
prop[propIndex++] = dm.dmPosition.x; // rotated viewport pixel units
diff --git a/src/newt/native/X11RandR13.c b/src/newt/native/X11RandR13.c
index 1d721efcb..4f52ad190 100644
--- a/src/newt/native/X11RandR13.c
+++ b/src/newt/native/X11RandR13.c
@@ -61,16 +61,23 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_RandR13_freeScreenResources0
#define SAFE_STRING(s) (NULL==s?"":s)
-static void dumpOutputs(const char *prefix, Display *dpy, XRRScreenResources *resources, int noutput, RROutput * outputs) {
- int i, j;
- fprintf(stderr, "%s %p: Output count %d\n", prefix, resources, noutput);
+static void dumpOutputs(const char *prefix, Display *dpy, int screen_idx, XRRScreenResources *resources, int noutput, RROutput * outputs) {
+ int i, j, primIdx=0;
+ Window root = RootWindow(dpy, screen_idx);
+ RROutput pxid = XRRGetOutputPrimary (dpy, root);
+ fprintf(stderr, "%s %p: Output[count %d, prim %#lx]\n", prefix, resources, noutput, pxid);
for(i=0; i<noutput; i++) {
+ int isPrim =0;
RROutput output = outputs[i];
+ if ( None != pxid && pxid == output ) {
+ primIdx = i;
+ isPrim = 1;
+ }
XRROutputInfo * xrrOutputInfo = XRRGetOutputInfo (dpy, resources, output);
- fprintf(stderr, " Output[%d]: id %#lx, crtx 0x%lX, name %s (%d), %lux%lu, ncrtc %d, nclone %d, nmode %d (preferred %d)\n",
+ fprintf(stderr, " Output[%d]: id %#lx, crtx 0x%lX, name %s (%d), %lux%lu, ncrtc %d, nclone %d, nmode %d (preferred %d), primary %d\n",
i, output, xrrOutputInfo->crtc, SAFE_STRING(xrrOutputInfo->name), xrrOutputInfo->nameLen,
xrrOutputInfo->mm_width, xrrOutputInfo->mm_height,
- xrrOutputInfo->ncrtc, xrrOutputInfo->nclone, xrrOutputInfo->nmode, xrrOutputInfo->npreferred);
+ xrrOutputInfo->ncrtc, xrrOutputInfo->nclone, xrrOutputInfo->nmode, xrrOutputInfo->npreferred, isPrim);
for(j=0; j<xrrOutputInfo->ncrtc; j++) {
fprintf(stderr, " Output[%d].Crtc[%d].id %#lx\n", i, j, xrrOutputInfo->crtcs[j]);
}
@@ -145,7 +152,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_RandR13_dumpInfo0
XRRFreeCrtcInfo(xrrCrtcInfo);
}
- dumpOutputs("XRRScreenResources.outputs", dpy, resources, resources->noutput, resources->outputs);
+ dumpOutputs("XRRScreenResources.outputs", dpy, (int)screen_idx, resources, resources->noutput, resources->outputs);
fprintf(stderr, "XRRScreenResources %p: Mode count %d\n", resources, resources->nmode);
for(i=0; i<resources->nmode; i++) {
@@ -421,7 +428,14 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getMonitorDevice
return NULL;
}
+ Window root = RootWindow(dpy, 0); // FIXME screen_idx);
+ RROutput pxid = XRRGetOutputPrimary (dpy, root);
+ int isPrimary = 0;
+
RROutput output = xrrCrtcInfo->outputs[0];
+ if ( None != pxid && pxid == output ) {
+ isPrimary = 1;
+ }
XRROutputInfo * xrrOutputInfo = XRRGetOutputInfo (dpy, resources, output);
int numModes = xrrOutputInfo->nmode;
@@ -431,7 +445,8 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getMonitorDevice
prop[propIndex++] = propCount;
prop[propIndex++] = crt_idx;
- prop[propIndex++] = 0; // is_clone, does not work: 0 < xrrOutputInfo->nclone ? 1 : 0;
+ prop[propIndex++] = 0; // isClone, does not work: 0 < xrrOutputInfo->nclone ? 1 : 0;
+ prop[propIndex++] = isPrimary;
prop[propIndex++] = xrrOutputInfo->mm_width;
prop[propIndex++] = xrrOutputInfo->mm_height;
prop[propIndex++] = xrrCrtcInfo->x; // rotated viewport pixel units
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00aNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00aNEWT.java
index 5285673e9..43206bbae 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00aNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00aNEWT.java
@@ -87,7 +87,7 @@ public class TestScreenMode00aNEWT extends UITestCase {
}
@Test
- public void testScreenModeInfo00() throws InterruptedException {
+ public void test00ScreenModeStream() throws InterruptedException {
final DimensionImmutable res = new Dimension(640, 480);
final SurfaceSize surfsz = new SurfaceSize(res, 32);
final MonitorMode modeOut = new MonitorMode(surfsz, 60.0f, 0, 0);
@@ -112,7 +112,7 @@ public class TestScreenMode00aNEWT extends UITestCase {
final Rectangle viewport = new Rectangle(0, 0, 1920, 1080);
final ArrayHashSet<MonitorMode> supportedModes = new ArrayHashSet<MonitorMode>();
supportedModes.add(modeOut);
- final MonitorDevice monOut = new MonitorDeviceImpl(null, -1, false, sizeMM, modeOut, null, viewport, viewport, supportedModes);
+ final MonitorDevice monOut = new MonitorDeviceImpl(null, -1, false, true, sizeMM, modeOut, null, viewport, viewport, supportedModes);
System.err.println("01 out : "+monOut);
cache.monitorDevices.add(monOut);
{
@@ -120,19 +120,83 @@ public class TestScreenMode00aNEWT extends UITestCase {
final MonitorDevice monIn = MonitorModeProps.streamInMonitorDevice(cache, null, null, props, 0, null);
System.err.println("01 in : "+monIn);
- Assert.assertEquals(monOut.getCurrentMode(), monOut.getOriginalMode());
- Assert.assertEquals(monOut.getSupportedModes(), monIn.getSupportedModes());
+ Assert.assertEquals(monOut.getId(), monIn.getId());
+ Assert.assertEquals(monOut.isClone(), monIn.isClone());
+ Assert.assertEquals(monOut.isPrimary(), monIn.isPrimary());
Assert.assertEquals(monOut.getViewport(), monIn.getViewport());
Assert.assertEquals(monOut.getViewportInWindowUnits(), monIn.getViewportInWindowUnits());
Assert.assertEquals(monOut.getOriginalMode(), monIn.getOriginalMode());
Assert.assertEquals(monOut.getCurrentMode(), monIn.getCurrentMode());
+ Assert.assertEquals(monOut.getSupportedModes(), monIn.getSupportedModes());
+ Assert.assertEquals(monOut.getCurrentMode(), monOut.getOriginalMode());
Assert.assertEquals(monOut.hashCode(), monIn.hashCode());
Assert.assertEquals(monOut, monIn);
}
}
+ static void dumpMonitor(final String pre0, final String pre1, final MonitorDevice monitor) {
+ System.err.println(pre0+" "+monitor);
+ final float[] pixelPerMM = monitor.getPixelsPerMM(new float[2]);
+ System.err.println(pre1+" pixel/mm ["+pixelPerMM[0]+", "+pixelPerMM[1]+"]");
+ System.err.println(pre1+" pixel/in ["+pixelPerMM[0]*25.4f+", "+pixelPerMM[1]*25.4f+"]");
+ final MonitorMode sm_o = monitor.getOriginalMode();
+ Assert.assertNotNull(sm_o);
+ final MonitorMode sm_c = monitor.queryCurrentMode();
+ System.err.println(pre1+" orig : "+sm_o);
+ System.err.println(pre1+" current: "+sm_c);
+ Assert.assertNotNull(sm_c);
+ Assert.assertEquals(sm_o, sm_c);
+ }
+
@Test
- public void testScreenModeInfo01() throws InterruptedException {
+ public void test01ScreenAllMonitor() throws InterruptedException {
+ final Display dpy = NewtFactory.createDisplay(null);
+ final Screen screen = NewtFactory.createScreen(dpy, screenIdx);
+ screen.addReference();
+ Assert.assertEquals(true,screen.isNativeValid());
+ Assert.assertEquals(true,screen.getDisplay().isNativeValid());
+ final List<MonitorDevice> monitors = screen.getMonitorDevices();
+ Assert.assertTrue(monitors.size()>0);
+
+ final MonitorDevice primMonitor = screen.getPrimaryMonitor();
+ Assert.assertNotNull("Could not retrieve primary monitor", primMonitor);
+ dumpMonitor("Primary Device ", " ", primMonitor);
+ Assert.assertTrue("Tracked primary monitor not flagged as primary", primMonitor.isPrimary());
+
+ // Dump all Monitor's and its DPI and current/original mode
+ int j=0;
+ for(final Iterator<MonitorDevice> iMonitor=monitors.iterator(); iMonitor.hasNext(); j++) {
+ final MonitorDevice monitor = iMonitor.next();
+ dumpMonitor("Monitor Index "+j, " ", monitor);
+ if( monitor.getId() == primMonitor.getId() ) {
+ Assert.assertTrue("Primary monitor not flagged as primary", monitor.isPrimary());
+ } else {
+ Assert.assertFalse("Non primary monitor flagged as primary", monitor.isPrimary());
+ }
+ }
+ final RectangleImmutable zero = new Rectangle();
+
+ final Rectangle monitorViewPU = new Rectangle();
+ final Rectangle monitorViewWU = new Rectangle();
+ MonitorDevice.unionOfViewports(monitorViewPU, monitorViewWU, monitors);
+ System.err.println("Test.0: Monitor union viewport: "+monitorViewPU+" [pu] / "+monitorViewWU+" [wu]");
+ Assert.assertNotEquals(zero, monitorViewPU);
+ Assert.assertNotEquals(zero, monitorViewWU);
+
+ final RectangleImmutable screenViewPU = screen.getViewport();
+ final RectangleImmutable screenViewWU = screen.getViewportInWindowUnits();
+ System.err.println("Test.1: Screen viewport: "+screenViewPU+" [pu] / "+screenViewWU+" [wu]");
+ Assert.assertNotEquals(zero, screenViewPU);
+ Assert.assertNotEquals(zero, screenViewWU);
+
+ screen.removeReference();
+
+ Assert.assertEquals(false,screen.isNativeValid());
+ Assert.assertEquals(false,screen.getDisplay().isNativeValid());
+ }
+
+ @Test
+ public void test02ScreenAllModesInfo() throws InterruptedException {
final Display dpy = NewtFactory.createDisplay(null);
final Screen screen = NewtFactory.createScreen(dpy, screenIdx);
screen.addReference();
@@ -189,39 +253,6 @@ public class TestScreenMode00aNEWT extends UITestCase {
}
Assert.assertTrue(allMonitorModes.containsAll(modes));
}
-
- // Dump all Monitor's and its DPI and current/original mode
- j=0;
- for(final Iterator<MonitorDevice> iMonitor=monitors.iterator(); iMonitor.hasNext(); j++) {
- final MonitorDevice monitor = iMonitor.next();
- System.err.println(j+": "+monitor);
- final float[] pixelPerMM = monitor.getPixelsPerMM(new float[2]);
- System.err.println(j+" pixel/mm ["+pixelPerMM[0]+", "+pixelPerMM[1]+"]");
- System.err.println(j+" pixel/in ["+pixelPerMM[0]*25.4f+", "+pixelPerMM[1]*25.4f+"]");
- final MonitorMode sm_o = monitor.getOriginalMode();
- Assert.assertNotNull(sm_o);
- final MonitorMode sm_c = monitor.queryCurrentMode();
- System.err.println("[0] orig : "+sm_o);
- System.err.println("[0] current: "+sm_c);
- Assert.assertNotNull(sm_c);
- Assert.assertEquals(sm_o, sm_c);
- }
-
- final RectangleImmutable zero = new Rectangle();
-
- final Rectangle monitorViewPU = new Rectangle();
- final Rectangle monitorViewWU = new Rectangle();
- MonitorDevice.unionOfViewports(monitorViewPU, monitorViewWU, monitors);
- System.err.println("Test.0: Monitor union viewport: "+monitorViewPU+" [pu] / "+monitorViewWU+" [wu]");
- Assert.assertNotEquals(zero, monitorViewPU);
- Assert.assertNotEquals(zero, monitorViewWU);
-
- final RectangleImmutable screenViewPU = screen.getViewport();
- final RectangleImmutable screenViewWU = screen.getViewportInWindowUnits();
- System.err.println("Test.1: Screen viewport: "+screenViewPU+" [pu] / "+screenViewWU+" [wu]");
- Assert.assertNotEquals(zero, screenViewPU);
- Assert.assertNotEquals(zero, screenViewWU);
-
screen.removeReference();
Assert.assertEquals(false,screen.isNativeValid());