8223271: SplashScreen is still shown if defaulting to headless on MacOS
Reviewed-by: bpb, serb, kcr
This commit is contained in:
parent
10cac15976
commit
312d66471a
@ -824,6 +824,7 @@ ifeq ($(ENABLE_HEADLESS_ONLY), false)
|
||||
$(LIBM) -lpthread -liconv -losxapp \
|
||||
-framework ApplicationServices \
|
||||
-framework Foundation \
|
||||
-framework Security \
|
||||
-framework Cocoa \
|
||||
-framework JavaNativeFoundation
|
||||
else ifeq ($(call isTargetOs, windows), true)
|
||||
|
@ -1169,13 +1169,13 @@ SelectVersion(int argc, char **argv, char **main_class)
|
||||
* Passing on splash screen info in environment variables
|
||||
*/
|
||||
if (splash_file_name && !headlessflag) {
|
||||
char* splash_file_entry = JLI_MemAlloc(JLI_StrLen(SPLASH_FILE_ENV_ENTRY "=")+JLI_StrLen(splash_file_name)+1);
|
||||
splash_file_entry = JLI_MemAlloc(JLI_StrLen(SPLASH_FILE_ENV_ENTRY "=")+JLI_StrLen(splash_file_name)+1);
|
||||
JLI_StrCpy(splash_file_entry, SPLASH_FILE_ENV_ENTRY "=");
|
||||
JLI_StrCat(splash_file_entry, splash_file_name);
|
||||
putenv(splash_file_entry);
|
||||
}
|
||||
if (splash_jar_name && !headlessflag) {
|
||||
char* splash_jar_entry = JLI_MemAlloc(JLI_StrLen(SPLASH_JAR_ENV_ENTRY "=")+JLI_StrLen(splash_jar_name)+1);
|
||||
splash_jar_entry = JLI_MemAlloc(JLI_StrLen(SPLASH_JAR_ENV_ENTRY "=")+JLI_StrLen(splash_jar_name)+1);
|
||||
JLI_StrCpy(splash_jar_entry, SPLASH_JAR_ENV_ENTRY "=");
|
||||
JLI_StrCat(splash_jar_entry, splash_jar_name);
|
||||
putenv(splash_jar_entry);
|
||||
@ -2241,6 +2241,11 @@ ShowSplashScreen()
|
||||
if (file_name == NULL){
|
||||
return;
|
||||
}
|
||||
|
||||
if (!DoSplashInit()) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
maxScaledImgNameLength = DoSplashGetScaledImgNameMaxPstfixLen(file_name);
|
||||
|
||||
scaled_splash_name = JLI_MemAlloc(
|
||||
@ -2261,13 +2266,13 @@ ShowSplashScreen()
|
||||
jar_name, file_name, &data_size);
|
||||
}
|
||||
if (image_data) {
|
||||
DoSplashInit();
|
||||
DoSplashSetScaleFactor(scale_factor);
|
||||
DoSplashLoadMemory(image_data, data_size);
|
||||
JLI_MemFree(image_data);
|
||||
} else {
|
||||
DoSplashClose();
|
||||
}
|
||||
} else {
|
||||
DoSplashInit();
|
||||
if (isImageScaled) {
|
||||
DoSplashSetScaleFactor(scale_factor);
|
||||
DoSplashLoadFile(scaled_splash_name);
|
||||
@ -2279,6 +2284,7 @@ ShowSplashScreen()
|
||||
|
||||
DoSplashSetFileJarName(file_name, jar_name);
|
||||
|
||||
exit:
|
||||
/*
|
||||
* Done with all command line processing and potential re-execs so
|
||||
* clean up the environment.
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
int DoSplashLoadMemory(void* pdata, int size); /* requires preloading the file */
|
||||
int DoSplashLoadFile(const char* filename);
|
||||
void DoSplashInit(void);
|
||||
int DoSplashInit(void);
|
||||
void DoSplashClose(void);
|
||||
void DoSplashSetFileJarName(const char* fileName, const char* jarName);
|
||||
void DoSplashSetScaleFactor(float scaleFactor);
|
||||
|
@ -33,7 +33,7 @@ extern void* SplashProcAddress(const char* name); /* in java_md.c */
|
||||
*/
|
||||
typedef int (*SplashLoadMemory_t)(void* pdata, int size);
|
||||
typedef int (*SplashLoadFile_t)(const char* filename);
|
||||
typedef void (*SplashInit_t)(void);
|
||||
typedef int (*SplashInit_t)(void);
|
||||
typedef void (*SplashClose_t)(void);
|
||||
typedef void (*SplashSetFileJarName_t)(const char* fileName,
|
||||
const char* jarName);
|
||||
@ -71,8 +71,8 @@ int DoSplashLoadFile(const char* filename) {
|
||||
INVOKE(SplashLoadFile, 0)(filename);
|
||||
}
|
||||
|
||||
void DoSplashInit(void) {
|
||||
INVOKEV(SplashInit)();
|
||||
int DoSplashInit(void) {
|
||||
INVOKE(SplashInit, 0)();
|
||||
}
|
||||
|
||||
void DoSplashClose(void) {
|
||||
|
@ -28,6 +28,7 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <objc/objc-auto.h>
|
||||
|
||||
#include <Security/AuthSession.h>
|
||||
#import <JavaNativeFoundation/JavaNativeFoundation.h>
|
||||
#import "NSApplicationAWT.h"
|
||||
|
||||
@ -184,8 +185,31 @@ jboolean SplashGetScaledImageName(const char* jar, const char* file,
|
||||
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;
|
||||
@ -206,6 +230,7 @@ SplashInitPlatform(Splash * splash) {
|
||||
[NSApplicationAWT runAWTLoopWithApp:[NSApplicationAWT sharedApplication]];
|
||||
}];
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -57,7 +57,7 @@ SplashSetFileJarName(const char* fileName, const char* jarName) {
|
||||
splash->jarName = SplashConvertStringAlloc(jarName, &splash->jarNameLen);
|
||||
}
|
||||
|
||||
JNIEXPORT void
|
||||
JNIEXPORT int
|
||||
SplashInit()
|
||||
{
|
||||
Splash *splash = SplashGetInstance();
|
||||
@ -67,7 +67,7 @@ SplashInit()
|
||||
splash->scaleFactor = 1;
|
||||
initFormat(&splash->imageFormat, QUAD_RED_MASK, QUAD_GREEN_MASK,
|
||||
QUAD_BLUE_MASK, QUAD_ALPHA_MASK);
|
||||
SplashInitPlatform(splash);
|
||||
return SplashInitPlatform(splash);
|
||||
}
|
||||
|
||||
JNIEXPORT void
|
||||
@ -263,6 +263,7 @@ SplashLoadStream(SplashStream * stream)
|
||||
|
||||
Splash *splash = SplashGetInstance();
|
||||
if (splash->isVisible < 0) {
|
||||
stream->close(stream);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ SplashLoadMemory(void *pdata, int size); /* requires preloading the file */
|
||||
JNIEXPORT int
|
||||
SplashLoadFile(const char *filename); // FIXME: range checking for SplashLoadMemory
|
||||
|
||||
JNIEXPORT void
|
||||
JNIEXPORT int
|
||||
SplashInit(void);
|
||||
|
||||
JNIEXPORT void
|
||||
@ -125,7 +125,7 @@ typedef struct Splash
|
||||
/* To be implemented in the platform-specific native code. */
|
||||
|
||||
|
||||
void SplashInitPlatform(Splash * splash);
|
||||
int SplashInitPlatform(Splash * splash);
|
||||
void SplashCreateThread(Splash * splash);
|
||||
void SplashCleanupPlatform(Splash * splash);
|
||||
void SplashDonePlatform(Splash * splash);
|
||||
|
@ -405,7 +405,7 @@ HandleIOError(Display * display) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
SplashInitPlatform(Splash * splash) {
|
||||
int shapeVersionMajor, shapeVersionMinor;
|
||||
|
||||
@ -424,7 +424,7 @@ SplashInitPlatform(Splash * splash) {
|
||||
splash->display = XOpenDisplay(NULL);
|
||||
if (!splash->display) {
|
||||
splash->isVisible = -1;
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
shapeSupported = XShapeQueryExtension(splash->display, &shapeEventBase,
|
||||
@ -474,7 +474,7 @@ SplashInitPlatform(Splash * splash) {
|
||||
splash->screen = NULL;
|
||||
splash->visual = NULL;
|
||||
fprintf(stderr, "Warning: unable to initialize the splashscreen. Not enough available color cells.\n");
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
splash->cmap = AllocColors(splash->display, splash->screen,
|
||||
numColors, colorIndex);
|
||||
@ -506,6 +506,7 @@ SplashInitPlatform(Splash * splash) {
|
||||
default:
|
||||
; /* FIXME: should probably be fixed, but javaws splash screen doesn't support other visuals either */
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -437,7 +437,7 @@ SplashUnlock(Splash * splash)
|
||||
LeaveCriticalSection(&splash->lock);
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
SplashInitPlatform(Splash * splash)
|
||||
{
|
||||
HDC hdc;
|
||||
@ -486,6 +486,7 @@ SplashInitPlatform(Splash * splash)
|
||||
}
|
||||
}
|
||||
ReleaseDC(NULL, hdc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
x
Reference in New Issue
Block a user