summaryrefslogtreecommitdiffstats
path: root/src/newt
diff options
context:
space:
mode:
Diffstat (limited to 'src/newt')
-rw-r--r--src/newt/classes/jogamp/newt/awt/NewtFactoryAWT.java2
-rw-r--r--src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java57
-rw-r--r--src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java19
-rw-r--r--src/newt/native/MacWindow.m124
-rw-r--r--src/newt/native/NewtMacWindow.h2
5 files changed, 133 insertions, 71 deletions
diff --git a/src/newt/classes/jogamp/newt/awt/NewtFactoryAWT.java b/src/newt/classes/jogamp/newt/awt/NewtFactoryAWT.java
index 4faa5de9c..8eaca7c0e 100644
--- a/src/newt/classes/jogamp/newt/awt/NewtFactoryAWT.java
+++ b/src/newt/classes/jogamp/newt/awt/NewtFactoryAWT.java
@@ -180,7 +180,7 @@ public class NewtFactoryAWT extends NewtFactory {
screen.addReference();
try {
if( NativeWindowFactory.TYPE_MACOSX == nwt ) {
- res = screen.getMonitor( JAWTUtil.getMonitorIndex( awtComp.getGraphicsConfiguration().getDevice() ) );
+ res = screen.getMonitor( JAWTUtil.getMonitorDisplayID( awtComp.getGraphicsConfiguration().getDevice() ) );
}
if( null == res ) {
// Fallback, use AWT component coverage
diff --git a/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java
index f493bdc95..1389692fc 100644
--- a/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java
@@ -42,6 +42,7 @@ import jogamp.newt.MonitorModeProps;
import jogamp.newt.ScreenImpl;
import com.jogamp.common.util.ArrayHashSet;
+import com.jogamp.newt.Display;
import com.jogamp.newt.MonitorDevice;
import com.jogamp.newt.MonitorMode;
import com.jogamp.opengl.math.FloatUtil;
@@ -63,8 +64,8 @@ public class ScreenDriver extends ScreenImpl {
@Override
protected void closeNativeImpl() { }
- private MonitorMode getMonitorModeImpl(final MonitorModeProps.Cache cache, final int crt_idx, final int mode_idx) {
- final int[] modeProps = getMonitorMode0(crt_idx, mode_idx);
+ private MonitorMode getMonitorModeImpl(final MonitorModeProps.Cache cache, final int crt_id, final int mode_idx) {
+ final int[] modeProps = getMonitorMode0(crt_id, mode_idx);
final MonitorMode res;
if (null == modeProps || 0 >= modeProps.length) {
res = null;
@@ -74,9 +75,10 @@ public class ScreenDriver extends ScreenImpl {
return res;
}
- private class CrtProps {
+ class CrtProps {
CrtProps() {
- count = getMonitorCount0();
+ crtIDs = getMonitorDeviceIds0();
+ count = crtIDs.length;
pixelScaleArray = new float[count];
propsOrigArray = new int[count][];
propsFixedArray = new int[count][];
@@ -85,11 +87,12 @@ public class ScreenDriver extends ScreenImpl {
// Gather whole topology of monitors (NSScreens)
//
for(int crtIdx=0; crtIdx<count; crtIdx++) {
- final float pixelScaleRaw = (float)OSXUtil.GetPixelScaleByScreenIdx(crtIdx);
+ final int crt_id = crtIDs[crtIdx];
+ final float pixelScaleRaw = (float)OSXUtil.GetPixelScaleByDisplayID(crt_id);
pixelScaleArray[crtIdx] = FloatUtil.isZero(pixelScaleRaw, FloatUtil.EPSILON) ? 1.0f : pixelScaleRaw;
- propsOrigArray[crtIdx] = getMonitorProps0(crtIdx);
+ propsOrigArray[crtIdx] = getMonitorProps0(crt_id);
if ( null == propsOrigArray[crtIdx] ) {
- throw new InternalError("Could not gather device props "+crtIdx+"/"+count);
+ throw new InternalError("Could not gather device props "+crtIdx+"/"+count+" -> "+Display.toHexString(crt_id));
}
// copy orig -> fixed
final int propsLen = propsOrigArray[crtIdx].length;
@@ -128,7 +131,16 @@ public class ScreenDriver extends ScreenImpl {
}
}
}
+ int getIndex(final int crt_id) {
+ for(int i=0; i<count; i++) {
+ if( crt_id == crtIDs[i] ) {
+ return i;
+ }
+ }
+ return -1;
+ }
final int count;
+ final int[] crtIDs;
final float[] pixelScaleArray;
final int[][] propsOrigArray;
final int[][] propsFixedArray;
@@ -142,13 +154,14 @@ public class ScreenDriver extends ScreenImpl {
// Collect all monitorModes for all monitorDevices
//
for(int crtIdx=0; crtIdx<crtProps.count; crtIdx++) {
+ final int crt_id = crtProps.crtIDs[crtIdx];
final ArrayHashSet<MonitorMode> supportedModes = new ArrayHashSet<MonitorMode>();
int modeIdx = 0;
{
// Get all supported modes for this monitorDevice
MonitorMode mode;
while( true ) {
- mode = getMonitorModeImpl(cache, crtIdx, modeIdx);
+ mode = getMonitorModeImpl(cache, crt_id, modeIdx);
if( null != mode ) {
if( mode.getSurfaceSize().getBitsPerPixel() >= 24 ) { // drop otherwise
supportedModes.getOrAdd(mode);
@@ -160,11 +173,11 @@ public class ScreenDriver extends ScreenImpl {
}
}
if( 0 >= modeIdx ) {
- throw new InternalError("Could not gather single mode of device "+crtIdx+"/"+crtProps.count);
+ throw new InternalError("Could not gather single mode of device "+crtIdx+"/"+crtProps.count+" -> "+Display.toHexString(crt_id));
}
- final MonitorMode currentMode = getMonitorModeImpl(cache, crtIdx, -1);
+ final MonitorMode currentMode = getMonitorModeImpl(cache, crt_id, -1);
if ( null == currentMode ) {
- throw new InternalError("Could not gather current mode of device "+crtIdx+"/"+crtProps.count+", but gathered "+modeIdx+" modes");
+ throw new InternalError("Could not gather current mode of device "+crtIdx+"/"+crtProps.count+" -> "+Display.toHexString(crt_id)+", but gathered "+modeIdx+" modes");
}
// merge monitor-props + supported modes
final float pixelScale = crtProps.pixelScaleArray[crtIdx];
@@ -177,15 +190,19 @@ public class ScreenDriver extends ScreenImpl {
@Override
protected boolean updateNativeMonitorDeviceViewportImpl(final MonitorDevice monitor, final float[] pixelScale, final Rectangle viewportPU, final Rectangle viewportWU) {
final CrtProps crtProps = new CrtProps();
- final int crtIdx = monitor.getId();
- if( 0 > crtIdx || crtIdx >= crtProps.count ) {
- throw new IndexOutOfBoundsException("monitor id "+crtIdx+" not withon [0.."+(crtProps.count-1)+"]");
+ final int crt_id = monitor.getId();
+ if( 0 == crt_id ) {
+ throw new IllegalArgumentException("Invalid monitor id "+Display.toHexString(crt_id));
+ }
+ final int crt_idx = crtProps.getIndex(crt_id);
+ if( 0 > crt_idx || crt_idx >= crtProps.count ) {
+ throw new IndexOutOfBoundsException("monitor id "+crt_idx+" not within [0.."+(crtProps.count-1)+"]");
}
- final int[] fixedMonitorProps = crtProps.propsFixedArray[crtIdx];
+ final int[] fixedMonitorProps = crtProps.propsFixedArray[crt_idx];
int offset = MonitorModeProps.IDX_MONITOR_DEVICE_VIEWPORT;
viewportPU.set(fixedMonitorProps[offset++], fixedMonitorProps[offset++], fixedMonitorProps[offset++], fixedMonitorProps[offset++]);
viewportWU.set(fixedMonitorProps[offset++], fixedMonitorProps[offset++], fixedMonitorProps[offset++], fixedMonitorProps[offset++]);
- final float _pixelScale = crtProps.pixelScaleArray[crtIdx];
+ final float _pixelScale = crtProps.pixelScaleArray[crt_idx];
pixelScale[0] = _pixelScale;
pixelScale[1] = _pixelScale;
return true;
@@ -206,8 +223,8 @@ public class ScreenDriver extends ScreenImpl {
return 0; // big-desktop w/ multiple monitor attached, only one screen available
}
- private native int getMonitorCount0();
- private native int[] getMonitorProps0(int crt_idx);
- private native int[] getMonitorMode0(int crt_index, int mode_idx);
- private native boolean setMonitorMode0(int crt_index, int nativeId, int rot);
+ private native int[] getMonitorDeviceIds0();
+ private native int[] getMonitorProps0(int crt_id);
+ private native int[] getMonitorMode0(int crt_id, int mode_idx);
+ private native boolean setMonitorMode0(int crt_id, int nativeId, int rot);
}
diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
index 7f3a53626..d241545d5 100644
--- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
@@ -96,8 +96,8 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
}
}
- private boolean updatePixelScaleByScreenIdx(final boolean sendEvent) {
- final float maxPixelScaleRaw = (float) OSXUtil.GetPixelScaleByScreenIdx(getScreen().getIndex());
+ private boolean updatePixelScaleByDisplayID(final boolean sendEvent) {
+ final float maxPixelScaleRaw = (float) OSXUtil.GetPixelScaleByDisplayID(getDisplayID());
if( DEBUG_IMPLEMENTATION ) {
System.err.println("WindowDriver.updatePixelScale.1: "+hasPixelScale[0]+", "+maxPixelScaleRaw+" (max)");
}
@@ -130,13 +130,13 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
@Override
protected final void instantiationFinished() {
- updatePixelScaleByScreenIdx(false /* sendEvent*/);
+ updatePixelScaleByDisplayID(false /* sendEvent*/);
}
@Override
protected void setScreen(final ScreenImpl newScreen) { // never null !
super.setScreen(newScreen);
- updatePixelScaleByScreenIdx(false /* sendEvent*/); // caller (reparent, ..) will send reshape event
+ updatePixelScaleByDisplayID(false /* sendEvent*/); // caller (reparent, ..) will send reshape event
}
@Override
@@ -640,6 +640,16 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
super.enqueueKeyEvent(wait, eventType, modifiers, keyCode, keySym, keyChar);
}
+ protected int getDisplayID() {
+ if( !isOffscreenInstance ) {
+ final long whandle = getWindowHandle();
+ if(0 != whandle) {
+ return getDisplayID0(whandle);
+ }
+ }
+ return 0;
+ }
+
//----------------------------------------------------------------------
// Internals only
//
@@ -716,6 +726,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
/** Must be called on Main-Thread */
private native void initWindow0(long parentWindow, long window, int x, int y, int w, int h, float reqPixelScale,
boolean opaque, boolean visible, long view);
+ private native int getDisplayID0(long window);
private native void setPixelScale0(long window, long view, float reqPixelScale);
private native boolean lockSurface0(long window, long view);
private native boolean unlockSurface0(long window, long view);
diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m
index fbac6b37e..5593cd682 100644
--- a/src/newt/native/MacWindow.m
+++ b/src/newt/native/MacWindow.m
@@ -366,19 +366,15 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_DisplayDriver_destroyPoint
[pool release];
}
-NSScreen * NewtScreen_getNSScreenByIndex(int screen_idx, BOOL cap) {
+#if 0
+static NSScreen * NewtScreen_getNSScreenByIndex(int screen_idx) {
NSArray *screens = [NSScreen screens];
if( screen_idx<0 || screen_idx>=[screens count] ) {
- if( cap ) {
- screen_idx=0;
- } else {
- return NULL;
- }
+ return NULL;
}
return (NSScreen *) [screens objectAtIndex: screen_idx];
}
-
-NSScreen * NewtScreen_getNSScreenByCoord(int x, int y) {
+static NSScreen * NewtScreen_getNSScreenByCoord(int x, int y) {
NSArray *screens = [NSScreen screens];
int i;
for(i=[screens count]-1; i>=0; i--) {
@@ -391,9 +387,9 @@ NSScreen * NewtScreen_getNSScreenByCoord(int x, int y) {
return screen;
}
}
- return (NSScreen *) [screens objectAtIndex: 0];
+ return NULL;
}
-
+#endif
static void NewtScreen_dump() {
#ifdef VERBOSE_ON
NSArray *screens = [NSScreen screens];
@@ -420,12 +416,27 @@ NS_ENDHANDLER
CGDirectDisplayID NewtScreen_getCGDirectDisplayIDByNSScreen(NSScreen *screen) {
+ if( NULL == screen ) {
+ return (CGDirectDisplayID)0;
+ }
// Mind: typedef uint32_t CGDirectDisplayID;
NSDictionary * dict = [screen deviceDescription];
NSNumber * val = (NSNumber *) [dict objectForKey: @"NSScreenNumber"];
// [NSNumber integerValue] returns NSInteger which is 32 or 64 bit native size
return (CGDirectDisplayID) [val integerValue];
}
+static NSScreen * NewtScreen_getNSScreenByCGDirectDisplayID(CGDirectDisplayID displayID) {
+ NSArray *screens = [NSScreen screens];
+ int i;
+ for(i=[screens count]-1; i>=0; i--) {
+ NSScreen * screen = (NSScreen *) [screens objectAtIndex: i];
+ CGDirectDisplayID dID = NewtScreen_getCGDirectDisplayIDByNSScreen(screen);
+ if( dID == displayID ) {
+ return screen;
+ }
+ }
+ return NULL;
+}
/**
* Only in >= 10.6:
@@ -453,16 +464,28 @@ static long GetDictionaryLong(CFDictionaryRef theDict, const void* key)
/*
* Class: jogamp_newt_driver_macosx_ScreenDriver
- * Method: getMonitorCount0
+ * Method: getMonitorDeviceIds0
* Signature: ()I
*/
-JNIEXPORT jint JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getMonitorCount0
+JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getMonitorDeviceIds0
(JNIEnv *env, jobject obj)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSArray *screens = [NSScreen screens];
+ int count = [screens count];
+ int32_t displayIDs[count];
+ int i;
+ for(i=0; i<count; i++) {
+ NSScreen * screen = (NSScreen *) [screens objectAtIndex: i];
+ displayIDs[i] = (int32_t)NewtScreen_getCGDirectDisplayIDByNSScreen(screen);
+ }
+ jintArray properties = (*env)->NewIntArray(env, count);
+ if (properties == NULL) {
+ NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", count);
+ }
+ (*env)->SetIntArrayRegion(env, properties, 0, count, displayIDs);
[pool release];
- return (jint) [screens count];
+ return properties;
}
/*
@@ -471,7 +494,7 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getMonitorCou
* Signature: (I)[I
*/
JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getMonitorProps0
- (JNIEnv *env, jobject obj, jint crt_idx)
+ (JNIEnv *env, jobject obj, jint crt_id)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
@@ -485,28 +508,31 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getMonit
timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td);
fprintf(stderr, "MacScreen_getMonitorProps0.1: %ld ms\n", td_ms); fflush(NULL);
#endif
- NSScreen *screen = NewtScreen_getNSScreenByIndex((int)crt_idx, false);
+ CGDirectDisplayID displayID = (CGDirectDisplayID)crt_id;
+ NSScreen *screen = NewtScreen_getNSScreenByCGDirectDisplayID(displayID);
if( NULL == screen ) {
[pool release];
return NULL;
}
- CGDirectDisplayID display = NewtScreen_getCGDirectDisplayIDByNSScreen(screen);
+ CGDirectDisplayID mainDisplayID = CGMainDisplayID();
+ BOOL isPrimary = mainDisplayID == displayID;
#ifdef DBG_PERF
timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td);
fprintf(stderr, "MacScreen_getMonitorProps0.2: %ld ms\n", td_ms); fflush(NULL);
#endif
- CGSize sizeMM = CGDisplayScreenSize(display);
+ CGSize sizeMM = CGDisplayScreenSize(displayID);
#ifdef DBG_PERF
timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td);
fprintf(stderr, "MacScreen_getMonitorProps0.3: %ld ms\n", td_ms); fflush(NULL);
#endif
- CGRect dBounds = CGDisplayBounds (display); // origin top-left
+ CGRect dBounds = CGDisplayBounds (displayID); // origin top-left
#ifdef VERBOSE_ON
- BOOL usesGL = CGDisplayUsesOpenGLAcceleration(display);
+ BOOL usesGL = CGDisplayUsesOpenGLAcceleration(displayID);
NSRect sFrame = [screen frame]; // origin bottom-left
- DBG_PRINT( "getMonitorProps0: scrn %d, top-left displayBounds[%d/%d %dx%d], bottom-left screenFrame[%d/%d %dx%d], usesGL %d\n", (int)crt_idx,
+ DBG_PRINT( "getMonitorProps0: crt_id 0x%X (prim %d), top-left displayBounds[%d/%d %dx%d], bottom-left screenFrame[%d/%d %dx%d], usesGL %d\n",
+ (int)crt_id, isPrimary,
(int)dBounds.origin.x, (int)dBounds.origin.y, (int)dBounds.size.width, (int)dBounds.size.height,
(int)sFrame.origin.x, (int)sFrame.origin.y, (int)sFrame.size.width, (int)sFrame.size.height,
(int)usesGL);
@@ -516,9 +542,9 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getMonit
jint prop[ propCount ];
int offset = 0;
prop[offset++] = propCount;
- prop[offset++] = crt_idx;
+ prop[offset++] = crt_id;
prop[offset++] = 0; // isClone
- prop[offset++] = 0 == crt_idx ? 1 : 0; // isPrimary
+ prop[offset++] = isPrimary ? 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)
@@ -547,11 +573,12 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getMonit
* Signature: (II)[I
*/
JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getMonitorMode0
- (JNIEnv *env, jobject obj, jint crt_idx, jint mode_idx)
+ (JNIEnv *env, jobject obj, jint crt_id, jint mode_idx)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
- NSScreen *screen = NewtScreen_getNSScreenByIndex((int)crt_idx, false);
+ CGDirectDisplayID displayID = (CGDirectDisplayID)crt_id;
+ NSScreen *screen = NewtScreen_getNSScreenByCGDirectDisplayID(displayID);
if( NULL == screen ) {
[pool release];
return NULL;
@@ -563,21 +590,19 @@ NS_DURING
NS_HANDLER
NS_ENDHANDLER
- CGDirectDisplayID display = NewtScreen_getCGDirectDisplayIDByNSScreen(screen);
-
- CFArrayRef availableModes = CGDisplayAvailableModes(display);
+ CFArrayRef availableModes = CGDisplayAvailableModes(displayID);
CFIndex numberOfAvailableModes = CFArrayGetCount(availableModes);
CFIndex numberOfAvailableModesRots = ROTMODES_PER_REALMODE * numberOfAvailableModes;
CFDictionaryRef mode = NULL;
- int currentCCWRot = (int)CGDisplayRotation(display);
+ int currentCCWRot = (int)CGDisplayRotation(displayID);
jint ccwRot = 0;
int nativeId = 0;
#ifdef VERBOSE_ON
if(0 >= mode_idx) {
// only for current mode (-1) and first mode (scanning)
- DBG_PRINT( "getScreenMode0: scrn %d (s %p, d %p, pscale %lf), mode %d, avail: %d/%d, current rot %d ccw\n",
- (int)crt_idx, screen, (void*)(intptr_t)display, pixelScale, (int)mode_idx, (int)numberOfAvailableModes, (int)numberOfAvailableModesRots, currentCCWRot);
+ DBG_PRINT( "getScreenMode0: crtID 0x%X (s %p, pscale %lf), mode %d, avail: %d/%d, current rot %d ccw\n",
+ (uint32_t)displayID, screen, pixelScale, (int)mode_idx, (int)numberOfAvailableModes, (int)numberOfAvailableModesRots, currentCCWRot);
}
#endif
@@ -594,7 +619,7 @@ NS_ENDHANDLER
mode = (CFDictionaryRef)CFArrayGetValueAtIndex(availableModes, nativeId);
} else {
// current mode
- mode = CGDisplayCurrentMode(display);
+ mode = CGDisplayCurrentMode(displayID);
ccwRot = currentCCWRot;
CFRange range = CFRangeMake (0, numberOfAvailableModes);
nativeId = CFArrayGetFirstIndexOfValue(availableModes, range, (CFDictionaryRef)mode);
@@ -652,26 +677,25 @@ NS_ENDHANDLER
* Signature: (III)Z
*/
JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_setMonitorMode0
- (JNIEnv *env, jobject object, jint crt_idx, jint nativeId, jint ccwRot)
+ (JNIEnv *env, jobject object, jint crt_id, jint nativeId, jint ccwRot)
{
jboolean res = JNI_TRUE;
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
- NSScreen *screen = NewtScreen_getNSScreenByIndex((int)crt_idx, false);
+ CGDirectDisplayID displayID = (CGDirectDisplayID)crt_id;
+ NSScreen *screen = NewtScreen_getNSScreenByCGDirectDisplayID(displayID);
if( NULL == screen ) {
[pool release];
return JNI_FALSE;
}
- CGDirectDisplayID display = NewtScreen_getCGDirectDisplayIDByNSScreen(screen);
-
- CFArrayRef availableModes = CGDisplayAvailableModes(display);
+ CFArrayRef availableModes = CGDisplayAvailableModes(displayID);
CFIndex numberOfAvailableModes = CFArrayGetCount(availableModes);
#ifdef VERBOSE_ON
CFIndex numberOfAvailableModesRots = ROTMODES_PER_REALMODE * numberOfAvailableModes;
#endif
- DBG_PRINT( "setScreenMode0: scrn %d (%p, %p), nativeID %d, rot %d ccw, avail: %d/%d\n",
- (int)crt_idx, screen, (void*)(intptr_t)display, (int)nativeId, ccwRot, (int)numberOfAvailableModes, (int)numberOfAvailableModesRots);
+ DBG_PRINT( "setScreenMode0: crtID 0x%X (%p), nativeID %d, rot %d ccw, avail: %d/%d\n",
+ (uint32_t)displayID, screen, (int)nativeId, ccwRot, (int)numberOfAvailableModes, (int)numberOfAvailableModesRots);
CFDictionaryRef mode = NULL;
@@ -689,7 +713,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_setMonito
}
if( NULL != mode ) {
- CGError err = CGDisplaySwitchToMode(display, mode);
+ CGError err = CGDisplaySwitchToMode(displayID, mode);
if(kCGErrorSuccess != err) {
DBG_PRINT( "setScreenMode0: SetMode failed: %d\n", (int)err);
res = JNI_FALSE;
@@ -807,6 +831,15 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createWindow
return (jlong) ((intptr_t) myWindow);
}
+JNIEXPORT jint JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_getDisplayID0(JNIEnv *env, jobject jthis, jlong window) {
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ NewtMacWindow* myWindow = (NewtMacWindow*) ((intptr_t) window);
+ NSScreen *screen = [myWindow screen];
+ int32_t displayID = (int32_t)NewtScreen_getCGDirectDisplayIDByNSScreen(screen);
+ [pool release];
+ return (jint) displayID;
+}
+
/**
* Method is called on Main-Thread, hence no special invocation required inside method.
*
@@ -968,10 +1001,13 @@ NS_DURING
* <https://developer.apple.com/library/mac/documentation/graphicsimaging/Conceptual/QuartzDisplayServicesConceptual/Articles/DisplayCapture.html>
*
NSScreen *myScreen = NewtScreen_getNSScreenByCoord(x, y);
- if ( [myView respondsToSelector:@selector(enterFullScreenMode:withOptions:)] ) {
- // Available >= 10.5 - Makes the menubar disapear
- [myView enterFullScreenMode: myScreen withOptions:NULL];
- } */
+ if( NULL != myScreen ) {
+ if ( [myView respondsToSelector:@selector(enterFullScreenMode:withOptions:)] ) {
+ // Available >= 10.5 - Makes the menubar disapear
+ [myView enterFullScreenMode: myScreen withOptions:NULL];
+ }
+ }
+ */
if( myWindow->hasPresentationSwitch ) {
DBG_PRINT( "initWindow0.%d - %p view %p, setPresentationOptions 0x%X\n",
dbgIdx++, myWindow, myView, (int)myWindow->fullscreenPresentationOptions);
@@ -1005,9 +1041,9 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setPixelScale
#ifdef VERBOSE_ON
int dbgIdx = 1;
#endif
-
DBG_PRINT( "setPixelScale0 - %p (this), %p (window), view %p, reqPixScale %f (START)\n",
(void*)(intptr_t)jthis, myWindow, myView, (float)reqPixelScale);
+ (void)myWindow;
NS_DURING
// HiDPI scaling: Setup - Available >= 10.7
diff --git a/src/newt/native/NewtMacWindow.h b/src/newt/native/NewtMacWindow.h
index 0f80df2d7..7dc5c6e19 100644
--- a/src/newt/native/NewtMacWindow.h
+++ b/src/newt/native/NewtMacWindow.h
@@ -49,8 +49,6 @@
// #define DBG_LIFECYCLE 1
-NSScreen * NewtScreen_getNSScreenByIndex(int screen_idx, BOOL cap);
-NSScreen * NewtScreen_getNSScreenByCoord(int x, int y);
CGDirectDisplayID NewtScreen_getCGDirectDisplayIDByNSScreen(NSScreen *screen);
@interface NewtView : NSView