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
48 static void SplashCenter(Splash * splash)
49 {
50 // otherwise could use screens[0] to select the menu-bar screen
51 NSRect screenFrame = [[NSScreen mainScreen] visibleFrame];
52
53 splash->x = (screenFrame.size.width - splash->width) / 2;
54 splash->y = (screenFrame.size.height - splash->height) / 2 + screenFrame.origin.y;
55 }
56
57 unsigned
58 SplashTime(void) {
59 struct timeval tv;
60 struct timezone tz;
61 unsigned long long msec;
62
63 gettimeofday(&tv, &tz);
64 msec = (unsigned long long) tv.tv_sec * 1000 +
65 (unsigned long long) tv.tv_usec / 1000;
66
67 return (unsigned) msec;
68 }
69
70 /* Could use npt but decided to cut down on linked code size */
71 char* SplashConvertStringAlloc(const char* in, int* size) {
320 void *
321 SplashScreenThread(void *param) {
322 objc_registerThreadWithCollector();
323
324 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
325 Splash *splash = (Splash *) param;
326
327 SplashLock(splash);
328 pipe(splash->controlpipe);
329 fcntl(splash->controlpipe[0], F_SETFL,
330 fcntl(splash->controlpipe[0], F_GETFL, 0) | O_NONBLOCK);
331 splash->time = SplashTime();
332 splash->currentFrame = 0;
333 [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
334 SplashCenter(splash);
335
336 splash->window = (void*) [[NSWindow alloc]
337 initWithContentRect: NSMakeRect(splash->x, splash->y, splash->width, splash->height)
338 styleMask: NSBorderlessWindowMask
339 backing: NSBackingStoreBuffered
340 defer: NO];
341
342 [splash->window setOpaque: NO];
343 [splash->window setBackgroundColor: [NSColor clearColor]];
344 }];
345 fflush(stdout);
346 if (splash->window) {
347 [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
348 [splash->window orderFrontRegardless];
349 }];
350 SplashRedrawWindow(splash);
351 SplashEventLoop(splash);
352 }
353 SplashUnlock(splash);
354 SplashDone(splash);
355
356 splash->isVisible=-1;
357
358 [pool drain];
359
360 return 0;
|
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
48 static NSScreen* SplashNSScreen()
49 {
50 return [[NSScreen screens] objectAtIndex: 0];
51 }
52
53 static void SplashCenter(Splash * splash)
54 {
55 NSRect screenFrame = [SplashNSScreen() frame];
56
57 splash->x = (screenFrame.size.width - splash->width) / 2;
58 splash->y = (screenFrame.size.height - splash->height) / 2 + screenFrame.origin.y;
59 }
60
61 unsigned
62 SplashTime(void) {
63 struct timeval tv;
64 struct timezone tz;
65 unsigned long long msec;
66
67 gettimeofday(&tv, &tz);
68 msec = (unsigned long long) tv.tv_sec * 1000 +
69 (unsigned long long) tv.tv_usec / 1000;
70
71 return (unsigned) msec;
72 }
73
74 /* Could use npt but decided to cut down on linked code size */
75 char* SplashConvertStringAlloc(const char* in, int* size) {
324 void *
325 SplashScreenThread(void *param) {
326 objc_registerThreadWithCollector();
327
328 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
329 Splash *splash = (Splash *) param;
330
331 SplashLock(splash);
332 pipe(splash->controlpipe);
333 fcntl(splash->controlpipe[0], F_SETFL,
334 fcntl(splash->controlpipe[0], F_GETFL, 0) | O_NONBLOCK);
335 splash->time = SplashTime();
336 splash->currentFrame = 0;
337 [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
338 SplashCenter(splash);
339
340 splash->window = (void*) [[NSWindow alloc]
341 initWithContentRect: NSMakeRect(splash->x, splash->y, splash->width, splash->height)
342 styleMask: NSBorderlessWindowMask
343 backing: NSBackingStoreBuffered
344 defer: NO
345 screen: SplashNSScreen()];
346
347 [splash->window setOpaque: NO];
348 [splash->window setBackgroundColor: [NSColor clearColor]];
349 }];
350 fflush(stdout);
351 if (splash->window) {
352 [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
353 [splash->window orderFrontRegardless];
354 }];
355 SplashRedrawWindow(splash);
356 SplashEventLoop(splash);
357 }
358 SplashUnlock(splash);
359 SplashDone(splash);
360
361 splash->isVisible=-1;
362
363 [pool drain];
364
365 return 0;
|