1 /* |
1 /* |
2 * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
26 #include "splashscreen_impl.h" |
26 #include "splashscreen_impl.h" |
27 |
27 |
28 #import <Cocoa/Cocoa.h> |
28 #import <Cocoa/Cocoa.h> |
29 #import <objc/objc-auto.h> |
29 #import <objc/objc-auto.h> |
30 |
30 |
|
31 #include <Security/AuthSession.h> |
31 #import <JavaNativeFoundation/JavaNativeFoundation.h> |
32 #import <JavaNativeFoundation/JavaNativeFoundation.h> |
32 #import "NSApplicationAWT.h" |
33 #import "NSApplicationAWT.h" |
33 |
34 |
34 #include <sys/time.h> |
35 #include <sys/time.h> |
35 #include <pthread.h> |
36 #include <pthread.h> |
182 } |
183 } |
183 [pool drain]; |
184 [pool drain]; |
184 return JNI_FALSE; |
185 return JNI_FALSE; |
185 } |
186 } |
186 |
187 |
187 void |
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 |
188 SplashInitPlatform(Splash * splash) { |
209 SplashInitPlatform(Splash * splash) { |
|
210 if (!isInAquaSession()) { |
|
211 return 0; |
|
212 } |
189 pthread_mutex_init(&splash->lock, NULL); |
213 pthread_mutex_init(&splash->lock, NULL); |
190 |
214 |
191 splash->maskRequired = 0; |
215 splash->maskRequired = 0; |
192 |
216 |
193 |
217 |
194 //TODO: the following is too much of a hack but should work in 90% cases. |
218 //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 |
219 // besides we don't use device-dependent drawing, so probably |
196 // that's very fine indeed |
220 // that's very fine indeed |
197 splash->byteAlignment = 1; |
221 splash->byteAlignment = 1; |
198 initFormat(&splash->screenFormat, 0xff << 8, |
222 initFormat(&splash->screenFormat, 0xff << 8, |
204 if (!isSWTRunning()) { |
228 if (!isSWTRunning()) { |
205 [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^() { |
229 [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^() { |
206 [NSApplicationAWT runAWTLoopWithApp:[NSApplicationAWT sharedApplication]]; |
230 [NSApplicationAWT runAWTLoopWithApp:[NSApplicationAWT sharedApplication]]; |
207 }]; |
231 }]; |
208 } |
232 } |
|
233 return 1; |
209 } |
234 } |
210 |
235 |
211 void |
236 void |
212 SplashCleanupPlatform(Splash * splash) { |
237 SplashCleanupPlatform(Splash * splash) { |
213 splash->maskRequired = 0; |
238 splash->maskRequired = 0; |
255 |
280 |
256 void |
281 void |
257 SplashRedrawWindow(Splash * splash) { |
282 SplashRedrawWindow(Splash * splash) { |
258 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
283 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
259 |
284 |
260 SplashUpdateScreenData(splash); |
|
261 |
|
262 [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ |
285 [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ |
|
286 // drop the reference to the old view and image |
|
287 [splash->window setContentView: nil]; |
|
288 SplashUpdateScreenData(splash); |
|
289 |
263 // NSDeviceRGBColorSpace vs. NSCalibratedRGBColorSpace ? |
290 // NSDeviceRGBColorSpace vs. NSCalibratedRGBColorSpace ? |
264 NSBitmapImageRep * rep = [[NSBitmapImageRep alloc] |
291 NSBitmapImageRep * rep = [[NSBitmapImageRep alloc] |
265 initWithBitmapDataPlanes: (unsigned char**)&splash->screenData |
292 initWithBitmapDataPlanes: (unsigned char**)&splash->screenData |
266 pixelsWide: splash->width |
293 pixelsWide: splash->width |
267 pixelsHigh: splash->height |
294 pixelsHigh: splash->height |
284 NSSize size = [image size]; |
311 NSSize size = [image size]; |
285 size.width /= scaleFactor; |
312 size.width /= scaleFactor; |
286 size.height /= scaleFactor; |
313 size.height /= scaleFactor; |
287 [image setSize: size]; |
314 [image setSize: size]; |
288 } |
315 } |
289 |
316 |
290 NSImageView * view = [[NSImageView alloc] init]; |
317 NSImageView * view = [[NSImageView alloc] init]; |
291 |
318 |
292 [view setImage: image]; |
319 [view setImage: image]; |
293 [view setEditable: NO]; |
320 [view setEditable: NO]; |
294 //NOTE: we don't set a 'wait cursor' for the view because: |
321 //NOTE: we don't set a 'wait cursor' for the view because: |