11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 #include "splashscreen_impl.h"
27
28 #import <Cocoa/Cocoa.h>
29 #import <objc/objc-auto.h>
30
31 #import <JavaNativeFoundation/JavaNativeFoundation.h>
32 #import "NSApplicationAWT.h"
33
34 #include <sys/time.h>
35 #include <pthread.h>
36 #include <iconv.h>
37 #include <langinfo.h>
38 #include <locale.h>
39 #include <fcntl.h>
40 #include <poll.h>
41 #include <errno.h>
42 #include <sys/types.h>
43 #include <signal.h>
44 #include <unistd.h>
45 #include <dlfcn.h>
46
47 #include <sizecalc.h>
48 #import "ThreadUtilities.h"
49
50 NSString* findScaledImageName(NSString *fileName,
167 if(![[NSFileManager defaultManager]
168 fileExistsAtPath: fileName2x]) {
169 fileName2x = findScaledImageName(fileName, dotIndex, @"@200pct");
170 }
171 if (jar || [[NSFileManager defaultManager]
172 fileExistsAtPath: fileName2x]){
173 if (strlen([fileName2x UTF8String]) > scaledImageLength) {
174 [pool drain];
175 return JNI_FALSE;
176 }
177 *scaleFactor = 2;
178 strcpy(scaledFile, [fileName2x UTF8String]);
179 [pool drain];
180 return JNI_TRUE;
181 }
182 }
183 [pool drain];
184 return JNI_FALSE;
185 }
186
187 void
188 SplashInitPlatform(Splash * splash) {
189 pthread_mutex_init(&splash->lock, NULL);
190
191 splash->maskRequired = 0;
192
193
194 //TODO: the following is too much of a hack but should work in 90% cases.
195 // besides we don't use device-dependent drawing, so probably
196 // that's very fine indeed
197 splash->byteAlignment = 1;
198 initFormat(&splash->screenFormat, 0xff << 8,
199 0xff << 16, 0xff << 24, 0xff << 0);
200 splash->screenFormat.byteOrder = 1 ? BYTE_ORDER_LSBFIRST : BYTE_ORDER_MSBFIRST;
201 splash->screenFormat.depthBytes = 4;
202
203 // If we are running SWT we should not start a runLoop
204 if (!isSWTRunning()) {
205 [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^() {
206 [NSApplicationAWT runAWTLoopWithApp:[NSApplicationAWT sharedApplication]];
207 }];
208 }
209 }
210
211 void
212 SplashCleanupPlatform(Splash * splash) {
213 splash->maskRequired = 0;
214 }
215
216 void
217 SplashDonePlatform(Splash * splash) {
218 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
219
220 pthread_mutex_destroy(&splash->lock);
221 [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
222 if (splash->window) {
223 [splash->window orderOut:nil];
224 [splash->window release];
225 }
226 }];
227 [pool drain];
228 }
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 #include "splashscreen_impl.h"
27
28 #import <Cocoa/Cocoa.h>
29 #import <objc/objc-auto.h>
30
31 #include <Security/AuthSession.h>
32 #import <JavaNativeFoundation/JavaNativeFoundation.h>
33 #import "NSApplicationAWT.h"
34
35 #include <sys/time.h>
36 #include <pthread.h>
37 #include <iconv.h>
38 #include <langinfo.h>
39 #include <locale.h>
40 #include <fcntl.h>
41 #include <poll.h>
42 #include <errno.h>
43 #include <sys/types.h>
44 #include <signal.h>
45 #include <unistd.h>
46 #include <dlfcn.h>
47
48 #include <sizecalc.h>
49 #import "ThreadUtilities.h"
50
51 NSString* findScaledImageName(NSString *fileName,
168 if(![[NSFileManager defaultManager]
169 fileExistsAtPath: fileName2x]) {
170 fileName2x = findScaledImageName(fileName, dotIndex, @"@200pct");
171 }
172 if (jar || [[NSFileManager defaultManager]
173 fileExistsAtPath: fileName2x]){
174 if (strlen([fileName2x UTF8String]) > scaledImageLength) {
175 [pool drain];
176 return JNI_FALSE;
177 }
178 *scaleFactor = 2;
179 strcpy(scaledFile, [fileName2x UTF8String]);
180 [pool drain];
181 return JNI_TRUE;
182 }
183 }
184 [pool drain];
185 return JNI_FALSE;
186 }
187
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
209 SplashInitPlatform(Splash * splash) {
210 if (!isInAquaSession()) {
211 return 0;
212 }
213 pthread_mutex_init(&splash->lock, NULL);
214
215 splash->maskRequired = 0;
216
217
218 //TODO: the following is too much of a hack but should work in 90% cases.
219 // besides we don't use device-dependent drawing, so probably
220 // that's very fine indeed
221 splash->byteAlignment = 1;
222 initFormat(&splash->screenFormat, 0xff << 8,
223 0xff << 16, 0xff << 24, 0xff << 0);
224 splash->screenFormat.byteOrder = 1 ? BYTE_ORDER_LSBFIRST : BYTE_ORDER_MSBFIRST;
225 splash->screenFormat.depthBytes = 4;
226
227 // If we are running SWT we should not start a runLoop
228 if (!isSWTRunning()) {
229 [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^() {
230 [NSApplicationAWT runAWTLoopWithApp:[NSApplicationAWT sharedApplication]];
231 }];
232 }
233 return 1;
234 }
235
236 void
237 SplashCleanupPlatform(Splash * splash) {
238 splash->maskRequired = 0;
239 }
240
241 void
242 SplashDonePlatform(Splash * splash) {
243 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
244
245 pthread_mutex_destroy(&splash->lock);
246 [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
247 if (splash->window) {
248 [splash->window orderOut:nil];
249 [splash->window release];
250 }
251 }];
252 [pool drain];
253 }
|