win32: fix canvas-refresh problem when a canvas is shown

and when it has been drawn onto outside of `on-paint';
 also, try to prep the content of all canvases within a
 top-level window before the window is shown (as on other
 platforms)
This commit is contained in:
Matthew Flatt 2011-01-21 09:05:30 -07:00
parent e331f1bce2
commit 8228ce92cf
4 changed files with 41 additions and 11 deletions

View File

@ -228,6 +228,13 @@
(get-virtual-v-pos)
0)))
(define/override (show-children)
(when (dc . is-a? . dc<%>)
;; if the canvas was never shown, then it has never
;; been refreshed --- but it may have been drawn
;; outside `on-paint', so force a refresh
(reset-dc)))
(define/override (get-client-hwnd)
canvas-hwnd)

View File

@ -177,15 +177,29 @@
(define/override (show on?)
(let ([es (get-eventspace)])
(when (and on?
(eventspace-shutdown? es))
(error (string->symbol
(format "show method in ~a"
(if (is-dialog?)
'dialog%
'frame%)))
"eventspace has been shutdown")))
(super show on?))
(when on?
(when (eventspace-shutdown? es)
(error (string->symbol
(format "show method in ~a"
(if (is-dialog?)
'dialog%
'frame%)))
"eventspace has been shutdown"))
(when saved-child
(if (eq? (current-thread) (eventspace-handler-thread es))
(do-paint-children)
(let ([s (make-semaphore)])
(queue-callback (lambda ()
(do-paint-children)
(semaphore-post s)))
(sync/timeout 1 s))))))
;; calling `direct-show' instead of `show' avoids
;; calling `show-children':
(atomically (direct-show on?)))
(define/private (do-paint-children)
(when saved-child
(send saved-child paint-children)))
(define/override (direct-show on?)
;; atomic mode

View File

@ -70,6 +70,13 @@
#t)
#f))
(define/override (show-children)
(for ([c (in-list children)])
(send c show-children)))
(define/override (paint-children)
(for ([c (in-list children)])
(send c show-children)))
(define/override (wants-mouse-capture? control-hwnd)
(ptr-equal? (get-client-hwnd) control-hwnd))

View File

@ -245,6 +245,7 @@
(define/public (control-scrolled) #f)
(define/public (show on?)
(when on? (show-children))
(atomically (direct-show on?)))
(define shown? #f)
@ -295,8 +296,6 @@
(define/public (is-shown?)
shown?)
(define/public (paint-children) (void))
(define/public (get-x)
(let ([r (GetWindowRect hwnd)]
[pr (GetWindowRect (send parent get-client-hwnd))])
@ -485,6 +484,9 @@
(when parent
(send parent register-child this on?)))
(define/public (show-children) (void))
(define/public (paint-children) (void))
(define/public (get-top-frame)
(send parent get-top-frame))