aboutsummaryrefslogtreecommitdiffstats
path: root/src/nativewindow
diff options
context:
space:
mode:
Diffstat (limited to 'src/nativewindow')
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowFactory.java40
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java50
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/util/PixelFormat.java4
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/util/PixelFormatUtil.java12
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java55
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java88
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java6
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java4
-rw-r--r--src/nativewindow/native/macosx/OSXmisc.m28
-rw-r--r--src/nativewindow/native/x11/Xmisc.c6
-rw-r--r--src/nativewindow/native/x11/Xmisc.h26
11 files changed, 247 insertions, 72 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowFactory.java
index cba3a9214..d01e3a203 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowFactory.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowFactory.java
@@ -70,8 +70,11 @@ import com.jogamp.nativewindow.x11.X11GraphicsScreen;
adapt their components to the {@link NativeWindow} interface,
which provides a platform-independent mechanism of accessing the
information required to perform operations like
- hardware-accelerated rendering using the OpenGL API. */
-
+ hardware-accelerated rendering using the OpenGL API.
+ * <p>
+ * FIXME: Bug 973 Needs service provider interface (SPI) for TK dependent implementation
+ * </p>
+ */
public abstract class NativeWindowFactory {
protected static final boolean DEBUG;
@@ -421,6 +424,9 @@ public abstract class NativeWindowFactory {
}
/** Don't know if we shall add this factory here ..
+ * <p>
+ * FIXME: Bug 973 Needs service provider interface (SPI) for TK dependent implementation
+ * </p>
public static AbstractGraphicsDevice createGraphicsDevice(String type, String connection, int unitID, long handle, ToolkitLock locker) {
if(TYPE_EGL == type) {
return new
@@ -632,6 +638,9 @@ public abstract class NativeWindowFactory {
* If the visualID is {@link VisualIDHolder#VID_UNDEFINED} and the platform requires it
* at creation time (see above), it is not valid for further processing.
* </p>
+ * <p>
+ * FIXME: Bug 973 Needs service provider interface (SPI) for TK dependent implementation
+ * </p>
*/
public static boolean isNativeVisualIDValidForProcessing(final int visualID) {
return NativeWindowFactory.TYPE_X11 != NativeWindowFactory.getNativeWindowType(false) ||
@@ -645,7 +654,18 @@ public abstract class NativeWindowFactory {
* </p>
*/
public static AbstractGraphicsDevice createDevice(final String displayConnection, final boolean own) {
- final String nwt = NativeWindowFactory.getNativeWindowType(true);
+ return createDevice(NativeWindowFactory.getNativeWindowType(true), displayConnection, own);
+ }
+ /**
+ * Creates a native device type, following the given {@link #getNativeWindowType(boolean) native-window-type}.
+ * <p>
+ * The device will be opened if <code>own</code> is true, otherwise no native handle will ever be acquired.
+ * </p>
+ * <p>
+ * FIXME: Bug 973 Needs service provider interface (SPI) for TK dependent implementation
+ * </p>
+ */
+ public static AbstractGraphicsDevice createDevice(final String nwt, final String displayConnection, final boolean own) {
if( NativeWindowFactory.TYPE_X11 == nwt ) {
if( own ) {
return new X11GraphicsDevice(displayConnection, AbstractGraphicsDevice.DEFAULT_UNIT, null /* ToolkitLock */);
@@ -656,16 +676,13 @@ public abstract class NativeWindowFactory {
return new WindowsGraphicsDevice(AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT);
} else if( NativeWindowFactory.TYPE_MACOSX == nwt ) {
return new MacOSXGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT);
- /**
- * FIXME: Needs service provider interface (SPI) for TK dependent implementation
- } else if( NativeWindowFactory.TYPE_BCM_VC_IV == nwt ) {
- } else if( NativeWindowFactory.TYPE_ANDROID== nwt ) {
} else if( NativeWindowFactory.TYPE_EGL == nwt ) {
- } else if( NativeWindowFactory.TYPE_BCM_VC_IV == nwt ) {
+ throw new UnsupportedOperationException("n/a for windowing system: "+nwt);
} else if( NativeWindowFactory.TYPE_AWT == nwt ) {
- */
+ throw new UnsupportedOperationException("n/a for windowing system: "+nwt);
+ } else {
+ return new DefaultGraphicsDevice(nwt, displayConnection, AbstractGraphicsDevice.DEFAULT_UNIT);
}
- throw new UnsupportedOperationException("n/a for windowing system: "+nwt);
}
/**
@@ -691,6 +708,9 @@ public abstract class NativeWindowFactory {
/**
* @param nw
* @return top-left client-area position in window units
+ * <p>
+ * FIXME: Bug 973 Needs service provider interface (SPI) for TK dependent implementation
+ * </p>
*/
public static PointImmutable getLocationOnScreen(final NativeWindow nw) {
final String nwt = NativeWindowFactory.getNativeWindowType(true);
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
index f1442abee..d315e1876 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java
@@ -805,27 +805,10 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
* </p>
*/
@Override
- public Point getLocationOnScreen(Point storage) {
+ public Point getLocationOnScreen(final Point storage) {
Point los = getLocationOnScreenNative(storage);
if(null == los) {
- if(!Thread.holdsLock(component.getTreeLock())) {
- // avoid deadlock ..
- if(DEBUG) {
- System.err.println("Warning: JAWT Lock hold, but not the AWT tree lock: "+this);
- ExceptionUtils.dumpStack(System.err);
- }
- if( null == storage ) {
- storage = new Point();
- }
- getLocationOnScreenNonBlocking(storage, component);
- return storage;
- }
- final java.awt.Point awtLOS = component.getLocationOnScreen();
- if(null!=storage) {
- los = storage.translate(awtLOS.x, awtLOS.y);
- } else {
- los = new Point(awtLOS.x, awtLOS.y);
- }
+ los = AWTMisc.getLocationOnScreenSafe(storage, component, DEBUG);
}
return los;
}
@@ -854,35 +837,6 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
}
protected abstract Point getLocationOnScreenNativeImpl(int x, int y);
- protected static Component getLocationOnScreenNonBlocking(final Point storage, Component comp) {
- final java.awt.Insets insets = new java.awt.Insets(0, 0, 0, 0); // DEBUG
- Component last = null;
- while(null != comp) {
- final int dx = comp.getX();
- final int dy = comp.getY();
- if( DEBUG ) {
- final java.awt.Insets ins = AWTMisc.getInsets(comp, false);
- if( null != ins ) {
- insets.bottom += ins.bottom;
- insets.top += ins.top;
- insets.left += ins.left;
- insets.right += ins.right;
- }
- System.err.print("LOS: "+storage+" + "+comp.getClass().getName()+"["+dx+"/"+dy+", vis "+comp.isVisible()+", ins "+ins+" -> "+insets+"] -> ");
- }
- storage.translate(dx, dy);
- if( DEBUG ) {
- System.err.println(storage);
- }
- last = comp;
- if( comp instanceof Window ) { // top-level heavy-weight ?
- break;
- }
- comp = comp.getParent();
- }
- return last;
- }
-
@Override
public boolean hasFocus() {
return component.hasFocus();
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/util/PixelFormat.java b/src/nativewindow/classes/com/jogamp/nativewindow/util/PixelFormat.java
index 8b1e91564..748e14f0d 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/util/PixelFormat.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/util/PixelFormat.java
@@ -425,7 +425,7 @@ public enum PixelFormat {
boolean isInterleaved();
/** Number of components per pixel, e.g. 3 for {@link PixelFormat#RGBx8888 RGBx8888}. */
- int componenCount();
+ int componentCount();
/** Number of bits per pixel, e.g. 24 bits for {@link PixelFormat#RGBx8888 RGBx8888}. */
int bitsPerPixel();
/**
@@ -602,7 +602,7 @@ public enum PixelFormat {
@Override
public final boolean isInterleaved() { return true; }
@Override
- public final int componenCount() { return compMask.length; }
+ public final int componentCount() { return compMask.length; }
@Override
public final int bitsPerPixel() { return bitsPerPixel; }
@Override
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/util/PixelFormatUtil.java b/src/nativewindow/classes/com/jogamp/nativewindow/util/PixelFormatUtil.java
index 180f02d72..42f6ccb8a 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/util/PixelFormatUtil.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/util/PixelFormatUtil.java
@@ -46,12 +46,12 @@ public class PixelFormatUtil {
public static class ComponentMap {
/**
* Contains the source index for each destination index,
- * length is {@link Composition#componenCount()} of destination.
+ * length is {@link Composition#componentCount()} of destination.
*/
final int[] dst2src;
/**
* Contains the destination index for each source index,
- * length is {@link Composition#componenCount()} of source.
+ * length is {@link Composition#componentCount()} of source.
*/
final int[] src2dst;
@@ -62,8 +62,8 @@ public class PixelFormatUtil {
final boolean hasSrcRGB;
public ComponentMap(final PixelFormat.Composition src, final PixelFormat.Composition dst) {
- final int sCompCount = src.componenCount();
- final int dCompCount = dst.componenCount();
+ final int sCompCount = src.componentCount();
+ final int dCompCount = dst.componentCount();
final PixelFormat.CType[] sCompOrder = src.componentOrder();
final PixelFormat.CType[] dCompOrder = dst.componentOrder();
@@ -513,8 +513,8 @@ public class PixelFormatUtil {
final Bitstream<ByteBuffer> dstBitStream,
final PixelFormat.Composition srcComp,
final Bitstream<ByteBuffer> srcBitStream) throws IllegalStateException, IOException {
- final int sCompCount = srcComp.componenCount();
- final int dCompCount = dstComp.componenCount();
+ final int sCompCount = srcComp.componentCount();
+ final int dCompCount = dstComp.componentCount();
final int[] sc = new int[sCompCount];
final int[] dcDef = new int[dCompCount];
final int[] srcCompBitCount = srcComp.componentBitCount();
diff --git a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java
index 0c072d05b..3900f03db 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java
@@ -44,11 +44,13 @@ import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JRootPane;
import javax.swing.WindowConstants;
+
import com.jogamp.nativewindow.NativeWindowException;
import com.jogamp.nativewindow.WindowClosingProtocol;
import com.jogamp.nativewindow.util.PixelRectangle;
import com.jogamp.nativewindow.util.PixelFormat;
import com.jogamp.nativewindow.util.PixelFormatUtil;
+
import javax.swing.MenuSelectionManager;
import com.jogamp.nativewindow.awt.DirectDataBufferInt;
@@ -115,6 +117,59 @@ public class AWTMisc {
return null;
}
+ public static com.jogamp.nativewindow.util.Point getLocationOnScreenSafe(com.jogamp.nativewindow.util.Point storage,
+ final Component component,
+ final boolean verbose)
+ {
+ if(!Thread.holdsLock(component.getTreeLock())) {
+ // avoid deadlock ..
+ if( null == storage ) {
+ storage = new com.jogamp.nativewindow.util.Point();
+ }
+ getLocationOnScreenNonBlocking(storage, component, verbose);
+ return storage;
+ }
+ final java.awt.Point awtLOS = component.getLocationOnScreen();
+ com.jogamp.nativewindow.util.Point los;
+ if(null!=storage) {
+ los = storage.translate(awtLOS.x, awtLOS.y);
+ } else {
+ los = new com.jogamp.nativewindow.util.Point(awtLOS.x, awtLOS.y);
+ }
+ return los;
+ }
+ public static Component getLocationOnScreenNonBlocking(final com.jogamp.nativewindow.util.Point storage,
+ Component comp,
+ final boolean verbose)
+ {
+ final java.awt.Insets insets = new java.awt.Insets(0, 0, 0, 0); // DEBUG
+ Component last = null;
+ while(null != comp) {
+ final int dx = comp.getX();
+ final int dy = comp.getY();
+ if( verbose ) {
+ final java.awt.Insets ins = getInsets(comp, false);
+ if( null != ins ) {
+ insets.bottom += ins.bottom;
+ insets.top += ins.top;
+ insets.left += ins.left;
+ insets.right += ins.right;
+ }
+ System.err.print("LOS: "+storage+" + "+comp.getClass().getName()+"["+dx+"/"+dy+", vis "+comp.isVisible()+", ins "+ins+" -> "+insets+"] -> ");
+ }
+ storage.translate(dx, dy);
+ if( verbose ) {
+ System.err.println(storage);
+ }
+ last = comp;
+ if( comp instanceof Window ) { // top-level heavy-weight ?
+ break;
+ }
+ comp = comp.getParent();
+ }
+ return last;
+ }
+
public static interface ComponentAction {
/**
* @param c the component to perform the action on
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java
index e733b7233..93c3dbaf7 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java
@@ -49,14 +49,19 @@ import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Map;
+import com.jogamp.nativewindow.AbstractGraphicsDevice;
+import com.jogamp.nativewindow.AbstractGraphicsScreen;
import com.jogamp.nativewindow.NativeWindowException;
import com.jogamp.nativewindow.NativeWindowFactory;
import com.jogamp.nativewindow.ToolkitLock;
+import com.jogamp.nativewindow.awt.AWTGraphicsScreen;
import jogamp.common.os.PlatformPropsImpl;
import jogamp.nativewindow.Debug;
import jogamp.nativewindow.NWJNILibLoader;
+import jogamp.nativewindow.jawt.x11.X11SunJDKReflection;
import jogamp.nativewindow.macosx.OSXUtil;
+import jogamp.nativewindow.x11.X11Lib;
import com.jogamp.common.os.Platform;
import com.jogamp.common.util.PropertyAccess;
@@ -545,6 +550,21 @@ public class JAWTUtil {
return jawtToolkitLock;
}
+ public static final int getMonitorIndex(final GraphicsDevice device) {
+ int idx = -1;
+ if( null != getCGDisplayIDMethodOnOSX ) {
+ // OSX specific
+ try {
+ final Object res = getCGDisplayIDMethodOnOSX.invoke(device);
+ if (res instanceof Integer) {
+ final int displayID = ((Integer)res).intValue();
+ idx = OSXUtil.GetNSScreenIdx(displayID);
+ }
+ } catch (final Throwable t) {}
+ }
+ return idx;
+ }
+
/**
* Returns the pixel scale factor of the given {@link GraphicsDevice}, if supported.
* <p>
@@ -628,5 +648,73 @@ public class JAWTUtil {
}
return changed;
}
+
+ private static String getThreadName() {
+ return Thread.currentThread().getName();
+ }
+ private static String toHexString(final long val) {
+ return "0x" + Long.toHexString(val);
+ }
+
+ /**
+ * @param awtComp must be {@link java.awt.Component#isDisplayable() displayable}
+ * and must have a {@link java.awt.Component#getGraphicsConfiguration() GraphicsConfiguration}
+ * @return AbstractGraphicsDevice instance reflecting the {@code awtComp}
+ * @throws IllegalArgumentException if {@code awtComp} is not {@link java.awt.Component#isDisplayable() displayable}
+ * or has {@code null} {@link java.awt.Component#getGraphicsConfiguration() GraphicsConfiguration}.
+ * @see #getAbstractGraphicsScreen(java.awt.Component)
+ */
+ public static AbstractGraphicsDevice createDevice(final java.awt.Component awtComp) throws IllegalArgumentException {
+ if( !awtComp.isDisplayable() ) {
+ throw new IllegalArgumentException("Given AWT-Component is not displayable: "+awtComp);
+ }
+ final GraphicsDevice device;
+ final GraphicsConfiguration gc = awtComp.getGraphicsConfiguration();
+ if(null!=gc) {
+ device = gc.getDevice();
+ } else {
+ throw new IllegalArgumentException("Given AWT-Component has no GraphicsConfiguration set: "+awtComp);
+ }
+
+ final String displayConnection;
+ final String nwt = NativeWindowFactory.getNativeWindowType(true);
+ if( NativeWindowFactory.TYPE_X11 == nwt ) {
+ final long displayHandleAWT = X11SunJDKReflection.graphicsDeviceGetDisplay(device);
+ if( 0 == displayHandleAWT ) {
+ displayConnection = null; // default
+ if(DEBUG) {
+ System.err.println(getThreadName()+" - JAWTUtil.createDevice: Null AWT dpy, default X11 display");
+ }
+ } else {
+ /**
+ * Using the AWT display handle works fine with NVidia.
+ * However we experienced different results w/ AMD drivers,
+ * some work, but some behave erratic.
+ * I.e. hangs in XQueryExtension(..) via X11GraphicsScreen.
+ */
+ displayConnection = X11Lib.XDisplayString(displayHandleAWT);
+ if(DEBUG) {
+ System.err.println(getThreadName()+" - JAWTUtil.createDevice: AWT dpy "+displayConnection+" / "+toHexString(displayHandleAWT));
+ }
+ }
+ } else {
+ displayConnection = null; // default
+ }
+ return NativeWindowFactory.createDevice(displayConnection, true /* own */);
+ }
+
+ /**
+ * @param awtComp must be {@link java.awt.Component#isDisplayable() displayable}
+ * and must have a {@link java.awt.Component#getGraphicsConfiguration() GraphicsConfiguration}
+ * @return AbstractGraphicsScreen instance reflecting the {@code awtComp}
+ * @throws IllegalArgumentException if {@code awtComp} is not {@link java.awt.Component#isDisplayable() displayable}
+ * or has {@code null} {@link java.awt.Component#getGraphicsConfiguration() GraphicsConfiguration}.
+ * @see #createDevice(java.awt.Component)
+ */
+ public static AbstractGraphicsScreen getAbstractGraphicsScreen(final java.awt.Component awtComp) throws IllegalArgumentException {
+ final AbstractGraphicsDevice adevice = createDevice(awtComp);
+ return NativeWindowFactory.createScreen(adevice, AWTGraphicsScreen.findScreenIndex(awtComp.getGraphicsConfiguration().getDevice()));
+ }
+
}
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
index 6ac480120..6f3f1ed6b 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
@@ -145,7 +145,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface {
// CALayer position will be determined in native code.
// See detailed description in {@link JAWTUtil#JAWT_OSX_CALAYER_QUIRK_LAYOUT}
final Point p0 = new Point();
- final Component outterComp = getLocationOnScreenNonBlocking(p0, component);
+ final Component outterComp = AWTMisc.getLocationOnScreenNonBlocking(p0, component, DEBUG);
final java.awt.Insets outterInsets = AWTMisc.getInsets(outterComp, true);
final Point p1 = (Point)p0.cloneMutable();
p1.translate(-outterComp.getX(), -outterComp.getY());
@@ -178,7 +178,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface {
// CALayer position will be determined in native code.
// See detailed description in {@link JAWTUtil#JAWT_OSX_CALAYER_QUIRK_LAYOUT}
final Point p0 = new Point();
- final Component outterComp = getLocationOnScreenNonBlocking(p0, component);
+ final Component outterComp = AWTMisc.getLocationOnScreenNonBlocking(p0, component, DEBUG);
final java.awt.Insets outterInsets = AWTMisc.getInsets(outterComp, true);
final Point p1 = (Point)p0.cloneMutable();
p1.translate(-outterComp.getX(), -outterComp.getY());
@@ -405,7 +405,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface {
if( null == storage ) {
storage = new Point();
}
- getLocationOnScreenNonBlocking(storage, component);
+ AWTMisc.getLocationOnScreenNonBlocking(storage, component, DEBUG);
return storage;
}
@Override
diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
index 8ec7b7e95..a5970b87c 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
@@ -107,6 +107,9 @@ public class OSXUtil implements ToolkitProperties {
return (Insets) GetInsets0(windowOrView);
}
+ public static int GetNSScreenIdx(final int displayID) {
+ return GetNSScreenIdx0(displayID);
+ }
public static double GetPixelScaleByScreenIdx(final int screenIndex) {
return GetPixelScale0(screenIndex);
}
@@ -395,6 +398,7 @@ public class OSXUtil implements ToolkitProperties {
private static native boolean isNSWindow0(long object);
private static native Object GetLocationOnScreen0(long windowOrView, int src_x, int src_y);
private static native Object GetInsets0(long windowOrView);
+ private static native int GetNSScreenIdx0(int displayID);
private static native double GetPixelScale0(int screenIndex);
private static native double GetPixelScale1(int displayID);
private static native double GetPixelScale2(long windowOrView);
diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m
index 2cc272a41..87494e946 100644
--- a/src/nativewindow/native/macosx/OSXmisc.m
+++ b/src/nativewindow/native/macosx/OSXmisc.m
@@ -156,6 +156,18 @@ static NSScreen * OSXUtil_getNSScreenByCGDirectDisplayID(CGDirectDisplayID displ
}
return (NSScreen *) [screens objectAtIndex: 0];
}
+static int OSXUtil_getNSScreenIdxByCGDirectDisplayID(CGDirectDisplayID displayID) {
+ NSArray *screens = [NSScreen screens];
+ int i;
+ for(i=[screens count]-1; i>=0; i--) {
+ NSScreen * screen = (NSScreen *) [screens objectAtIndex: i];
+ CGDirectDisplayID dID = OSXUtil_getCGDirectDisplayIDByNSScreen(screen);
+ if( dID == displayID ) {
+ return i;
+ }
+ }
+ return -1;
+}
/*
* Class: Java_jogamp_nativewindow_macosx_OSXUtil
@@ -263,6 +275,22 @@ JNIEXPORT jobject JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetInsets0
/*
* Class: Java_jogamp_nativewindow_macosx_OSXUtil
+ * Method: GetNSScreenIdx0
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetNSScreenIdx0
+ (JNIEnv *env, jclass unused, jint displayID)
+{
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+
+ int idx = OSXUtil_getNSScreenIdxByCGDirectDisplayID((CGDirectDisplayID)displayID);
+ [pool release];
+
+ return idx;
+}
+
+/*
+ * Class: Java_jogamp_nativewindow_macosx_OSXUtil
* Method: GetPixelScale0
* Signature: (I)D
*/
diff --git a/src/nativewindow/native/x11/Xmisc.c b/src/nativewindow/native/x11/Xmisc.c
index a2e744cd8..efb4620ba 100644
--- a/src/nativewindow/native/x11/Xmisc.c
+++ b/src/nativewindow/native/x11/Xmisc.c
@@ -52,12 +52,12 @@
#include <dlfcn.h>
#undef __USE_GNU
+#include "Xmisc.h"
+
/* Current versions of Solaris don't expose the XF86 extensions,
although with the recent transition to Xorg this will probably
happen in an upcoming release */
-#if !defined(__sun_obsolete) && !defined(_HPUX)
-#include <X11/extensions/xf86vmode.h>
-#else
+#if defined(__sun_obsolete) || defined(_HPUX)
/* Need to provide stubs for these */
Bool XF86VidModeGetGammaRampSize(
Display *display,
diff --git a/src/nativewindow/native/x11/Xmisc.h b/src/nativewindow/native/x11/Xmisc.h
index 91f2ac5d9..d8868f802 100644
--- a/src/nativewindow/native/x11/Xmisc.h
+++ b/src/nativewindow/native/x11/Xmisc.h
@@ -39,4 +39,30 @@
#include <X11/Xlib.h>
#include <X11/Xutil.h>
+#if !defined(__sun_obsolete) && !defined(_HPUX)
+#include <X11/extensions/xf86vmode.h>
+#else
+Bool XF86VidModeGetGammaRampSize(
+ Display* /* dpy */,
+ int /* screen */,
+ int* /* size */
+);
+Bool XF86VidModeGetGammaRamp(
+ Display* /* dpy */,
+ int /* screen */,
+ int /* size */,
+ unsigned short* /* red array */,
+ unsigned short* /* green array */,
+ unsigned short* /* blue array */
+);
+Bool XF86VidModeSetGammaRamp(
+ Display* /* dpy */,
+ int /* screen */,
+ int /* size */,
+ unsigned short* /* red array */,
+ unsigned short* /* green array */,
+ unsigned short* /* blue array */
+);
+#endif /* defined(__sun_obsolete) || defined(_HPUX) */
+
#endif /* Xmisc_h */