an experiment in making a cocoa webkit browser manageable under X11
1#include <stdio.h>
2#include <strings.h>
3#include <unistd.h>
4
5#include <Cocoa/Cocoa.h>
6
7#include "X11Window.h"
8#include "WKWindow.h"
9
10__dead void usage(void);
11int debug = 0;
12
13int main(int argc, char* argv[])
14{
15 int ch;
16
17 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
18 [NSApplication sharedApplication];
19
20 while ((ch = getopt(argc, argv, "d")) != -1)
21 switch (ch) {
22 case 'd':
23 debug = 1;
24 break;
25 default:
26 usage();
27 }
28 argc -= optind;
29 argv += optind;
30
31 /* bring up the X11 window */
32 X11Window *X = [X11Window alloc];
33 [X init];
34
35 /* handle webkit window in the main thread (webkit won't allow use in
36 * another thread anyway) */
37 WKWindow *WKW = [WKWindow alloc];
38 [WKW init];
39 [WKW setShadow:X];
40
41 /* let X do its event loop in its own thread */
42 [X performSelectorInBackground:@selector(mainLoopWithWKWindow:)
43 withObject:WKW];
44
45 /* if we have a remaining arg, load it as the url */
46 if (argc)
47 [WKW loadURL:[NSString stringWithFormat:@"%s", argv[0]]];
48
49 [NSApp run];
50
51 [pool release];
52 return (0);
53}
54
55__dead void
56usage(void)
57{
58 extern char *__progname;
59
60 fprintf(stderr, "usage: %s [-d] url\n", __progname);
61 exit(1);
62}