160 isComponent = JNI_FALSE; 161 } 162 163 JNF_COCOA_EXIT(env); 164 165 return isComponent; 166 } 167 168 /* 169 * Class: sun_lwawt_macosx_LWCToolkit 170 * Method: beep 171 * Signature: ()V 172 */ 173 JNIEXPORT void JNICALL 174 Java_sun_lwawt_macosx_LWCToolkit_beep 175 (JNIEnv *env, jobject self) 176 { 177 NSBeep(); // produces both sound and visual flash, if configured in System Preferences 178 } 179 180 CGDirectDisplayID 181 FindCGDirectDisplayIDForScreenIndex(jint screenIndex) 182 { 183 // most common case - just one monitor 184 CGDirectDisplayID screenID = CGMainDisplayID(); 185 186 CGDisplayCount displayCount = 0; 187 CGGetOnlineDisplayList(0, NULL, &displayCount); 188 189 if ((displayCount > 1) && 190 (screenIndex >= 0) && 191 (screenIndex < (jint)displayCount)) 192 { 193 if (displayCount < 10) { 194 // stack allocated optimization for less than 10 monitors 195 CGDirectDisplayID onlineDisplays[displayCount]; 196 CGGetOnlineDisplayList(displayCount, onlineDisplays, &displayCount); 197 screenID = (CGDirectDisplayID)onlineDisplays[screenIndex]; 198 } else { 199 CGDirectDisplayID *onlineDisplays = 200 malloc(displayCount*sizeof(CGDirectDisplayID)); 201 if (onlineDisplays != NULL) { 202 CGGetOnlineDisplayList(displayCount, onlineDisplays, 203 &displayCount); 204 screenID = (CGDirectDisplayID)onlineDisplays[screenIndex]; 205 free(onlineDisplays); 206 } 207 } 208 } 209 210 return screenID; 211 } 212 213 /* 214 * Class: sun_lwawt_macosx_LWCToolkit 215 * Method: initIDs 216 * Signature: ()V 217 */ 218 JNIEXPORT void JNICALL 219 Java_sun_lwawt_macosx_LWCToolkit_initIDs 220 (JNIEnv *env, jclass klass) { 221 // set thread names 222 dispatch_async(dispatch_get_main_queue(), ^(void){ 223 [[NSThread currentThread] setName:@"AppKit Thread"]; 224 225 JNIEnv *env = [ThreadUtilities getJNIEnv]; 226 static JNF_CLASS_CACHE(jc_LWCToolkit, "sun/lwawt/macosx/LWCToolkit"); 227 static JNF_STATIC_MEMBER_CACHE(jsm_installToolkitThreadNameInJava, jc_LWCToolkit, "installToolkitThreadNameInJava", "()V"); 228 JNFCallStaticVoidMethod(env, jsm_installToolkitThreadNameInJava); 229 }); 230 231 gNumberOfButtons = sun_lwawt_macosx_LWCToolkit_BUTTONS; 232 | 160 isComponent = JNI_FALSE; 161 } 162 163 JNF_COCOA_EXIT(env); 164 165 return isComponent; 166 } 167 168 /* 169 * Class: sun_lwawt_macosx_LWCToolkit 170 * Method: beep 171 * Signature: ()V 172 */ 173 JNIEXPORT void JNICALL 174 Java_sun_lwawt_macosx_LWCToolkit_beep 175 (JNIEnv *env, jobject self) 176 { 177 NSBeep(); // produces both sound and visual flash, if configured in System Preferences 178 } 179 180 /* 181 * Class: sun_lwawt_macosx_LWCToolkit 182 * Method: initIDs 183 * Signature: ()V 184 */ 185 JNIEXPORT void JNICALL 186 Java_sun_lwawt_macosx_LWCToolkit_initIDs 187 (JNIEnv *env, jclass klass) { 188 // set thread names 189 dispatch_async(dispatch_get_main_queue(), ^(void){ 190 [[NSThread currentThread] setName:@"AppKit Thread"]; 191 192 JNIEnv *env = [ThreadUtilities getJNIEnv]; 193 static JNF_CLASS_CACHE(jc_LWCToolkit, "sun/lwawt/macosx/LWCToolkit"); 194 static JNF_STATIC_MEMBER_CACHE(jsm_installToolkitThreadNameInJava, jc_LWCToolkit, "installToolkitThreadNameInJava", "()V"); 195 JNFCallStaticVoidMethod(env, jsm_installToolkitThreadNameInJava); 196 }); 197 198 gNumberOfButtons = sun_lwawt_macosx_LWCToolkit_BUTTONS; 199 |