From 973e650fc707deb689d4dd233c10be0d3667a3e3 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Thu, 24 Oct 2013 11:28:26 -0600 Subject: [PATCH] racket/gui: default application-file handler requeues on active-frame change When files passed to the default application-file handler cannot be delivered because no frame is active or the frame does not accept files, then retry when the active frame changes in the future (in addition to when the application-file handler itself is changed). This adjustment should fix a long-standing problem where files are not delivered to DrRacket on Mac OS X. --- .../gui-doc/scribblings/gui/system-menu-funcs.scrbl | 4 ++-- pkgs/gui-pkgs/gui-lib/mred/private/app.rkt | 4 +++- pkgs/gui-pkgs/gui-lib/mred/private/wxtop.rkt | 12 ++++++++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/pkgs/gui-pkgs/gui-doc/scribblings/gui/system-menu-funcs.scrbl b/pkgs/gui-pkgs/gui-doc/scribblings/gui/system-menu-funcs.scrbl index 9436a4d3df..c331b1832b 100644 --- a/pkgs/gui-pkgs/gui-doc/scribblings/gui/system-menu-funcs.scrbl +++ b/pkgs/gui-pkgs/gui-doc/scribblings/gui/system-menu-funcs.scrbl @@ -67,10 +67,10 @@ When the current eventspace is the initial eventspace, this procedure The default handler queues a callback to the @method[window<%> on-drop-file] method of the most-recently activated frame in the main eventspace (see -@racket[get-top-level-edit-target-window]), if +@racket[get-top-level-edit-target-window]), if any such frame exists and if drag-and-drop is enabled for that frame. Otherwise, it saves the filename and re-queues the handler event when the application - file handler is later changed. + file handler is later changed or when a frame becomes active. On Windows, when the application is @italic{not} running and user double-clicks an application-handled file or drags a file onto the application's icon, diff --git a/pkgs/gui-pkgs/gui-lib/mred/private/app.rkt b/pkgs/gui-pkgs/gui-lib/mred/private/app.rkt index c4a66e66ce..e70d76a5a7 100644 --- a/pkgs/gui-pkgs/gui-lib/mred/private/app.rkt +++ b/pkgs/gui-pkgs/gui-lib/mred/private/app.rkt @@ -117,7 +117,9 @@ (lambda () (if (send af accept-drag?) (send af on-drop-file f) (set! saved-files (cons f saved-files)))))) - (set! saved-files (cons f saved-files))))))) + (begin + (add-active-frame-callback! requeue-saved-files) + (set! saved-files (cons f saved-files)))))))) (define (requeue-saved-files) (as-entry diff --git a/pkgs/gui-pkgs/gui-lib/mred/private/wxtop.rkt b/pkgs/gui-pkgs/gui-lib/mred/private/wxtop.rkt index 090cc0bba0..4587579279 100644 --- a/pkgs/gui-pkgs/gui-lib/mred/private/wxtop.rkt +++ b/pkgs/gui-pkgs/gui-lib/mred/private/wxtop.rkt @@ -13,7 +13,8 @@ "wxcontainer.rkt") (provide (protect-out active-main-frame - set-root-menu-wx-frame!) + set-root-menu-wx-frame! + add-active-frame-callback!) get-display-size get-display-left-top-inset get-display-count @@ -24,6 +25,10 @@ ;; Weak boxed: (define active-main-frame (make-weak-box #f)) + + (define active-frame-callbacks null) + (define (add-active-frame-callback! cb) + (set! active-frame-callbacks (cons cb active-frame-callbacks))) (define root-menu-wx-frame #f) (define (set-root-menu-wx-frame! f) @@ -633,7 +638,10 @@ (when (and (wx:main-eventspace? (get-eventspace)) (not (eq? this root-menu-wx-frame)) (not floating-window?)) - (set! active-main-frame (make-weak-box this)))) + (set! active-main-frame (make-weak-box this)) + (let ([cbs (reverse active-frame-callbacks)]) + (set! active-frame-callbacks null) + (for ([cb (in-list cbs)]) (cb))))) ;; Send refresh to subwindows that need it (set! activate-refresh-wins (filter weak-box-value activate-refresh-wins)) (for-each (lambda (b)