diff options
author | Sven Gothel <[email protected]> | 2023-01-29 19:56:45 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-01-29 19:56:45 +0100 |
commit | e96aeb6e9acd2b1435f5fad244a1488e74a3a6d6 (patch) | |
tree | 68a4466d97b006e63f12040ff2db0a24d263344c /src/newt/classes/com/jogamp | |
parent | 516d3d57eb54f6fe95d842d29a2929e024ee8f34 (diff) |
GDIUtil: Add GetMonitor*() variants incl. PixelScale; NEWT MonitorDevice: Add 64-bit nativeHandle (Windows HMONITOR), add PixelScale for Windows
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 | 14 |
2 files changed, 31 insertions, 6 deletions
diff --git a/src/newt/classes/com/jogamp/newt/MonitorDevice.java b/src/newt/classes/com/jogamp/newt/MonitorDevice.java index e96fc82f5..584b83505 100644 --- a/src/newt/classes/com/jogamp/newt/MonitorDevice.java +++ b/src/newt/classes/com/jogamp/newt/MonitorDevice.java @@ -60,7 +60,8 @@ import com.jogamp.common.util.ArrayHashSet; */ public abstract class MonitorDevice { protected final Screen screen; // backref - protected final int nativeId; // unique monitor device ID + protected final long nativeHandle; // unique monitor device long handle, implementation specific + protected final int nativeId; // unique monitor device integer Id, implementation specific 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! @@ -74,7 +75,8 @@ public abstract class MonitorDevice { /** * @param screen associated {@link Screen} - * @param nativeId unique monitor device ID + * @param nativeHandle unique monitor device long handle, implementation specific + * @param nativeId unique monitor device integer Id, implementation specific * @param isClone flag * @param isPrimary flag * @param sizeMM size in millimeters @@ -84,16 +86,17 @@ 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, + protected MonitorDevice(final Screen screen, final long nativeHandle, 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.nativeHandle = nativeHandle; this.nativeId = nativeId; this.sizeMM = sizeMM; this.originalMode = currentMode; this.supportedModes = supportedModes; - this.pixelScale = null != pixelScale ? pixelScale : new float[] { 1.0f, 1.0f }; + this.pixelScale = null != pixelScale ? pixelScale : new float[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE }; this.viewportPU = viewportPU; this.viewportWU = viewportWU; @@ -137,7 +140,10 @@ public abstract class MonitorDevice { return nativeId; } - /** @return the immutable unique native Id of this monitor device. */ + /** @return the immutable unique native long handle of this monitor device, implementation specific. */ + public final long getHandle() { return nativeHandle; } + + /** @return the immutable unique native integer Id of this monitor device, implementation specific. */ public final int getId() { return nativeId; } /** @return {@code true} if this device represents a <i>clone</i>, otherwise return {@code false}. */ @@ -345,7 +351,14 @@ public abstract class MonitorDevice { final StringBuilder sb = new StringBuilder(); sb.append("Monitor[Id ").append(Display.toHexString(nativeId)).append(" ["); { + if( nativeHandle != nativeId ) { + sb.append("handle ").append(Display.toHexString(nativeHandle)); + preComma = true; + } if( isClone() ) { + if( preComma ) { + sb.append(", "); + } sb.append("clone"); preComma = true; } diff --git a/src/newt/classes/com/jogamp/newt/Screen.java b/src/newt/classes/com/jogamp/newt/Screen.java index 9b2a280f9..4c4faef8d 100644 --- a/src/newt/classes/com/jogamp/newt/Screen.java +++ b/src/newt/classes/com/jogamp/newt/Screen.java @@ -245,7 +245,7 @@ public abstract class Screen { return monitors.get(0); } - public final MonitorDevice getMonitor(final int monitorId) { + public final MonitorDevice getMonitorById(final int monitorId) { final List<MonitorDevice> monitors = getMonitorDevices(); final int monitorCount = monitors.size(); for(int i=0; i<monitorCount; i++) { @@ -257,6 +257,18 @@ public abstract class Screen { return null; } + public final MonitorDevice getMonitorByHandle(final long monitorHandle) { + final List<MonitorDevice> monitors = getMonitorDevices(); + final int monitorCount = monitors.size(); + for(int i=0; i<monitorCount; i++) { + final MonitorDevice monitor = monitors.get(i); + if( monitor.getHandle() == monitorHandle ) { + return monitor; + } + } + return null; + } + /** * Calculates the union of all monitor's {@link MonitorDevice#getViewport() viewport} in pixel- and window units. * <p> |