src/java.desktop/macosx/native/libsplashscreen/splashscreen_sys.m
changeset 55189 fdaf7287ea3a
parent 47216 71c04702a3d5
child 55708 2b0acaf92ecc
equal deleted inserted replaced
55188:e29c0c8ebd90 55189:fdaf7287ea3a
    26 #include "splashscreen_impl.h"
    26 #include "splashscreen_impl.h"
    27 
    27 
    28 #import <Cocoa/Cocoa.h>
    28 #import <Cocoa/Cocoa.h>
    29 #import <objc/objc-auto.h>
    29 #import <objc/objc-auto.h>
    30 
    30 
       
    31 #include <Security/AuthSession.h>
    31 #import <JavaNativeFoundation/JavaNativeFoundation.h>
    32 #import <JavaNativeFoundation/JavaNativeFoundation.h>
    32 #import "NSApplicationAWT.h"
    33 #import "NSApplicationAWT.h"
    33 
    34 
    34 #include <sys/time.h>
    35 #include <sys/time.h>
    35 #include <pthread.h>
    36 #include <pthread.h>
   182     }
   183     }
   183     [pool drain];
   184     [pool drain];
   184     return JNI_FALSE;
   185     return JNI_FALSE;
   185 }
   186 }
   186 
   187 
   187 void
   188 static int isInAquaSession() {
       
   189     // environment variable to bypass the aqua session check
       
   190     char *ev = getenv("AWT_FORCE_HEADFUL");
       
   191     if (ev && (strncasecmp(ev, "true", 4) == 0)) {
       
   192         // if "true" then tell the caller we're in
       
   193         // an Aqua session without actually checking
       
   194         return 1;
       
   195     }
       
   196     // Is the WindowServer available?
       
   197     SecuritySessionId session_id;
       
   198     SessionAttributeBits session_info;
       
   199     OSStatus status = SessionGetInfo(callerSecuritySession, &session_id, &session_info);
       
   200     if (status == noErr) {
       
   201         if (session_info & sessionHasGraphicAccess) {
       
   202             return 1;
       
   203         }
       
   204     }
       
   205     return 0;
       
   206 }
       
   207 
       
   208 int
   188 SplashInitPlatform(Splash * splash) {
   209 SplashInitPlatform(Splash * splash) {
       
   210     if (!isInAquaSession()) {
       
   211         return 0;
       
   212     }
   189     pthread_mutex_init(&splash->lock, NULL);
   213     pthread_mutex_init(&splash->lock, NULL);
   190 
   214 
   191     splash->maskRequired = 0;
   215     splash->maskRequired = 0;
   192 
   216 
   193     
   217     
   204     if (!isSWTRunning()) {
   228     if (!isSWTRunning()) {
   205         [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^() {
   229         [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^() {
   206             [NSApplicationAWT runAWTLoopWithApp:[NSApplicationAWT sharedApplication]];
   230             [NSApplicationAWT runAWTLoopWithApp:[NSApplicationAWT sharedApplication]];
   207         }];
   231         }];
   208     }
   232     }
       
   233     return 1;
   209 }
   234 }
   210 
   235 
   211 void
   236 void
   212 SplashCleanupPlatform(Splash * splash) {
   237 SplashCleanupPlatform(Splash * splash) {
   213     splash->maskRequired = 0;
   238     splash->maskRequired = 0;