src/solaris/native/java/lang/java_props_macosx.c

Print this page
rev 5549 : 8003898: X11 toolkit can be chosen as the default toolkit
Summary: XToolkit is not selected for any values of system-wide environment variables (ex. DISPLAY).
Reviewed-by: anthony, art


  98 static PreferredToolkit getPreferredToolkitFromEnv() {
  99     char *envVar = getenv("AWT_TOOLKIT");
 100     if (envVar == NULL) return unset;
 101 
 102     if (strcasecmp(envVar, "CToolkit") == 0) return CToolkit;
 103     if (strcasecmp(envVar, "XToolkit") == 0) return XToolkit;
 104     if (strcasecmp(envVar, "HToolkit") == 0) return HToolkit;
 105     return unset;
 106 }
 107 
 108 static bool isInAquaSession() {
 109     // Is the WindowServer available?
 110     SecuritySessionId session_id;
 111     SessionAttributeBits session_info;
 112     OSStatus status = SessionGetInfo(callerSecuritySession, &session_id, &session_info);
 113     if (status != noErr) return false;
 114     if (!(session_info & sessionHasGraphicAccess)) return false;
 115     return true;
 116 }
 117 
 118 static bool isXDisplayDefined() {
 119     return getenv("DISPLAY") != NULL;
 120 }
 121 
 122 PreferredToolkit getPreferredToolkit() {
 123     static PreferredToolkit pref = unset;
 124     if (pref != unset) return pref;
 125 
 126     PreferredToolkit prefFromEnv = getPreferredToolkitFromEnv();
 127     if (prefFromEnv != unset) return pref = prefFromEnv;
 128 
 129     if (isInAquaSession()) return pref = CToolkit;
 130     if (isXDisplayDefined()) return pref = XToolkit;
 131     return pref = HToolkit;
 132 }
 133 
 134 void setUnknownOSAndVersion(java_props_t *sprops) {
 135     sprops->os_name = strdup("Unknown");
 136     sprops->os_version = strdup("Unknown");
 137 }
 138 
 139 void setOSNameAndVersion(java_props_t *sprops) {
 140     void *jrsFwk = getJRSFramework();
 141     if (jrsFwk == NULL) {
 142         setUnknownOSAndVersion(sprops);
 143         return;
 144     }
 145 
 146     char *(*copyOSName)() = dlsym(jrsFwk, "JRSCopyOSName");
 147     char *(*copyOSVersion)() = dlsym(jrsFwk, "JRSCopyOSVersion");
 148     if (copyOSName == NULL || copyOSVersion == NULL) {
 149         setUnknownOSAndVersion(sprops);
 150         return;




  98 static PreferredToolkit getPreferredToolkitFromEnv() {
  99     char *envVar = getenv("AWT_TOOLKIT");
 100     if (envVar == NULL) return unset;
 101 
 102     if (strcasecmp(envVar, "CToolkit") == 0) return CToolkit;
 103     if (strcasecmp(envVar, "XToolkit") == 0) return XToolkit;
 104     if (strcasecmp(envVar, "HToolkit") == 0) return HToolkit;
 105     return unset;
 106 }
 107 
 108 static bool isInAquaSession() {
 109     // Is the WindowServer available?
 110     SecuritySessionId session_id;
 111     SessionAttributeBits session_info;
 112     OSStatus status = SessionGetInfo(callerSecuritySession, &session_id, &session_info);
 113     if (status != noErr) return false;
 114     if (!(session_info & sessionHasGraphicAccess)) return false;
 115     return true;
 116 }
 117 




 118 PreferredToolkit getPreferredToolkit() {
 119     static PreferredToolkit pref = unset;
 120     if (pref != unset) return pref;
 121 
 122     PreferredToolkit prefFromEnv = getPreferredToolkitFromEnv();
 123     if (prefFromEnv != unset) return pref = prefFromEnv;
 124 
 125     if (isInAquaSession()) return pref = CToolkit;

 126     return pref = HToolkit;
 127 }
 128 
 129 void setUnknownOSAndVersion(java_props_t *sprops) {
 130     sprops->os_name = strdup("Unknown");
 131     sprops->os_version = strdup("Unknown");
 132 }
 133 
 134 void setOSNameAndVersion(java_props_t *sprops) {
 135     void *jrsFwk = getJRSFramework();
 136     if (jrsFwk == NULL) {
 137         setUnknownOSAndVersion(sprops);
 138         return;
 139     }
 140 
 141     char *(*copyOSName)() = dlsym(jrsFwk, "JRSCopyOSName");
 142     char *(*copyOSVersion)() = dlsym(jrsFwk, "JRSCopyOSVersion");
 143     if (copyOSName == NULL || copyOSVersion == NULL) {
 144         setUnknownOSAndVersion(sprops);
 145         return;