src/java.desktop/macosx/native/libsplashscreen/splashscreen_sys.m

Print this page

        

*** 124,139 **** done: setlocale(LC_ALL, old_locale); return buf; } char* SplashGetScaledImageName(const char* jar, const char* file, float *scaleFactor) { - NSAutoreleasePool *pool = [NSAutoreleasePool new]; *scaleFactor = 1; char* scaledFile = nil; ! float screenScaleFactor = 1; if (screenScaleFactor > 1) { NSString *fileName = [NSString stringWithUTF8String: file]; NSUInteger length = [fileName length]; NSRange range = [fileName rangeOfString: @"." --- 124,157 ---- done: setlocale(LC_ALL, old_locale); return buf; } + BOOL isSWTRunning() { + char envVar[80]; + // If this property is present we are running SWT + snprintf(envVar, sizeof(envVar), "JAVA_STARTED_ON_FIRST_THREAD_%d", getpid()); + return getenv(envVar) != NULL; + } + char* SplashGetScaledImageName(const char* jar, const char* file, float *scaleFactor) { *scaleFactor = 1; + + if(isSWTRunning()){ + return nil; + } + + NSAutoreleasePool *pool = [NSAutoreleasePool new]; char* scaledFile = nil; ! __block float screenScaleFactor = 1; ! ! [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ ! // initialize NSApplication and AWT stuff ! [NSApplicationAWT sharedApplication]; ! screenScaleFactor = [SplashNSScreen() backingScaleFactor]; ! }]; if (screenScaleFactor > 1) { NSString *fileName = [NSString stringWithUTF8String: file]; NSUInteger length = [fileName length]; NSRange range = [fileName rangeOfString: @"."
*** 174,189 **** initFormat(&splash->screenFormat, 0xff << 8, 0xff << 16, 0xff << 24, 0xff << 0); splash->screenFormat.byteOrder = 1 ? BYTE_ORDER_LSBFIRST : BYTE_ORDER_MSBFIRST; splash->screenFormat.depthBytes = 4; ! // If this property is present we are running SWT and should not start a runLoop // Can't check if running SWT in webstart, so splash screen in webstart SWT // applications is not supported ! char envVar[80]; ! snprintf(envVar, sizeof(envVar), "JAVA_STARTED_ON_FIRST_THREAD_%d", getpid()); ! if (getenv(envVar) == NULL) { [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^() { [NSApplicationAWT runAWTLoopWithApp:[NSApplicationAWT sharedApplication]]; }]; } } --- 192,205 ---- initFormat(&splash->screenFormat, 0xff << 8, 0xff << 16, 0xff << 24, 0xff << 0); splash->screenFormat.byteOrder = 1 ? BYTE_ORDER_LSBFIRST : BYTE_ORDER_MSBFIRST; splash->screenFormat.depthBytes = 4; ! // If we are running SWT we should not start a runLoop // Can't check if running SWT in webstart, so splash screen in webstart SWT // applications is not supported ! if (!isSWTRunning()) { [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^() { [NSApplicationAWT runAWTLoopWithApp:[NSApplicationAWT sharedApplication]]; }]; } }