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.
This commit is contained in:
Matthew Flatt 2013-10-24 11:28:26 -06:00
parent 5ff3caf481
commit 973e650fc7
3 changed files with 15 additions and 5 deletions

View File

@ -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,

View File

@ -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

View File

@ -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)