| 1 |
(library (Cocoa helpers) |
| 2 |
(export make-app nsstring) |
| 3 |
(import (ikarus) (Cocoa) (objc) (ikarus system $foreign)) |
| 4 |
|
| 5 |
(define (make-app) |
| 6 |
(define kProcessTransformToForegroundApplication 1) |
| 7 |
(define self (dlopen)) |
| 8 |
(define get-current-process |
| 9 |
((make-c-callout 'void '(pointer)) |
| 10 |
(dlsym self "GetCurrentProcess"))) |
| 11 |
(define transform-process-type |
| 12 |
((make-c-callout 'void '(pointer signed-int)) |
| 13 |
(dlsym self "TransformProcessType"))) |
| 14 |
(define set-front-process |
| 15 |
((make-c-callout 'void '(pointer)) |
| 16 |
(dlsym self "SetFrontProcess"))) |
| 17 |
(let ([p (malloc 16)]) |
| 18 |
(get-current-process p) |
| 19 |
(transform-process-type p kProcessTransformToForegroundApplication) |
| 20 |
(set-front-process p) |
| 21 |
(free p))) |
| 22 |
|
| 23 |
|
| 24 |
(define (nsstring x) |
| 25 |
[$ [$ NSString alloc] |
| 26 |
initWithCharactersNoCopy: x |
| 27 |
length: (string-length x) |
| 28 |
freeWhenDone: #t]) |
| 29 |
|
| 30 |
) |
| 31 |
|
| 32 |
|