queue and paint repairs

original commit: 5af3d96a5d5fc3a1edcc108a0754949c84e0ec7d
This commit is contained in:
Matthew Flatt 2010-07-23 08:19:34 -05:00
parent 10fbac433a
commit dc77ede76e
3 changed files with 26 additions and 7 deletions

View File

@ -10,6 +10,7 @@
"types.rkt"
"window.rkt"
"dc.rkt"
"queue.rkt"
"../common/event.rkt"
"../common/queue.rkt"
"../../syntax.rkt"
@ -40,7 +41,9 @@
(CGContextFillRect cg (make-NSRect (make-NSPoint 0 0)
(make-NSSize 32000 32000))))
(tellv ctx restoreGraphicsState))))
(send wx queue-paint))
(send wx queue-paint)
;; ensure that `nextEventMatchingMask:' returns
(post-dummy-event))
(-a _void (viewWillMoveToWindow: [_id w])
(when wx
(queue-window-event wx (lambda () (send wx fix-dc)))))
@ -76,15 +79,26 @@
(define canvas-style style)
;; Avoid multiple queued paints:
(define paint-queued? #f)
;; To handle paint requests that happen while on-paint
;; is being called already:
(define now-drawing? #f)
(define refresh-after-drawing? #f)
(define/public (queue-paint)
;; can be called from any thread, including the event-pump thread
(unless paint-queued?
(set! paint-queued? #t)
(queue-window-event this (lambda ()
(set! paint-queued? #f)
(on-paint)))))
(set! now-drawing? #t)
(fix-dc)
(on-paint)
(set! now-drawing? #f)
(when refresh-after-drawing?
(set! refresh-after-drawing? #f)
(refresh))))))
(define/override (refresh)
(tellv content-cocoa setNeedsDisplay: #:type _BOOL #t))
@ -312,9 +326,13 @@
(define/public (get-canvas-background) bg-col)
(define/public (set-canvas-background col) (set! bg-col col))
(define/public (get-canvas-background-for-clearing)
(and (not (memq 'transparent canvas-style))
(not (memq 'no-autoclear canvas-style))
bg-col))
(if now-drawing?
(begin
(set! refresh-after-drawing? #t)
#f)
(and (not (memq 'transparent canvas-style))
(not (memq 'no-autoclear canvas-style))
bg-col)))
(define/public (do-scroll direction scroller)
;; Called from the Cocoa handler thread

View File

@ -19,6 +19,7 @@
set-eventspace-hook!
set-front-hook!
set-menu-bar-hooks!
post-dummy-event
;; from common/queue:
current-eventspace

View File

@ -37,7 +37,7 @@
(define-glib g_main_context_query (_fun _GMainContext
_int
_pointer
_GPollFD-pointer
_pointer ;; GPollFD array
_int
-> _int))