From 36d033bf222a94a0902c8c098f2b95f5a3dc3db9 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Mon, 28 Oct 2013 16:00:54 -0400 Subject: [PATCH] slideshow: fix error exit with `interactive` Compensate for lost `on-subwindow-close` notifications. --- .../slideshow-lib/slideshow/viewer.rkt | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/pkgs/slideshow-pkgs/slideshow-lib/slideshow/viewer.rkt b/pkgs/slideshow-pkgs/slideshow-lib/slideshow/viewer.rkt index 4571b08d2e..ad07b3b57c 100644 --- a/pkgs/slideshow-pkgs/slideshow-lib/slideshow/viewer.rkt +++ b/pkgs/slideshow-pkgs/slideshow-lib/slideshow/viewer.rkt @@ -146,7 +146,8 @@ (set! click-regions (cons cr click-regions))) (define (add-interactive! ir) - (set! interactives (hash-set interactives ir #t))) + (set! interactives (hash-set interactives ir #t)) + (send c queue-interactive-check)) (define (make-quad l) (cond @@ -862,6 +863,8 @@ (set! interactives (for/hash ([k (in-hash-keys prefetched-interactives)]) (values (shift-interact k dx dy) #t))) + (when (positive? (hash-count prefetched-interactives)) + (queue-interactive-check)) (send f set-blank-cursor (null? click-regions))))) (define/override (on-size w h) (unless resizing-frame? @@ -970,6 +973,22 @@ (unless on? (swap-interactives! interactives #hash())))) + (define/public (queue-interactive-check) + ;; If a superwindow is hidden before we ere get a notification + ;; that the superwindow was visible, then we don't get a + ;; notification that the window is hidden. Use a low-priority + ;; callback to double-check. + (queue-callback (lambda () + (when (positive? (hash-count interactives)) + (let loop ([p this]) + (cond + [(not p) (void)] + [(send p is-shown?) (loop (send p get-parent))] + [else + ;; some superwindow is hidden + (swap-interactives! interactives #hash())])))) + #f)) + (define/public (call-with-suspended-interactive thunk) (define i interactives) (swap-interactives! i #hash())