diff options
author | Sven Gothel <[email protected]> | 2015-02-17 07:30:34 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2015-02-17 07:30:34 +0100 |
commit | 37ec129f36097f41ed0d45cbccd7a93e493e2bb9 (patch) | |
tree | cb3f418d8b405c4ecb5825386cc04cf7687b5a98 /src/nativewindow/native/macosx | |
parent | a28e1610e1c29279847bce80e1aa80a947ff799e (diff) |
Bug 1130 - Add Mapping from AWT Component -> NEWT [Screen, MonitorDevice]
The mapping AWT Component -> NEWT [Screen, MonitorDevice]
shall allow generic AWT applications to utilize NEWT's MonitorDevice
information like physical monitor-size and DPI.
- AWT-Component -> NEWT-Display:
- NewtFactoryAWT.createDisplay
- AWT-Component -> NEWT-Screen:
- NewtFactoryAWT.createScreen
- AWT-Component -> NEWT-MonitorMode:
- NewtFactoryAWT.getMonitorDevice
- NewtFactoryAWT.getMonitorDevice
- If OSX, utilizing OSX's AWT Component -> MonitorDevice-Index mapping
- Otherwise using the coverage to identify MonitorDevice
See TestGearsES2GLJPanelAWT 'GetPixelScale',
demonstrating the mapping while pressing 'p' (cached MonitorMode)
and pressing SHIFT-'p' (non-cached MonitorMode).
Diffstat (limited to 'src/nativewindow/native/macosx')
-rw-r--r-- | src/nativewindow/native/macosx/OSXmisc.m | 28 |
1 files changed, 28 insertions, 0 deletions
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 */ |