diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java | 16 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/awt/NewtFactoryAWT.java | 6 |
2 files changed, 14 insertions, 8 deletions
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java index 3eb5328bd..d2dc8f91b 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java @@ -557,19 +557,25 @@ public class JAWTUtil { return jawtToolkitLock; } - public static final int getMonitorDisplayID(final GraphicsDevice device) { - int displayID = 0; + /** + * Queries the Monitor's display ID of the given device + * <p> + * Currently only supported for OSX on Java<9 + * </p> + * @param device for which the display id is being queried + * @return {@code null} if not supported (Java9+ or !OSX), otherwise the monitor displayID + */ + public static final Integer getMonitorDisplayID(final GraphicsDevice device) { if( null != getCGDisplayIDMethodOnOSX ) { // OSX specific for Java<9 try { final Object res = getCGDisplayIDMethodOnOSX.invoke(device); if (res instanceof Integer) { - displayID = ((Integer)res).intValue(); + return (Integer)res; } } catch (final Throwable t) {} } - // TODO: Needs non-reflective Java9+ solution for all platforms - return displayID; + return null; } /** diff --git a/src/newt/classes/jogamp/newt/awt/NewtFactoryAWT.java b/src/newt/classes/jogamp/newt/awt/NewtFactoryAWT.java index 4e9273e83..97625c8aa 100644 --- a/src/newt/classes/jogamp/newt/awt/NewtFactoryAWT.java +++ b/src/newt/classes/jogamp/newt/awt/NewtFactoryAWT.java @@ -170,12 +170,12 @@ public class NewtFactoryAWT extends NewtFactory { */ public static MonitorDevice getMonitorDevice(final Screen screen, final java.awt.Component awtComp) throws IllegalArgumentException { final java.awt.GraphicsConfiguration gc = checkComponentValid(awtComp); - final String nwt = NativeWindowFactory.getNativeWindowType(true); MonitorDevice res = null; screen.addReference(); try { - if( NativeWindowFactory.TYPE_MACOSX == nwt ) { - res = screen.getMonitor( JAWTUtil.getMonitorDisplayID( gc.getDevice() ) ); + final Integer dispID = JAWTUtil.getMonitorDisplayID( gc.getDevice() ); + if( null != dispID ) { + res = screen.getMonitor( dispID.intValue() ); } if( null == res ) { // Fallback, use AWT component coverage |