Mac OS X 10.11: disable auto-update for suspended-flush windows

Previous versions of OS X seem to have automatically disabled
update for a window when flushing is disabled, but now we have to
do it ourselves, otherwise text editors can flicker a lot. (The
system change is probably related to the removal of the
`isFlushWindowDisabled` method of `NSWindow` (which was
deprecated in 10.10).
This commit is contained in:
Matthew Flatt 2015-10-04 12:11:21 -06:00
parent 52ac3da7bd
commit ea576d3177
3 changed files with 29 additions and 14 deletions

View File

@ -265,7 +265,9 @@
[ignored-name #f]
[gl-config #f])
(inherit get-cocoa get-cocoa-window
(inherit get-cocoa
get-cocoa-window
get-wx-window
get-eventspace
make-graphics-context
is-shown-to-root?
@ -319,7 +321,7 @@
(define/public (queue-paint) (void))
(define/public (request-canvas-flush-delay)
(unless is-gl?
(request-flush-delay (get-cocoa-window))))
(request-flush-delay (get-wx-window))))
(define/public (cancel-canvas-flush-delay req)
(unless is-gl?
(cancel-flush-delay req)))
@ -365,9 +367,6 @@
(define/public (end-refresh-sequence)
(send dc resume-flush))
(define/public (get-flush-window)
(get-cocoa-window))
(define/private (refresh-one)
(when is-gl?
(tellv content-cocoa setNeedsDisplay: #:type _BOOL #t))

View File

@ -399,6 +399,22 @@
(sync/timeout 1 s))))))
(atomically
(direct-show on?)))
(define flush-disabled 0)
(define/public (disable-flush-window)
(when (zero? flush-disabled)
(when (version-10.11-or-later?)
(tellv cocoa setAutodisplay: #:type _BOOL #f))
(tellv cocoa disableFlushWindow))
(set! flush-disabled (add1 flush-disabled)))
(define/public (enable-flush-window)
(set! flush-disabled (sub1 flush-disabled))
(when (zero? flush-disabled)
(tellv cocoa enableFlushWindow)
(when (version-10.11-or-later?)
(tellv cocoa setAutodisplay: #:type _BOOL #t))))
(define/public (force-window-focus)
(let ([next (get-app-front-window)])

View File

@ -1008,21 +1008,21 @@
(when wx
(queue-event (send wx get-eventspace) (lambda () (proc wx))))))
(define (request-flush-delay cocoa-win)
(define (request-flush-delay wx-win)
(do-request-flush-delay
cocoa-win
(lambda (cocoa-win)
(and (tell #:type _bool cocoa-win isVisible)
(tellv cocoa-win disableFlushWindow)
wx-win
(lambda (wx-win)
(and (tell #:type _bool (send wx-win get-cocoa-window) isVisible)
(send wx-win disable-flush-window)
#t))
(lambda (cocoa-win)
(tellv cocoa-win enableFlushWindow))))
(lambda (wx-win)
(send wx-win enable-flush-window))))
(define (cancel-flush-delay req)
(do-cancel-flush-delay
req
(lambda (cocoa-win)
(tellv cocoa-win enableFlushWindow))))
(lambda (wx-win)
(send wx-win enable-flush-window))))
(define (make-init-point x y)
(make-NSPoint (if (not x)