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 _OSStatus _sint32)
(define-coreserv FSPathMakeRef (_fun _path _FSRef (_pointer = #f) -> _OSStatus))
(define-coreserv FSGetCatalogInfo

View File

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

View File

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