gui
gui copied to clipboard
Flickering problems of canvas without focus on MacOS
To reproduce:
- run this program
#lang racket/gui
(require mrlib/hierlist)
(define f (new frame% [label ""] [width 640] [height 480]))
(define hl (new hierarchical-list% [parent f]))
;(send hl set-scroll-via-copy #t)
(for ([i (in-range 1000)])
(send+ hl
(new-item)
(get-editor)
(insert (number->string i))))
(send f show #t)
- focus on other windows
- move the cursor to this window without focusing on it
- scrolling
This problem only occurs on Mac when racket window doesn't have focus. Also, uncomment the (send hl set-scroll-via-copy #t)
can avoid this problem. Though I use hierlist in this example, it seems other canvas also have similar problems when updating without focus.
I don't have a repair right now, but I can confirm that racket/gui
treats refresh for the frontmost window differently than other windows.
Fundamentally, the problem is a mismatch between the OS's view that each application has a single GUI event loop and the racket/gui
notion of eventspaces. Because of that mismatch, the refresh management that would normally come from the OS doesn't automatically work, and racket/gui
has to specifically request that refreshes are delayed. Worse, recent versions of Mac OS took away the ability to request a delay per-window, so racket/gui
has to request a delay process-wide. To prevent one eventspace from disabling the updates of windows in other eventspaces, racket/gui
currently uses the heuristic that only the frontmost window can delay refreshes. That's not a great rule, though, and it should be revisited.
@mflatt I'm not very familiar with how often multiple eventspaces are used in racket, but from your words, it seems it is possible to allow windows in same eventspace with frontmost window to request a delay, or it still is not acceptable to disable the updates of other frames in same eventspace? Also, I think a small terminal window on top of other windows is not rare, and it is probably worthwhile to remember the previous frontmost window when a racket gui app lose focus.