jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsEnv.m
changeset 33513 1804980c8ed7
parent 32872 abca6234313d
child 38987 ffe8b158dd6a
equal deleted inserted replaced
33512:4a358314de0c 33513:1804980c8ed7
    24  */
    24  */
    25 
    25 
    26 #import "AWT_debug.h"
    26 #import "AWT_debug.h"
    27 
    27 
    28 #import "jni_util.h"
    28 #import "jni_util.h"
       
    29 #import "ThreadUtilities.h"
    29 
    30 
    30 #import <JavaNativeFoundation/JavaNativeFoundation.h>
    31 #import <JavaNativeFoundation/JavaNativeFoundation.h>
    31 
    32 
    32 #define MAX_DISPLAYS 64
    33 #define MAX_DISPLAYS 64
    33 
    34 
   112 static void displaycb_handle
   113 static void displaycb_handle
   113 (CGDirectDisplayID display, CGDisplayChangeSummaryFlags flags, void *userInfo)
   114 (CGDirectDisplayID display, CGDisplayChangeSummaryFlags flags, void *userInfo)
   114 {
   115 {
   115     if (flags == kCGDisplayBeginConfigurationFlag) return;
   116     if (flags == kCGDisplayBeginConfigurationFlag) return;
   116 
   117 
   117     JNFPerformEnvBlock(JNFThreadDetachImmediately, ^(JNIEnv *env) {
   118     [ThreadUtilities performOnMainThreadWaiting:NO block:^() {
   118         JNFWeakJObjectWrapper *wrapper = (JNFWeakJObjectWrapper *)userInfo;
       
   119 
   119 
   120         jobject graphicsEnv = [wrapper jObjectWithEnv:env];
   120         JNFPerformEnvBlock(JNFThreadDetachImmediately, ^(JNIEnv *env) {
   121         if (graphicsEnv == NULL) return; // ref already GC'd
   121             JNFWeakJObjectWrapper *wrapper = (JNFWeakJObjectWrapper *)userInfo;
   122         static JNF_CLASS_CACHE(jc_CGraphicsEnvironment, "sun/awt/CGraphicsEnvironment");
   122 
   123         static JNF_MEMBER_CACHE(jm_displayReconfiguration, jc_CGraphicsEnvironment, "_displayReconfiguration", "(IZ)V");
   123             jobject graphicsEnv = [wrapper jObjectWithEnv:env];
   124         JNFCallVoidMethod(env, graphicsEnv, jm_displayReconfiguration,
   124             if (graphicsEnv == NULL) return; // ref already GC'd
   125                             (jint) display, 
   125             static JNF_CLASS_CACHE(jc_CGraphicsEnvironment, "sun/awt/CGraphicsEnvironment");
   126                             (jboolean) flags & kCGDisplayRemoveFlag);
   126             static JNF_MEMBER_CACHE(jm_displayReconfiguration,
   127     });
   127                     jc_CGraphicsEnvironment, "_displayReconfiguration","(IZ)V");
       
   128             JNFCallVoidMethod(env, graphicsEnv, jm_displayReconfiguration,
       
   129                     (jint) display, (jboolean) flags & kCGDisplayRemoveFlag);
       
   130         });
       
   131     }];
   128 }
   132 }
   129 
   133 
   130 /*
   134 /*
   131  * Class:     sun_awt_CGraphicsEnvironment
   135  * Class:     sun_awt_CGraphicsEnvironment
   132  * Method:    registerDisplayReconfiguration
   136  * Method:    registerDisplayReconfiguration