gui icon indicating copy to clipboard operation
gui copied to clipboard

Flickering problems of canvas without focus on MacOS

Open yjqww6 opened this issue 4 years ago • 2 comments

To reproduce:

  1. 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)
  1. focus on other windows
  2. move the cursor to this window without focusing on it
  3. 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.

yjqww6 avatar Jul 18 '20 04:07 yjqww6

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 avatar Aug 01 '20 19:08 mflatt

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

yjqww6 avatar Aug 04 '20 13:08 yjqww6