cocoa: fix problems with frame-list management

This commit is contained in:
Matthew Flatt 2010-11-24 07:12:02 -07:00
parent 0d6d285423
commit 14a72b5a08
2 changed files with 25 additions and 8 deletions

View File

@ -36,6 +36,9 @@
(define empty-mb (new menu-bar%))
(define root-fake-frame #f)
;; Maps window numbers to weak boxes of frame objects;
;; the weak-box layer is needed to avoid GC-accounting
;; problems.
(define all-windows (make-hash))
(define-objc-mixin (MyWindowMethods Superclass)
@ -278,7 +281,7 @@
(register-frame-shown this on?)
(let ([num (tell #:type _NSInteger cocoa windowNumber)])
(if on?
(hash-set! all-windows num this)
(hash-set! all-windows num (make-weak-box this))
(hash-remove! all-windows num)))
(when on?
(let ([b (eventspace-wait-cursor-count (get-eventspace))])
@ -534,9 +537,13 @@
(let ([f (tell #:type _NSRect (tell NSScreen mainScreen) frame)])
(make-NSPoint x (- (NSSize-height (NSRect-size f)) y)))
belowWindowWithWindowNumber: #:type _NSInteger 0)])
(atomically (hash-ref all-windows n #f))))
(atomically (let ([b (hash-ref all-windows n #f)])
(and b (weak-box-value b))))))
(set-fixup-window-locations!
(lambda ()
(for ([f (in-hash-values all-windows)])
(send f fixup-locations-children))))
;; in atomic mode
(for ([b (in-hash-values all-windows)])
(let ([f (weak-box-value b)])
(send f fixup-locations-children)))))

View File

@ -12,6 +12,7 @@
ffi/unsafe/objc
"../../lock.rkt"
"dc.rkt"
"frame.rkt"
"bitmap.rkt"
"cg.rkt"
"utils.rkt"
@ -101,8 +102,13 @@
(send pss set-native pi make-print-info)
pi)))])
(install-pss-to-print-info pss print-info)
(if (= (tell #:type _NSInteger (tell NSPageLayout pageLayout) runModalWithPrintInfo: print-info)
(if (atomically
(let ([front (get-front)])
(begin0
(= (tell #:type _NSInteger (tell NSPageLayout pageLayout) runModalWithPrintInfo: print-info)
NSOkButton)
(when front
(tellv (send front get-cocoa-window) makeKeyAndOrderFront: #f)))))
(begin
(let ([o (tell #:type _int print-info orientation)])
(send pss set-orientation (if (= o NSLandscapeOrientation)
@ -195,4 +201,8 @@
(set-ivar! view-cocoa wxb (->wxb this))
(tellv op-cocoa runOperation))))
(atomically
(let ([front (get-front)])
(tellv op-cocoa runOperation)
(when front
(tellv (send front get-cocoa-window) makeKeyAndOrderFront: #f)))))))