107 JNIEXPORT jint JNICALL 108 Java_sun_awt_CGraphicsEnvironment_getMainDisplayID 109 (JNIEnv *env, jclass class) 110 { 111 return CGMainDisplayID(); 112 } 113 114 /* 115 * Post the display reconfiguration event. 116 */ 117 static void displaycb_handle 118 (CGDirectDisplayID display, CGDisplayChangeSummaryFlags flags, void *userInfo) 119 { 120 if (flags == kCGDisplayBeginConfigurationFlag) return; 121 122 JNFPerformEnvBlock(JNFThreadDetachImmediately, ^(JNIEnv *env) { 123 JNFWeakJObjectWrapper *wrapper = (JNFWeakJObjectWrapper *)userInfo; 124 125 jobject graphicsEnv = [wrapper jObjectWithEnv:env]; 126 if (graphicsEnv == NULL) return; // ref already GC'd 127 128 static JNF_CLASS_CACHE(jc_CGraphicsEnvironment, "sun/awt/CGraphicsEnvironment"); 129 static JNF_MEMBER_CACHE(jm_displayReconfiguration, jc_CGraphicsEnvironment, "_displayReconfiguration", "(J)V"); 130 JNFCallVoidMethod(env, graphicsEnv, jm_displayReconfiguration); 131 }); 132 } 133 134 /* 135 * Class: sun_awt_CGraphicsEnvironment 136 * Method: registerDisplayReconfiguration 137 * Signature: ()J 138 */ 139 JNIEXPORT jlong JNICALL 140 Java_sun_awt_CGraphicsEnvironment_registerDisplayReconfiguration 141 (JNIEnv *env, jobject this) 142 { 143 jlong ret = 0L; 144 145 JNF_COCOA_ENTER(env); 146 147 JNFWeakJObjectWrapper *wrapper = [JNFWeakJObjectWrapper wrapperWithJObject:this withEnv:env]; 148 CFRetain(wrapper); // pin from ObjC-GC 149 150 /* Register the callback */ | 107 JNIEXPORT jint JNICALL 108 Java_sun_awt_CGraphicsEnvironment_getMainDisplayID 109 (JNIEnv *env, jclass class) 110 { 111 return CGMainDisplayID(); 112 } 113 114 /* 115 * Post the display reconfiguration event. 116 */ 117 static void displaycb_handle 118 (CGDirectDisplayID display, CGDisplayChangeSummaryFlags flags, void *userInfo) 119 { 120 if (flags == kCGDisplayBeginConfigurationFlag) return; 121 122 JNFPerformEnvBlock(JNFThreadDetachImmediately, ^(JNIEnv *env) { 123 JNFWeakJObjectWrapper *wrapper = (JNFWeakJObjectWrapper *)userInfo; 124 125 jobject graphicsEnv = [wrapper jObjectWithEnv:env]; 126 if (graphicsEnv == NULL) return; // ref already GC'd 127 static JNF_CLASS_CACHE(jc_CGraphicsEnvironment, "sun/awt/CGraphicsEnvironment"); 128 static JNF_MEMBER_CACHE(jm_displayReconfiguration, jc_CGraphicsEnvironment, "_displayReconfiguration", "(IZ)V"); 129 JNFCallVoidMethod(env, graphicsEnv, jm_displayReconfiguration, 130 (jint) display, 131 (jboolean) flags & kCGDisplayRemoveFlag); 132 }); 133 } 134 135 /* 136 * Class: sun_awt_CGraphicsEnvironment 137 * Method: registerDisplayReconfiguration 138 * Signature: ()J 139 */ 140 JNIEXPORT jlong JNICALL 141 Java_sun_awt_CGraphicsEnvironment_registerDisplayReconfiguration 142 (JNIEnv *env, jobject this) 143 { 144 jlong ret = 0L; 145 146 JNF_COCOA_ENTER(env); 147 148 JNFWeakJObjectWrapper *wrapper = [JNFWeakJObjectWrapper wrapperWithJObject:this withEnv:env]; 149 CFRetain(wrapper); // pin from ObjC-GC 150 151 /* Register the callback */ |