diff options
Diffstat (limited to 'src')
21 files changed, 144 insertions, 45 deletions
diff --git a/src/newt/classes/com/jogamp/newt/MonitorDevice.java b/src/newt/classes/com/jogamp/newt/MonitorDevice.java index 7d4c7918e..97b04a4b3 100644 --- a/src/newt/classes/com/jogamp/newt/MonitorDevice.java +++ b/src/newt/classes/com/jogamp/newt/MonitorDevice.java @@ -62,6 +62,7 @@ public abstract class MonitorDevice { protected final Screen screen; // backref protected final long nativeHandle; // unique monitor device long handle, implementation specific protected final int nativeId; // unique monitor device integer Id, implementation specific + protected final String name; // optional monitor name, maybe an empty string 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! @@ -131,6 +132,7 @@ public abstract class MonitorDevice { * @param screen associated {@link Screen} * @param nativeHandle unique monitor device long handle, implementation specific * @param nativeId unique monitor device integer Id, implementation specific + * @param name optional monitor name, maybe null * @param isClone flag * @param isPrimary flag * @param sizeMM size in millimeters @@ -141,12 +143,13 @@ public abstract class MonitorDevice { * @param supportedModes all supported {@link MonitorMode}s */ 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) { + final String name, 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.name = null != name ? name : ""; this.sizeMM = sizeMM; this.originalMode = currentMode; this.supportedModes = supportedModes; @@ -200,6 +203,9 @@ public abstract class MonitorDevice { /** @return the immutable unique native integer Id of this monitor device, implementation specific. */ public final int getId() { return nativeId; } + /** @return optional monitor name, maybe an empty string but never null. */ + public final String getName() { return name; } + /** @return {@code true} if this device represents a <i>clone</i>, otherwise return {@code false}. */ public final boolean isClone() { return isClone; } @@ -405,7 +411,17 @@ public abstract class MonitorDevice { final StringBuilder sb = new StringBuilder(); sb.append("Monitor[Id ").append(Display.toHexString(nativeId)).append(" ["); { + if( !name.isEmpty() ) { + if( preComma ) { + sb.append(", "); + } + sb.append("name ").append("'").append(name).append("'"); + preComma = true; + } if( nativeHandle != nativeId ) { + if( preComma ) { + sb.append(", "); + } sb.append("handle ").append(Display.toHexString(nativeHandle)); preComma = true; } @@ -425,8 +441,8 @@ public abstract class MonitorDevice { } 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(pixelScale[1]).append("], viewport[pixel ").append(viewportPU).append(", window ").append(viewportWU) + .append("], 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 c5c1ee230..7f6ffeb13 100644 --- a/src/newt/classes/com/jogamp/newt/Screen.java +++ b/src/newt/classes/com/jogamp/newt/Screen.java @@ -282,6 +282,24 @@ public abstract class Screen { } /** + * Returns the {@link MonitorDevice} which matches the given name. + * <p> + * If no match is found or the given name is null or empty, null is being returned + * </p> + */ + public final MonitorDevice getMonitorByName(final String name) { + if( null == name || name.isEmpty() ) { + return null; + } + for(final MonitorDevice monitor : getMonitorDevices()) { + if( name.equals( monitor.getName() ) ) { + return monitor; + } + } + return null; + } + + /** * Calculates the union of all monitor's {@link MonitorDevice#getViewport() viewport} in pixel- and window units. * <p> * Should be equal to {@link #getX()}, {@link #getY()}, {@link #getWidth()} and {@link #getHeight()}, diff --git a/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java b/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java index 3e81d3877..11b1ceb87 100644 --- a/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java +++ b/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java @@ -42,6 +42,7 @@ public class MonitorDeviceImpl extends MonitorDevice { * @param screen associated {@link Screen} * @param nativeHandle unique monitor device long handle, implementation specific * @param nativeId unique monitor device integer Id, implementation specific + * @param name optional monitor name, maybe null * @param isClone flag * @param isPrimary flag * @param sizeMM size in millimeters @@ -51,11 +52,10 @@ public class MonitorDeviceImpl extends MonitorDevice { * @param viewportWU viewport in window-units * @param supportedModes all supported {@link MonitorMode}s */ - public MonitorDeviceImpl(final ScreenImpl 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) { - super(screen, nativeHandle, nativeId, isClone, isPrimary, sizeMM, currentMode, pixelScale, viewportPU, viewportWU, supportedModes); + public MonitorDeviceImpl(final ScreenImpl screen, final long nativeHandle, final int nativeId, final String name, 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, nativeHandle, nativeId, name, isClone, isPrimary, sizeMM, currentMode, pixelScale, viewportPU, viewportWU, supportedModes); } @Override diff --git a/src/newt/classes/jogamp/newt/MonitorModeProps.java b/src/newt/classes/jogamp/newt/MonitorModeProps.java index 292551559..d5567b1d8 100644 --- a/src/newt/classes/jogamp/newt/MonitorModeProps.java +++ b/src/newt/classes/jogamp/newt/MonitorModeProps.java @@ -272,6 +272,7 @@ public class MonitorModeProps { * @param cache hash arrays of unique {@link MonitorMode} components and {@link MonitorDevice}s, allowing to avoid duplicates * @param screen the associated {@link ScreenImpl} * @param monitor_handle unique monitor long handle, implementation specific + * @param monitor_name optional monitor name, maybe null * @param pixelScale pre-fetched current pixel-scale, maybe {@code null} for {@link ScalableSurface#IDENTITY_PIXELSCALE}. * @param invscale_wuviewport if true, the viewport in window-units will be scaled by 1/pixelScale for soft-pixel-scale * @param monitorProperties the input data inclusive supported modes. @@ -281,9 +282,8 @@ public class MonitorModeProps { * matching the input <code>modeProperties</code>, or null if input could not be processed. */ public static MonitorDevice streamInMonitorDevice(final Cache cache, final ScreenImpl screen, - final long monitor_handle, - final float[] pixelScale, final boolean invscale_wuviewport, - final int[] monitorProperties, int offset, final int[] monitor_idx) { + final long monitor_handle, final String monitor_name, final float[] pixelScale, + final boolean invscale_wuviewport, final int[] monitorProperties, int offset, final int[] monitor_idx) { // min 11: count, id, ScreenSizeMM[width, height], Viewport[x, y, width, height], currentMonitorModeId, rotation, supportedModeId+ final int count = monitorProperties[offset]; if(MIN_MONITOR_DEVICE_PROPERTIES > count) { @@ -323,7 +323,7 @@ public class MonitorModeProps { } } } - MonitorDevice monitorDevice = new MonitorDeviceImpl(screen, monitor_handle, id, isClone, isPrimary, + MonitorDevice monitorDevice = new MonitorDeviceImpl(screen, monitor_handle, id, monitor_name, isClone, isPrimary, sizeMM, currentMode, pixelScale, viewportPU, viewportWU, supportedModes); if(null!=cache) { @@ -362,6 +362,7 @@ public class MonitorModeProps { * @param cache hash arrays of unique {@link MonitorMode} components and {@link MonitorDevice}s, allowing to avoid duplicates * @param screen the associated {@link ScreenImpl} * @param monitor_handle unique monitor long handle, implementation specific + * @param monitor_name optional monitor name, maybe null * @param currentMode pre-fetched current {@link MonitorMode}s from cache. * @param pixelScale pre-fetched current pixel-scale, maybe {@code null} for {@link ScalableSurface#IDENTITY_PIXELSCALE}. * @param invscale_wuviewport if true, the viewport in window-units will be scaled by 1/pixelScale for soft-pixel-scale @@ -373,12 +374,11 @@ public class MonitorModeProps { * matching the input <code>modeProperties</code>, or null if input could not be processed. */ public static MonitorDevice streamInMonitorDevice(final Cache cache, final ScreenImpl screen, - final long monitor_handle, + final long monitor_handle, final String monitor_name, final MonitorMode currentMode, final float[] pixelScale, - final boolean invscale_wuviewport, - final ArrayHashSet<MonitorMode> supportedModes, final int[] monitorProperties, - int offset, final int[] monitor_idx) { + final boolean invscale_wuviewport, final ArrayHashSet<MonitorMode> supportedModes, + final int[] monitorProperties, int offset, final int[] monitor_idx) { // min 11: count, id, ScreenSizeMM[width, height], Viewport[x, y, width, height], currentMonitorModeId, rotation, supportedModeId+ final int count = monitorProperties[offset]; if(MIN_MONITOR_DEVICE_PROPERTIES - 1 - NUM_MONITOR_MODE_PROPERTIES != count) { @@ -400,9 +400,9 @@ public class MonitorModeProps { if( invscale_wuviewport && null != pixelScale ) { viewportWU.scaleInv(pixelScale[0], pixelScale[1]); } - MonitorDevice monitorDevice = new MonitorDeviceImpl(screen, monitor_handle, monitor_id, isClone, isPrimary, - sizeMM, currentMode, pixelScale, - viewportPU, viewportWU, supportedModes); + MonitorDevice monitorDevice = new MonitorDeviceImpl(screen, monitor_handle, monitor_id, monitor_name, isClone, + isPrimary, sizeMM, currentMode, + pixelScale, viewportPU, viewportWU, supportedModes); if(null!=cache) { monitorDevice = cache.monitorDevices.getOrAdd(monitorDevice); if( monitorDevice.isPrimary() ) { diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java index d90ee73bb..17265a6a7 100644 --- a/src/newt/classes/jogamp/newt/ScreenImpl.java +++ b/src/newt/classes/jogamp/newt/ScreenImpl.java @@ -360,8 +360,8 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { * <li>{@link MonitorModeProps#MIN_MONITOR_DEVICE_PROPERTIES}</li> * </ul>, i.e. * <ul> - * <li>{@link MonitorModeProps#streamInMonitorDevice(jogamp.newt.MonitorModeProps.Cache, ScreenImpl, long, double[], boolean, int[], int, int[])}</li> - * <li>{@link MonitorModeProps#streamInMonitorDevice(int[], jogamp.newt.MonitorModeProps.Cache, long, ArrayHashSet, boolean, int[], int, ScreenImpl)}</li> + * <li>{@link MonitorModeProps#streamInMonitorDevice(jogamp.newt.MonitorModeProps.Cache, ScreenImpl, long, String, double[], boolean, int[], int, int[])}</li> + * <li>{@link MonitorModeProps#streamInMonitorDevice(int[], jogamp.newt.MonitorModeProps.Cache, long, String, ArrayHashSet, boolean, int[], int, ScreenImpl)}</li> * <li>{@link MonitorModeProps#streamInMonitorMode(int[], jogamp.newt.MonitorModeProps.Cache, int[], int)}</li> * </ul> * @param cache memory pool caching the result @@ -520,7 +520,8 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { if( MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES != i ) { throw new InternalError("XX"); } - return MonitorModeProps.streamInMonitorDevice(cache, this, monitorId, null, false /* invscale_wuviewport */, props, 0, null); + final String monitor_name = null; + return MonitorModeProps.streamInMonitorDevice(cache, this, monitorId, monitor_name, null, false /* invscale_wuviewport */, props, 0, null); } /** diff --git a/src/newt/classes/jogamp/newt/driver/android/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/android/ScreenDriver.java index 8d73592b5..fbad10c8c 100644 --- a/src/newt/classes/jogamp/newt/driver/android/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/android/ScreenDriver.java @@ -116,7 +116,7 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { props[i++] = 0; // rotated viewport y window-units props[i++] = outMetrics.widthPixels; // rotated viewport width window-units props[i++] = outMetrics.heightPixels; // rotated viewport height window-units - MonitorModeProps.streamInMonitorDevice(cache, this, crt_id, currentMode, null, false, cache.monitorModes, props, 0, null); + MonitorModeProps.streamInMonitorDevice(cache, this, crt_id, null, currentMode, null, false, cache.monitorModes, props, 0, null); } @Override diff --git a/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java index fc4bf03a4..18c60ea84 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java @@ -122,7 +122,7 @@ public class ScreenDriver extends ScreenImpl { props[i++] = 0; // rotated viewport y window-units props[i++] = currentMode.getRotatedWidth(); // rotated viewport width window-units props[i++] = currentMode.getRotatedHeight(); // rotated viewport height window-units - MonitorModeProps.streamInMonitorDevice(cache, this, crt_id, currentMode, null, false, cache.monitorModes, props, 0, null); + MonitorModeProps.streamInMonitorDevice(cache, this, crt_id, null, currentMode, null, false, cache.monitorModes, props, 0, null); } @Override 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 3cdb368f2..3d2e8fc3a 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java @@ -97,7 +97,7 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { props[i++] = 0; // rotated viewport y window-units props[i++] = fixedWidth; // FIXME rotated viewport width window-units props[i++] = fixedHeight; // FIXME rotated viewport height window-units - MonitorModeProps.streamInMonitorDevice(cache, this, crt_id, currentMode, null, false, cache.monitorModes, props, 0, null); + MonitorModeProps.streamInMonitorDevice(cache, this, crt_id, null, currentMode, null, false, cache.monitorModes, props, 0, null); } @Override 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 1b3807a94..6b4d97baa 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 @@ -90,7 +90,7 @@ public class ScreenDriver extends ScreenImpl { props[i++] = 0; // rotated viewport y window-units props[i++] = cachedWidth; // rotated viewport width window-units props[i++] = cachedHeight; // rotated viewport height window-units - MonitorModeProps.streamInMonitorDevice(cache, this, crt_id, currentMode, null, false, cache.monitorModes, props, 0, null); + MonitorModeProps.streamInMonitorDevice(cache, this, crt_id, null, currentMode, null, false, cache.monitorModes, props, 0, null); } @Override diff --git a/src/newt/classes/jogamp/newt/driver/egl/gbm/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/egl/gbm/ScreenDriver.java index a08b5a445..e25a0eb22 100644 --- a/src/newt/classes/jogamp/newt/driver/egl/gbm/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/egl/gbm/ScreenDriver.java @@ -129,7 +129,7 @@ public class ScreenDriver extends ScreenImpl { props[i++] = 0; // rotated viewport y window-units props[i++] = mode[scridx].getHdisplay(); // rotated viewport width window-units props[i++] = mode[scridx].getVdisplay(); // rotated viewport height window-units - MonitorModeProps.streamInMonitorDevice(cache, this, crt_id, currentMode, null, false, cache.monitorModes, props, 0, null); + MonitorModeProps.streamInMonitorDevice(cache, this, crt_id, null, currentMode, null, false, cache.monitorModes, props, 0, null); crtc_ids = new int[] { encoder[scridx].getCrtc_id() }; 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 7eb6eea92..456545430 100644 --- a/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java @@ -99,7 +99,7 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { props[i++] = 0; // rotated viewport y window-units props[i++] = cachedWidth; // rotated viewport width window-units props[i++] = cachedWidth; // rotated viewport height window-units - MonitorModeProps.streamInMonitorDevice(cache, this, crt_id, currentMode, null, false, cache.monitorModes, props, 0, null); + MonitorModeProps.streamInMonitorDevice(cache, this, crt_id, null, currentMode, null, false, cache.monitorModes, props, 0, null); } @Override diff --git a/src/newt/classes/jogamp/newt/driver/ios/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/ios/ScreenDriver.java index 4cf459699..234ee187c 100644 --- a/src/newt/classes/jogamp/newt/driver/ios/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/ios/ScreenDriver.java @@ -176,9 +176,9 @@ public class ScreenDriver extends ScreenImpl { } // merge monitor-props + supported modes final float pixelScale = crtProps.pixelScaleArray[crtIdx]; - MonitorModeProps.streamInMonitorDevice(cache, this, crt_id, currentMode, - new float[] { pixelScale, pixelScale }, false /* invscale_wuviewport */, - supportedModes, crtProps.propsFixedArray[crtIdx], 0, null); + MonitorModeProps.streamInMonitorDevice(cache, this, crt_id, null, + currentMode, new float[] { pixelScale, pixelScale }, + false /* invscale_wuviewport */, supportedModes, crtProps.propsFixedArray[crtIdx], 0, null); } } diff --git a/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java index ba28e161d..0b70737ac 100644 --- a/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java @@ -95,7 +95,7 @@ public class ScreenDriver extends ScreenImpl { props[i++] = 0; // rotated viewport y window-units props[i++] = cachedWidth; // rotated viewport width window-units props[i++] = cachedWidth; // rotated viewport height window-units - MonitorModeProps.streamInMonitorDevice(cache, this, crt_id, currentMode, null, false, cache.monitorModes, props, 0, null); + MonitorModeProps.streamInMonitorDevice(cache, this, crt_id, null, currentMode, null, false, cache.monitorModes, props, 0, null); } @Override diff --git a/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java index 635fffc0b..8cb900abd 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java @@ -182,9 +182,9 @@ public class ScreenDriver extends ScreenImpl { } // merge monitor-props + supported modes final float pixelScale = crtProps.pixelScaleArray[crtIdx]; - MonitorModeProps.streamInMonitorDevice(cache, this, crt_id, currentMode, - new float[] { pixelScale, pixelScale }, false /* invscale_wuviewport */, - supportedModes, crtProps.propsFixedArray[crtIdx], 0, null); + MonitorModeProps.streamInMonitorDevice(cache, this, crt_id, null, + currentMode, new float[] { pixelScale, pixelScale }, + false /* invscale_wuviewport */, supportedModes, crtProps.propsFixedArray[crtIdx], 0, null); } } diff --git a/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java index c3aa94648..386935586 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java @@ -110,7 +110,8 @@ public class ScreenDriver extends ScreenImpl { new ArrayHashSet<MonitorMode>(false, ArrayHashSet.DEFAULT_INITIAL_CAPACITY, ArrayHashSet.DEFAULT_LOAD_FACTOR); String adapterName; for(int adapterIdx=0; null != ( adapterName = getAdapterName(adapterIdx) ); adapterIdx++ ) { - for(int monitorIdx=0; null != getMonitorName(adapterName, monitorIdx, true); monitorIdx++ ) { + String monitor_name = null; + for(int monitorIdx=0; null != (monitor_name = getMonitorName(adapterName, monitorIdx, true)); monitorIdx++ ) { int modeIdx = 0; MonitorMode mode; do { @@ -143,8 +144,8 @@ public class ScreenDriver extends ScreenImpl { monitor_handle = monitor_id; } // merge monitor-props + supported modes - MonitorModeProps.streamInMonitorDevice(cache, this, monitor_handle, currentMode, pixel_scale, true /* invscale_wuviewport */, - supportedModes, monitorProps, 0, null); + MonitorModeProps.streamInMonitorDevice(cache, this, monitor_handle, monitor_name, currentMode, pixel_scale, + true /* invscale_wuviewport */, supportedModes, monitorProps, 0, null); // next monitor, 1st mode supportedModes = new ArrayHashSet<MonitorMode>(false, ArrayHashSet.DEFAULT_INITIAL_CAPACITY, ArrayHashSet.DEFAULT_LOAD_FACTOR); diff --git a/src/newt/classes/jogamp/newt/driver/x11/RandR.java b/src/newt/classes/jogamp/newt/driver/x11/RandR.java index a421289e2..ae6bc1061 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/RandR.java +++ b/src/newt/classes/jogamp/newt/driver/x11/RandR.java @@ -80,6 +80,7 @@ public interface RandR { */ int[] getMonitorModeProps(final long dpy, final ScreenDriver screen, final int mode_idx); int[] getMonitorDeviceProps(final long dpy, final ScreenDriver screen, MonitorModeProps.Cache cache, final int crt_id); + String getMonitorName(final long dpy, final ScreenDriver screen, final int crt_id); int[] getMonitorDeviceViewport(final long dpy, final ScreenDriver screen, final int crt_id); int[] getCurrentMonitorModeProps(final long dpy, final ScreenDriver screen, final int crt_id); /** The device shall be locked, blocking message handling. */ diff --git a/src/newt/classes/jogamp/newt/driver/x11/RandR11.java b/src/newt/classes/jogamp/newt/driver/x11/RandR11.java index 8fd03320a..ff2c75024 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/RandR11.java +++ b/src/newt/classes/jogamp/newt/driver/x11/RandR11.java @@ -215,6 +215,11 @@ class RandR11 implements RandR { } @Override + public String getMonitorName(final long dpy, final ScreenDriver screen, final int crt_id) { + return null; + } + + @Override public int[] getMonitorDeviceViewport(final long dpy, final ScreenDriver screen, final int crt_id) { if( SINGLE_CRT_ID != crt_id ) { // RandR11 only supports 1 CRT diff --git a/src/newt/classes/jogamp/newt/driver/x11/RandR13.java b/src/newt/classes/jogamp/newt/driver/x11/RandR13.java index bd3c7925e..d2b6cc022 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/RandR13.java +++ b/src/newt/classes/jogamp/newt/driver/x11/RandR13.java @@ -194,6 +194,22 @@ class RandR13 implements RandR { } @Override + public String getMonitorName(final long dpy, final ScreenDriver screen, final int crt_id) { + final int screen_idx = screen.getIndex(); + final long screenResources = getScreenResourceHandle(dpy, screen_idx); + try { + final long monitorInfo = getMonitorInfoHandle(dpy, screen_idx, screenResources, crt_id); + try { + return getMonitorName0(dpy, screenResources, monitorInfo, crt_id); + } finally { + releaseMonitorInfoHandle(monitorInfo); + } + } finally { + releaseScreenResourceHandle(screenResources); + } + } + + @Override public int[] getMonitorDeviceViewport(final long dpy, final ScreenDriver screen, final int crt_id) { final int screen_idx = screen.getIndex(); final long screenResources = getScreenResourceHandle(dpy, screen_idx); @@ -279,6 +295,7 @@ class RandR13 implements RandR { private static native int[] getMonitorMode0(long screenResources, int mode_index); private static native int[] getMonitorCurrentMode0(long screenResources, long monitorInfo); private static native int[] getMonitorDevice0(long display, long screenResources, long monitorInfo, int crtc_id); + private static native String getMonitorName0(long display, long screenResources, long monitorInfo, int crtc_id); private static native boolean setMonitorMode0(long display, int screen_index, long screenResources, long monitorInfo, int crtc_id, diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java index c6b91cbf6..1ffa26407 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java @@ -174,11 +174,12 @@ public class ScreenDriver extends ScreenImpl { for(int i = 0; i < crtCount; i++) { final int crt_id = crt_ids[i]; final int[] monitorProps = rAndR.getMonitorDeviceProps(device.getHandle(), this, cache, crt_id); + final String monitorName = rAndR.getMonitorName(device.getHandle(), this, crt_id); if( null != monitorProps && MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES <= monitorProps[0] && // Enabled ? I.e. contains active modes ? MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES <= monitorProps.length ) { - MonitorModeProps.streamInMonitorDevice(cache, this, crt_id, pixel_scale, true /* invscale_wuviewport */, - monitorProps, 0, null); + MonitorModeProps.streamInMonitorDevice(cache, this, crt_id, monitorName, pixel_scale, + true /* invscale_wuviewport */, monitorProps, 0, null); } } } diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java index 38c463e7c..28f881bab 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java @@ -333,7 +333,7 @@ public class WindowDriver extends WindowImpl { if(DEBUG_IMPLEMENTATION) { System.err.println("Info: Window Device Changed (P: "+newX+"/"+newY+ ", crt_move[orient "+orientation+", diff "+move_diff[0]+"/"+move_diff[1]+") "+ - ", monitor "+last_monitor.getId()+" -> "+new_monitor.getId()+ + ", monitor "+last_monitor.getName()+" -> "+new_monitor.getName()+ " - "+Thread.currentThread().getName()); } last_monitor = new_monitor; diff --git a/src/newt/native/X11RandR13.c b/src/newt/native/X11RandR13.c index 3f9dff289..02222c533 100644 --- a/src/newt/native/X11RandR13.c +++ b/src/newt/native/X11RandR13.c @@ -458,7 +458,7 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getMonitorDevice { Display * dpy = (Display *) (intptr_t) display; XRRScreenResources *resources = (XRRScreenResources *) (intptr_t) screenResources; - RRCrtc crtc = findRRCrtc( resources, (RRCrtc)(intptr_t)crt_id ); + RRCrtc crtc = findRRCrtc( resources, (RRCrtc)(intptr_t)crt_id ); // just re-validation if( 0 == crtc ) { // n/a return NULL; @@ -522,6 +522,45 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getMonitorDevice /* * Class: jogamp_newt_driver_x11_RandR13 + * Method: getMonitorName0 + * Signature: (JJJJ)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_jogamp_newt_driver_x11_RandR13_getMonitorName0 + (JNIEnv *env, jclass clazz, jlong display, jlong screenResources, jlong monitorInfo, jint crt_id) +{ + Display * dpy = (Display *) (intptr_t) display; + XRRScreenResources *resources = (XRRScreenResources *) (intptr_t) screenResources; + RRCrtc crtc = findRRCrtc( resources, (RRCrtc)(intptr_t)crt_id ); // just re-validation + if( 0 == crtc ) { + // n/a + return NULL; + } + XRRCrtcInfo *xrrCrtcInfo = (XRRCrtcInfo *) (intptr_t) monitorInfo; + if( NULL == xrrCrtcInfo ) { + // n/a + return NULL; + } + + RROutput output = xrrCrtcInfo->outputs[0]; + XRROutputInfo * xrrOutputInfo = XRRGetOutputInfo (dpy, resources, output); + int name_len = xrrOutputInfo->nameLen; + char* name = xrrOutputInfo->name; + if( NULL == name || 0 == name_len ) { + // n/a + return NULL; + } + char * name_copy = strndup(name, name_len); + XRRFreeOutputInfo (xrrOutputInfo); + if( NULL == name_copy ) { + return NULL; + } + jstring res = (*env)->NewStringUTF(env, name_copy); + free(name_copy); + return res; +} + +/* + * Class: jogamp_newt_driver_x11_RandR13 * Method: setMonitorMode0 * Signature: (JJJIIIII)Z */ @@ -534,7 +573,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_RandR13_setMonitorMode0 Display * dpy = (Display *) (intptr_t) display; Window root = RootWindow(dpy, (int)screen_idx); XRRScreenResources *resources = (XRRScreenResources *) (intptr_t) screenResources; - RRCrtc crtc = findRRCrtc( resources, (RRCrtc)(intptr_t)crt_id ); + RRCrtc crtc = findRRCrtc( resources, (RRCrtc)(intptr_t)crt_id ); // just re-validation if( 0 == crtc ) { // n/a DBG_PRINT("RandR13_setMonitorMode0.0: n/a: resources %p (%d), crt_id %#lx \n", |