more attempts to avoid flicker

This commit is contained in:
Matthew Flatt 2010-09-08 05:05:19 -06:00
parent 8c9e239798
commit f13b569b75
14 changed files with 35 additions and 32 deletions

View File

@ -248,6 +248,11 @@
(not (send dc can-backing-flush?))) (not (send dc can-backing-flush?)))
(do-on-paint #f #f))) (do-on-paint #f #f)))
(define/public (begin-refresh-sequence)
(send dc suspend-flush))
(define/public (end-refresh-sequence)
(send dc resume-flush))
(define/override (refresh) (define/override (refresh)
;; can be called from any thread, including the event-pump thread ;; can be called from any thread, including the event-pump thread
(queue-paint)) (queue-paint))

View File

@ -57,6 +57,8 @@
(cairo_surface_destroy s) (cairo_surface_destroy s)
(set! s #f))))) (set! s #f)))))
(define-local-member-name end-delay)
(define dc% (define dc%
(class backing-dc% (class backing-dc%
(init [(cnvs canvas)]) (init [(cnvs canvas)])
@ -94,10 +96,12 @@
(define/override (resume-flush) (define/override (resume-flush)
(atomically (atomically
(set! suspend-count (sub1 suspend-count)) (set! suspend-count (sub1 suspend-count))
(when (and (zero? suspend-count) req) (super resume-flush)))
(cancel-flush-delay req)
(set! req #f)) (define/public (end-delay)
(super resume-flush))))) (when (and (zero? suspend-count) req)
(cancel-flush-delay req)
(set! req #f)))))
(define (do-backing-flush canvas dc ctx dx dy) (define (do-backing-flush canvas dc ctx dx dy)
(tellv ctx saveGraphicsState) (tellv ctx saveGraphicsState)
@ -124,4 +128,5 @@
(cairo_set_source cr s) (cairo_set_source cr s)
(cairo_pattern_destroy s)) (cairo_pattern_destroy s))
(cairo_destroy cr)))))) (cairo_destroy cr))))))
(tellv ctx restoreGraphicsState))) (tellv ctx restoreGraphicsState)
(send dc end-delay)))

View File

@ -262,15 +262,20 @@
"the eventspace hash been shutdown")) "the eventspace hash been shutdown"))
(when saved-child (when saved-child
(if (eq? (current-thread) (eventspace-handler-thread es)) (if (eq? (current-thread) (eventspace-handler-thread es))
(send saved-child paint-children) (do-paint-children)
(let ([s (make-semaphore)]) (let ([s (make-semaphore)])
(queue-callback (lambda () (queue-callback (lambda ()
(when saved-child (do-paint-children)
(send saved-child paint-children))
(semaphore-post s))) (semaphore-post s)))
(sync/timeout 0.2 s)))))) (sync/timeout 1 s))))))
(direct-show on?)) (direct-show on?))
(define/private (do-paint-children)
(when saved-child
(send saved-child paint-children))
(yield-refresh)
(try-to-sync-refresh))
(define/public (destroy) (define/public (destroy)
(when child-sheet (send child-sheet destroy)) (when child-sheet (send child-sheet destroy))
(direct-show #f)) (direct-show #f))

View File

@ -78,8 +78,6 @@
set-combo-box-font set-combo-box-font
get-double-click-time get-double-click-time
run-printout run-printout
end-refresh-sequence
begin-refresh-sequence
file-creator-and-type file-creator-and-type
send-event send-event
set-executer set-executer

View File

@ -30,8 +30,6 @@
set-executer set-executer
send-event send-event
file-creator-and-type file-creator-and-type
begin-refresh-sequence
end-refresh-sequence
run-printout run-printout
get-double-click-time get-double-click-time
set-combo-box-font set-combo-box-font

View File

@ -130,7 +130,7 @@
(super-tell #:type _void keyDown: event))] (super-tell #:type _void keyDown: event))]
[-a _void (keyUp: [_id event]) [-a _void (keyUp: [_id event])
(unless (do-key-event wxb event self #f) (unless (do-key-event wxb event self #f)
(super-tell #:type _void keyDown: event))] (super-tell #:type _void keyUp: event))]
[-a _void (insertText: [_NSString str]) [-a _void (insertText: [_NSString str])
(let ([cit (current-insert-text)]) (let ([cit (current-insert-text)])
(if cit (if cit
@ -455,7 +455,10 @@
;; re-sync the display in case a stream of ;; re-sync the display in case a stream of
;; events (e.g., key repeat) have a corersponding ;; events (e.g., key repeat) have a corersponding
;; stream of screen updates. ;; stream of screen updates.
(void)) (try-to-sync-refresh)
(let ([cocoa-win (get-cocoa-window)])
(when cocoa-win
(tellv cocoa-win flushWindowIfNeeded))))
(define/public (dispatch-on-char/sync e) (define/public (dispatch-on-char/sync e)
(pre-event-refresh) (pre-event-refresh)

View File

@ -373,6 +373,9 @@
(define/public (on-paint) (void)) (define/public (on-paint) (void))
(define/public (begin-refresh-sequence) (void))
(define/public (end-refresh-sequence) (void))
(define/override (refresh) (define/override (refresh)
(queue-paint)) (queue-paint))

View File

@ -78,8 +78,6 @@
set-combo-box-font set-combo-box-font
get-double-click-time get-double-click-time
run-printout run-printout
end-refresh-sequence
begin-refresh-sequence
file-creator-and-type file-creator-and-type
send-event send-event
set-executer set-executer

View File

@ -34,8 +34,6 @@
set-executer set-executer
send-event send-event
file-creator-and-type file-creator-and-type
begin-refresh-sequence
end-refresh-sequence
run-printout run-printout
get-double-click-time get-double-click-time
set-combo-box-font set-combo-box-font
@ -84,8 +82,6 @@
(case-lambda (case-lambda
[(path cr ty) (void)] [(path cr ty) (void)]
[(path) (values #"????" #"????")])) [(path) (values #"????" #"????")]))
(define (begin-refresh-sequence) (void))
(define (end-refresh-sequence) (void))
(define-unimplemented run-printout) (define-unimplemented run-printout)
(define (get-double-click-time) 250) (define (get-double-click-time) 250)
(define (set-combo-box-font f) (void)) (define (set-combo-box-font f) (void))

View File

@ -56,8 +56,6 @@
set-combo-box-font set-combo-box-font
get-double-click-time get-double-click-time
run-printout run-printout
end-refresh-sequence
begin-refresh-sequence
file-creator-and-type file-creator-and-type
send-event send-event
set-executer set-executer

View File

@ -77,8 +77,6 @@
set-combo-box-font set-combo-box-font
get-double-click-time get-double-click-time
run-printout run-printout
end-refresh-sequence
begin-refresh-sequence
file-creator-and-type file-creator-and-type
send-event send-event
set-executer set-executer

View File

@ -24,8 +24,6 @@
set-executer set-executer
send-event send-event
file-creator-and-type file-creator-and-type
begin-refresh-sequence
end-refresh-sequence
run-printout run-printout
get-double-click-time get-double-click-time
set-combo-box-font set-combo-box-font
@ -76,8 +74,6 @@
(define-unimplemented set-executer) (define-unimplemented set-executer)
(define-unimplemented send-event) (define-unimplemented send-event)
(define-unimplemented file-creator-and-type) (define-unimplemented file-creator-and-type)
(define-unimplemented begin-refresh-sequence)
(define-unimplemented end-refresh-sequence)
(define-unimplemented run-printout) (define-unimplemented run-printout)
(define-unimplemented get-double-click-time) (define-unimplemented get-double-click-time)
(define-unimplemented set-combo-box-font) (define-unimplemented set-combo-box-font)

View File

@ -159,7 +159,9 @@
get-scroll-range set-scroll-range get-scroll-range set-scroll-range
is-shown-to-root? is-shown-to-root?
show-scrollbars show-scrollbars
set-focus) set-focus
begin-refresh-sequence
end-refresh-sequence)
(define blink-timer #f) (define blink-timer #f)
(define noloop? #f) (define noloop? #f)

View File

@ -42,8 +42,6 @@
the-clipboard the-clipboard
the-x-selection-clipboard the-x-selection-clipboard
get-double-click-threshold get-double-click-threshold
begin-refresh-sequence
end-refresh-sequence
begin-busy-cursor begin-busy-cursor
end-busy-cursor end-busy-cursor
hide-cursor hide-cursor