< prev index next >
src/java.desktop/macosx/native/libsplashscreen/splashscreen_sys.m
Print this page
@@ -26,10 +26,11 @@
#include "splashscreen_impl.h"
#import <Cocoa/Cocoa.h>
#import <objc/objc-auto.h>
+#include <Security/AuthSession.h>
#import <JavaNativeFoundation/JavaNativeFoundation.h>
#import "NSApplicationAWT.h"
#include <sys/time.h>
#include <pthread.h>
@@ -182,12 +183,35 @@
}
[pool drain];
return JNI_FALSE;
}
-void
+static int isInAquaSession() {
+ // environment variable to bypass the aqua session check
+ char *ev = getenv("AWT_FORCE_HEADFUL");
+ if (ev && (strncasecmp(ev, "true", 4) == 0)) {
+ // if "true" then tell the caller we're in
+ // an Aqua session without actually checking
+ return 1;
+ }
+ // Is the WindowServer available?
+ SecuritySessionId session_id;
+ SessionAttributeBits session_info;
+ OSStatus status = SessionGetInfo(callerSecuritySession, &session_id, &session_info);
+ if (status == noErr) {
+ if (session_info & sessionHasGraphicAccess) {
+ return 1;
+ }
+ }
+ return 0;
+}
+
+int
SplashInitPlatform(Splash * splash) {
+ if (!isInAquaSession()) {
+ return 0;
+ }
pthread_mutex_init(&splash->lock, NULL);
splash->maskRequired = 0;
@@ -204,10 +228,11 @@
if (!isSWTRunning()) {
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^() {
[NSApplicationAWT runAWTLoopWithApp:[NSApplicationAWT sharedApplication]];
}];
}
+ return 1;
}
void
SplashCleanupPlatform(Splash * splash) {
splash->maskRequired = 0;
< prev index next >