cocoa: finally found the documented API to enable GUI mode

original commit: ab070b205ea20b76b76dea5e027d2a35e7de6c73
This commit is contained in:
Matthew Flatt 2010-11-24 16:57:44 -07:00
parent 0590579daa
commit 0d9d00cb1c
3 changed files with 13 additions and 12 deletions

View File

@ -65,8 +65,6 @@
(define _FSRef _pointer) ; 80 bytes (define _FSRef _pointer) ; 80 bytes
(define _OSStatus _sint32)
(define-coreserv FSPathMakeRef (_fun _path _FSRef (_pointer = #f) -> _OSStatus)) (define-coreserv FSPathMakeRef (_fun _path _FSRef (_pointer = #f) -> _OSStatus))
(define-coreserv FSGetCatalogInfo (define-coreserv FSGetCatalogInfo

View File

@ -68,15 +68,16 @@
;; In case we were started in an executable without a bundle, ;; In case we were started in an executable without a bundle,
;; explicitly register with the dock so the application can receive ;; explicitly register with the dock so the application can receive
;; keyboard events. ;; keyboard events.
;; This technique is not sanctioned by Apple --- I found the code in SDL. (define-cstruct _ProcessSerialNumber
(define-cstruct _CPSProcessSerNum ([lo _uint32] [hi _uint32])) ([highLongOfPSN _ulong]
(define-appserv CPSGetCurrentProcess (_fun _CPSProcessSerNum-pointer -> _int) [lowLongOfPSN _ulong]))
#:fail (lambda () (lambda args 1))) (define kCurrentProcess 2)
(define-appserv CPSEnableForegroundOperation (_fun _CPSProcessSerNum-pointer _int _int _int _int -> _int) (define kProcessTransformToForegroundApplication 1)
#:fail (lambda () #f)) (define-appserv TransformProcessType (_fun _ProcessSerialNumber-pointer
(let ([psn (make-CPSProcessSerNum 0 0)]) _uint32
(when (zero? (CPSGetCurrentProcess psn)) -> _OSStatus))
(void (CPSEnableForegroundOperation psn #x03 #x3C #x2C #x1103)))) (void (TransformProcessType (make-ProcessSerialNumber 0 kCurrentProcess)
kProcessTransformToForegroundApplication))
(define app-delegate (tell (tell MyApplicationDelegate alloc) init)) (define app-delegate (tell (tell MyApplicationDelegate alloc) init))
(tellv app setDelegate: app-delegate) (tellv app setDelegate: app-delegate)

View File

@ -5,7 +5,7 @@
"utils.rkt") "utils.rkt")
(provide (provide
(protect-out _NSInteger _NSUInteger (protect-out _NSInteger _NSUInteger _OSStatus
_CGFloat _CGFloat
_NSPoint _NSPoint-pointer (struct-out NSPoint) _NSPoint _NSPoint-pointer (struct-out NSPoint)
_NSSize _NSSize-pointer (struct-out NSSize) _NSSize _NSSize-pointer (struct-out NSSize)
@ -18,6 +18,8 @@
(define _NSInteger _long) (define _NSInteger _long)
(define _NSUInteger _ulong) (define _NSUInteger _ulong)
(define _OSStatus _sint32)
(define 64-bit? (= (ctype-sizeof _long) 8)) (define 64-bit? (= (ctype-sizeof _long) 8))
(define _CGFloat (make-ctype (if 64-bit? _double _float) (define _CGFloat (make-ctype (if 64-bit? _double _float)