src/macosx/native/sun/awt/CGraphicsEnv.m

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 23,32 **** --- 23,33 ---- * questions. */ #import <JavaNativeFoundation/JavaNativeFoundation.h> + #import "jni_util.h" #import "LWCToolkit.h" #import "AWT_debug.h" /*
*** 62,97 **** JNF_COCOA_ENTER(env); /* Get the count */ CGDisplayCount displayCount; ! if (CGGetActiveDisplayList(MAX_DISPLAYS, NULL, &displayCount) != kCGErrorSuccess) { [JNFException raise:env as:kInternalError reason:"CGGetOnlineDisplayList() failed to get display count"]; return NULL; } /* Allocate an array and get the size list of display Ids */ CGDirectDisplayID displays[MAX_DISPLAYS]; ! if (CGGetActiveDisplayList(displayCount, displays, &displayCount) != kCGErrorSuccess) { [JNFException raise:env as:kInternalError reason:"CGGetOnlineDisplayList() failed to get display list"]; return NULL; } /* Allocate a java array for display identifiers */ ! ret = JNFNewIntArray(env, displayCount); /* Initialize and return the backing int array */ assert(sizeof(jint) >= sizeof(CGDirectDisplayID)); jint *elems = (*env)->GetIntArrayElements(env, ret, 0); ! CGDisplayCount i; ! for (i = 0; i < displayCount; i++) { ! elems[i] = displays[i]; } (*env)->ReleaseIntArrayElements(env, ret, elems, 0); JNF_COCOA_EXIT(env); --- 63,111 ---- JNF_COCOA_ENTER(env); /* Get the count */ CGDisplayCount displayCount; ! if (CGGetOnlineDisplayList(MAX_DISPLAYS, NULL, &displayCount) != kCGErrorSuccess) { [JNFException raise:env as:kInternalError reason:"CGGetOnlineDisplayList() failed to get display count"]; return NULL; } /* Allocate an array and get the size list of display Ids */ CGDirectDisplayID displays[MAX_DISPLAYS]; ! if (CGGetOnlineDisplayList(displayCount, displays, &displayCount) != kCGErrorSuccess) { [JNFException raise:env as:kInternalError reason:"CGGetOnlineDisplayList() failed to get display list"]; return NULL; } + CGDisplayCount i; + CGDisplayCount displayActiveCount = 0; //Active and sleeping. + for (i = 0; i < displayCount; ++i) { + if (CGDisplayMirrorsDisplay(displays[i]) == kCGNullDirectDisplay) { + ++displayActiveCount; + } else { + displays[i] = kCGNullDirectDisplay; + } + } + /* Allocate a java array for display identifiers */ ! ret = JNFNewIntArray(env, displayActiveCount); /* Initialize and return the backing int array */ assert(sizeof(jint) >= sizeof(CGDirectDisplayID)); jint *elems = (*env)->GetIntArrayElements(env, ret, 0); + CHECK_NULL_RETURN(elems, NULL); ! /* Filter out the mirrored displays */ ! for (i = 0; i < displayCount; ++i) { ! if (displays[i] != kCGNullDirectDisplay) { ! elems[--displayActiveCount] = displays[i]; ! } } (*env)->ReleaseIntArrayElements(env, ret, elems, 0); JNF_COCOA_EXIT(env);