ffi/unsafe/objc: remove -A'/+A', add `#:async-apply'

Another run at the problem 57516164de was meant to solve. The
new solution just gives up when a `drawRect:' method is called
in the wrong thread, which might create refresh glitches but
avoids a deadlock in the case that the Racket thread is blocked
on the update happening in the foreign thread.

original commit: ca0418d47d62426a4321ddfe7001466f7d87739e
This commit is contained in:
Matthew Flatt 2013-04-23 11:10:52 -06:00
parent d4afe33b87
commit 421ce99a49
2 changed files with 10 additions and 5 deletions

View File

@ -65,7 +65,8 @@
(define-objc-mixin (RacketViewMixin Superclass)
#:mixins (KeyMouseTextResponder CursorDisplayer FocusResponder)
[wxb]
(-A _void (drawRect: [_NSRect r])
(-a #:async-apply (box (void))
_void (drawRect: [_NSRect r])
(when wxb
(let ([wx (->wx wxb)])
(when wx
@ -98,7 +99,8 @@
(define-objc-class CornerlessFrameView NSView
[]
(-A _void (drawRect: [_NSRect r])
(-a #:async-apply (box (void))
_void (drawRect: [_NSRect r])
(let ([ctx (tell NSGraphicsContext currentContext)])
(tellv ctx saveGraphicsState)
(let ([cg (tell #:type _CGContextRef ctx graphicsPort)]
@ -129,7 +131,8 @@
[on?]
(-a _void (setFocusState: [_BOOL is-on?])
(set! on? is-on?))
(-A _void (drawRect: [_NSRect r])
(-a #:async-apply (box (void))
_void (drawRect: [_NSRect r])
(let ([f (tell #:type _NSRect self frame)])
(tellv bezel-cell
drawWithFrame: #:type _NSRect (make-NSRect (make-NSPoint 2 2)
@ -154,7 +157,8 @@
#:mixins (FocusResponder KeyMouseTextResponder CursorDisplayer)
#:protocols (NSComboBoxDelegate)
[wxb]
(-A _void (drawRect: [_NSRect r])
(-a #:async-apply (box (void))
_void (drawRect: [_NSRect r])
(super-tell #:type _void drawRect: #:type _NSRect r)
(let ([wx (->wx wxb)])
(when wx

View File

@ -22,7 +22,8 @@
(define-objc-class FrameView NSView
[]
(-A _void (drawRect: [_NSRect r])
(- #:async-apply (box (void))
_void (drawRect: [_NSRect r])
(let ([ctx (tell NSGraphicsContext currentContext)])
(tellv ctx saveGraphicsState)
(let ([cg (tell #:type _CGContextRef ctx graphicsPort)]