|
38 | 38 | queue-event
|
39 | 39 | yield)
|
40 | 40 |
|
41 |
| -(import-class NSApplication NSAutoreleasePool NSColor NSProcessInfo NSArray NSMenu NSThread) |
| 41 | +(import-class NSApplication NSAutoreleasePool NSColor NSProcessInfo NSArray NSMenu NSThread |
| 42 | + NSUserDefaults NSDictionary) |
42 | 43 |
|
43 | 44 | (unless (tell #:type _BOOL NSThread isMainThread)
|
44 | 45 | (error 'racket/gui
|
45 | 46 | "cannot instantiate in a non-main place on Mac OS"))
|
46 | 47 |
|
47 |
| -;; Extreme hackery to hide original arguments from |
48 |
| -;; NSApplication, because NSApplication wants to turn |
49 |
| -;; the arguments into `application:openFile:' calls. |
50 |
| -;; To hide the arguments, we replace the implementation |
51 |
| -;; of `arguments' in the NSProcessInfo object. |
52 |
| -(define (hack-argument-replacement self method) |
53 |
| - (tell NSArray |
54 |
| - arrayWithObjects: #:type (_vector i _NSString) (vector (path->string (find-system-path 'exec-file))) |
55 |
| - count: #:type _NSUInteger 1)) |
56 |
| -(let ([m (class_getInstanceMethod NSProcessInfo (selector arguments))]) |
57 |
| - (void (method_setImplementation m hack-argument-replacement))) |
| 48 | +;; Hide original arguments from NSApplication, because NSApplication |
| 49 | +;; otherwise turns the arguments into `application:openFile:' calls. |
| 50 | +(void |
| 51 | + (tell (tell NSUserDefaults standardUserDefaults) |
| 52 | + registerDefaults: |
| 53 | + (tell NSDictionary |
| 54 | + dictionaryWithObjects: |
| 55 | + (tell NSArray |
| 56 | + arrayWithObjects: #:type (_vector i _NSString) (vector "NO") |
| 57 | + count: #:type _NSUInteger 1) |
| 58 | + forKeys: |
| 59 | + (tell NSArray |
| 60 | + arrayWithObjects: #:type (_vector i _NSString) (vector "NSTreatUnknownArgumentsAsOpen") |
| 61 | + count: #:type _NSUInteger 1)))) |
58 | 62 |
|
59 | 63 | (define app (tell NSApplication sharedApplication))
|
60 | 64 |
|
|
0 commit comments