summaryrefslogtreecommitdiffstats
path: root/src/newt/native/WindowsWindow.c
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2015-03-09 15:45:36 +0100
committerSven Gothel <[email protected]>2015-03-09 15:45:36 +0100
commit0adbc977ac7848e8092fa1d58174d0a37aabb86b (patch)
tree3917a3cd756df3fdaa4320bfc4ebc9c32bb43f71 /src/newt/native/WindowsWindow.c
parentf0f6ee411efb97d34c443c070bb640c8d8a8333f (diff)
Bug 1142 - NEWT: Add support to retrieve the primary MonitorDevice
Support added for - Windows - X11 XRandR 1.3 - OSX Note: Our whole MonitorMode association handling is currently _not_ dynamic. - only on Windows we actually use native unique ID, which might not change (adapter and monitor idx) - On OSX and X11 we simply use indices, but if monitor setup changes - they refer to different instances. In case it is desired to cover dynamic monitor setup change, we need to address this issue in a new bug entry.
Diffstat (limited to 'src/newt/native/WindowsWindow.c')
-rw-r--r--src/newt/native/WindowsWindow.c66
1 files changed, 43 insertions, 23 deletions
diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c
index 7e15cd925..8c29978f0 100644
--- a/src/newt/native/WindowsWindow.c
+++ b/src/newt/native/WindowsWindow.c
@@ -124,9 +124,28 @@
#ifndef EDS_ROTATEDMODE
#define EDS_ROTATEDMODE 0x00000004
#endif
+
+// #define DISPLAY_DEVICE_ATTACHED_TO_DESKTOP 0x00000001
+// #define DISPLAY_DEVICE_MULTI_DRIVER 0x00000002
+#ifndef DISPLAY_DEVICE_PRIMARY_DEVICE
+#define DISPLAY_DEVICE_PRIMARY_DEVICE 0x00000004
+#endif
+#ifndef DISPLAY_DEVICE_MIRRORING_DRIVER
+#define DISPLAY_DEVICE_MIRRORING_DRIVER 0x00000008
+#endif
+// #define DISPLAY_DEVICE_VGA_COMPATIBLE 0x00000010
+// #define DISPLAY_DEVICE_REMOVABLE 0x00000020
+// #define DISPLAY_DEVICE_MODESPRUNED 0x08000000
+// #define DISPLAY_DEVICE_REMOTE 0x04000000
+// #define DISPLAY_DEVICE_DISCONNECT 0x02000000
+
#ifndef DISPLAY_DEVICE_ACTIVE
#define DISPLAY_DEVICE_ACTIVE 0x00000001
#endif
+#ifndef DISPLAY_DEVICE_ATTACHED
+#define DISPLAY_DEVICE_ATTACHED 0x00000002
+#endif
+
#ifndef DM_INTERLACED
#define DM_INTERLACED 2
#endif
@@ -1704,8 +1723,10 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_dumpMonitorI
int i = 0, j;
LPCTSTR aName, dName;
while(NULL != (aName = NewtScreen_getAdapterName(&aDevice, i))) {
- STD_PRINT("*** [%02d:__]: deviceName <%s> flags 0x%X active %d\n",
- i, aDevice.DeviceName, aDevice.StateFlags, ( 0 != ( aDevice.StateFlags & DISPLAY_DEVICE_ACTIVE ) ) );
+ STD_PRINT("*** [%02d:__]: deviceName <%s>, flags 0x%X, active %d, primary %d\n",
+ i, aDevice.DeviceName, aDevice.StateFlags,
+ ( 0 != ( aDevice.StateFlags & DISPLAY_DEVICE_ACTIVE ) ),
+ ( 0 != ( aDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE ) ));
STD_PRINT(" deviceString <%s> \n", aDevice.DeviceString);
STD_PRINT(" deviceID <%s> \n", aDevice.DeviceID);
j=0;
@@ -1858,27 +1879,30 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getMoni
* Signature: (Ljava/lang/String;II)[I
*/
JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getMonitorDevice0
- (JNIEnv *env, jobject obj, jstring jAdapterName, jint adapter_idx, jint monitor_idx, jint monitor_id)
+ (JNIEnv *env, jobject obj, jint adapter_idx, jint monitor_idx, jint monitor_id)
{
- LPCTSTR adapterName;
- {
-#ifdef UNICODE
- adapterName = NewtCommon_GetNullTerminatedStringChars(env, jAdapterName);
-#else
- adapterName = (*env)->GetStringUTFChars(env, jAdapterName, NULL);
-#endif
- }
+ int gotsize = 0;
+ int widthmm, heightmm;
+ DISPLAY_DEVICE adapterDevice, monitorDevice;
+ LPCTSTR monitorName = NULL;
+ LPCTSTR adapterName = NULL;
+ adapterName = NewtScreen_getAdapterName(&adapterDevice, adapter_idx);
+ if( NULL == adapterName ) {
+ DBG_PRINT("ERROR WindowsWindow: adapter[idx %d]: NULL\n", adapter_idx);
+ return (*env)->NewIntArray(env, 0);
+ }
DBG_PRINT("*** WindowsWindow: adapter[name %s, idx %d], monitor[idx %d, id %d], EDID-avail %d\n",
adapterName, adapter_idx, monitor_idx, monitor_id, NewtEDID_avail);
- int gotsize = 0;
- int widthmm, heightmm;
- DISPLAY_DEVICE monitorDevice;
- LPCTSTR monitorName = NewtScreen_getMonitorName(adapterName, &monitorDevice, monitor_idx, TRUE);
+
+ monitorName = NewtScreen_getMonitorName(adapterName, &monitorDevice, monitor_idx, TRUE);
+ if( NULL == monitorName ) {
+ DBG_PRINT("ERROR WindowsWindow: monitor[idx %d]: NULL\n", monitor_idx);
+ return (*env)->NewIntArray(env, 0);
+ }
if( NewtEDID_avail ) {
int widthcm, heightcm;
- if( NULL != monitorName &&
- NewtEDID_GetMonitorSizeFromEDIDByDevice(&monitorDevice, &widthmm, &heightmm, &widthcm, &heightcm) ) {
+ if( NewtEDID_GetMonitorSizeFromEDIDByDevice(&monitorDevice, &widthmm, &heightmm, &widthcm, &heightcm) ) {
DBG_PRINT("*** WindowsWindow: EDID %d x %d [mm], %d x %d [cm]\n", widthmm, heightmm, widthcm, heightcm);
if( 0 <= widthmm && 0 <= heightmm ) {
gotsize = 1; // got mm values
@@ -1908,11 +1932,6 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getMoni
int res = EnumDisplaySettingsEx(adapterName, devModeID, &dm, 0);
DBG_PRINT("*** WindowsWindow: getMonitorDevice.EnumDisplaySettingsEx(%s, devModeID %d) -> %d\n", adapterName, devModeID, res);
-#ifdef UNICODE
- free((void*) adapterName);
-#else
- (*env)->ReleaseStringUTFChars(env, jAdapterName, adapterName);
-#endif
if (0 == res) {
return (*env)->NewIntArray(env, 0);
}
@@ -1923,7 +1942,8 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getMoni
prop[propIndex++] = propCount;
prop[propIndex++] = monitor_id;
- prop[propIndex++] = NULL != monitorName && 0 != ( monitorDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER );
+ prop[propIndex++] = 0 != ( monitorDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER ); // isClone
+ prop[propIndex++] = 0 != ( adapterDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE ); // isPrimary
prop[propIndex++] = widthmm;
prop[propIndex++] = heightmm;
prop[propIndex++] = dm.dmPosition.x; // rotated viewport pixel units