From 8228ce92cfdf09611373a3c4bee7d4438f3b4ed0 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Fri, 21 Jan 2011 09:05:30 -0700 Subject: [PATCH] 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) --- collects/mred/private/wx/win32/canvas.rkt | 7 +++++ collects/mred/private/wx/win32/frame.rkt | 32 ++++++++++++++++------- collects/mred/private/wx/win32/panel.rkt | 7 +++++ collects/mred/private/wx/win32/window.rkt | 6 +++-- 4 files changed, 41 insertions(+), 11 deletions(-) diff --git a/collects/mred/private/wx/win32/canvas.rkt b/collects/mred/private/wx/win32/canvas.rkt index 375f950d89..0c5ddba9e9 100644 --- a/collects/mred/private/wx/win32/canvas.rkt +++ b/collects/mred/private/wx/win32/canvas.rkt @@ -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) diff --git a/collects/mred/private/wx/win32/frame.rkt b/collects/mred/private/wx/win32/frame.rkt index ecceb6e4e6..712f5ffd4a 100644 --- a/collects/mred/private/wx/win32/frame.rkt +++ b/collects/mred/private/wx/win32/frame.rkt @@ -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 diff --git a/collects/mred/private/wx/win32/panel.rkt b/collects/mred/private/wx/win32/panel.rkt index cb58ff65ff..5d5c798431 100644 --- a/collects/mred/private/wx/win32/panel.rkt +++ b/collects/mred/private/wx/win32/panel.rkt @@ -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)) diff --git a/collects/mred/private/wx/win32/window.rkt b/collects/mred/private/wx/win32/window.rkt index 6099f48385..814ad05f50 100644 --- a/collects/mred/private/wx/win32/window.rkt +++ b/collects/mred/private/wx/win32/window.rkt @@ -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))