diff --git a/collects/mred/private/wx/cocoa/frame.rkt b/collects/mred/private/wx/cocoa/frame.rkt index 0edb644f98..8d585a77f8 100644 --- a/collects/mred/private/wx/cocoa/frame.rkt +++ b/collects/mred/private/wx/cocoa/frame.rkt @@ -47,7 +47,7 @@ (let ([wx (->wx wxb)]) (and wx (not (other-modal? wx))))] - [-a _BOOL (canBecomeMainWindow) #t] + [-a _BOOL (canBecomeMainWindow) #t] [-a _BOOL (windowShouldClose: [_id win]) (queue-window*-event wxb (lambda (wx) (unless (other-modal? wx) @@ -73,15 +73,19 @@ (queue-window*-event wxb (lambda (wx) (send wx on-size 0 0))))] [-a _void (windowDidBecomeMain: [_id notification]) - (when wxb - (let ([wx (->wx wxb)]) - (when wx - (set! front wx) - (send wx install-wait-cursor) - (send wx install-mb) - (send wx notify-responder #t) - (queue-window-event wx (lambda () - (send wx on-activate #t))))))] + ;; We check whether the window is visible because + ;; clicking the dock item tries to resurrect a hidden + ;; frame. See also `setOneShot' below. + (when (tell #:type _BOOL self isVisible) + (when wxb + (let ([wx (->wx wxb)]) + (when wx + (set! front wx) + (send wx install-wait-cursor) + (send wx install-mb) + (send wx notify-responder #t) + (queue-window-event wx (lambda () + (send wx on-activate #t)))))))] [-a _void (windowDidResignMain: [_id notification]) (when wxb (let ([wx (->wx wxb)]) @@ -89,7 +93,9 @@ (when (eq? front wx) (set! front #f) (send wx uninstall-wait-cursor)) - (send empty-mb install) + (if root-fake-frame + (send root-fake-frame install-mb) + (send empty-mb install)) (send wx notify-responder #f) (queue-window-event wx (lambda () (send wx on-activate #f))))))] @@ -185,6 +191,10 @@ (tellv cocoa setAcceptsMouseMovedEvents: #:type _BOOL #t) + ;; Setting the window in one-shot mode helps prevent the + ;; frame from being resurrected by a click on the dock icon. + (tellv cocoa setOneShot: #:type _BOOL #t) + (define/override (get-cocoa-content) (tell cocoa contentView)) (define/override (get-cocoa-window) cocoa) diff --git a/collects/mred/private/wx/cocoa/queue.rkt b/collects/mred/private/wx/cocoa/queue.rkt index aec434b544..6c9f005bc8 100644 --- a/collects/mred/private/wx/cocoa/queue.rkt +++ b/collects/mred/private/wx/cocoa/queue.rkt @@ -48,6 +48,10 @@ (super-tell #:type _BOOL validateMenuItem: menuItem))] [-a _BOOL (application: [_id theApplication] openFile: [_NSString filename]) (queue-file-event (string->path filename))] + [-a _BOOL (applicationShouldHandleReopen: [_id app] hasVisibleWindows: [_BOOL has-visible?]) + ;; If we have any visible windows, return #t to do the default thing. + ;; Otherwise return #f, because we don't want any invisible windows resurrected. + has-visible?] [-a _void (applicationDidChangeScreenParameters: notification) ;; Screen changes sometimes make the event loop get stuck; ;; hack: schedule a wake-up call in 5 seconds