gtk: smoother editor-canvas resize

- call `on-size' on setting the canvas size, like Win32 and Cocoa,
   which mainly shows/hides auto-shown scrollbars more on time
   (e.g., DrRacket doesn't start with horizontal scrollbars that
   immediately disappear)
 - switch mouse tracking to "hint" mode, instead of catching every
   single mouse position
 - when queueing `on-size' methos in response to client-size changes,
   cancel and queued but undelivered calls; in the case of editor
   canvases, this doesn't really have an effect, due to the other
   `on-size' call
 Closes PR 11369, hopefully
This commit is contained in:
Matthew Flatt 2011-02-19 16:05:54 -07:00
parent 8ae72bc29c
commit 85951bf665
5 changed files with 19 additions and 6 deletions

View File

@ -457,6 +457,7 @@
(reset-auto-scroll 0 0))
(on-size))
;; this `on-size' method is for `editor-canvas%', only:
(define/public (on-size) (void))
(define/public (show-scrollbars h? v?)

View File

@ -239,7 +239,7 @@
[ignored-name #f]
[gl-config #f])
(inherit get-gtk set-size get-size get-client-size
(inherit get-gtk get-size get-client-size
get-top-win
set-auto-size
adjust-client-delta infer-client-delta
@ -336,6 +336,10 @@
(list client-gtk))))])
(set-size x y w h)
(define/override (set-size x y w h)
(super set-size x y w h)
(on-size))
(define dc (new dc% [canvas this] [transparent? (memq 'transparent style)]))
@ -361,7 +365,7 @@
GDK_KEY_RELEASE_MASK
GDK_BUTTON_PRESS_MASK
GDK_BUTTON_RELEASE_MASK
GDK_POINTER_MOTION_MASK
GDK_POINTER_MOTION_HINT_MASK
GDK_FOCUS_CHANGE_MASK
GDK_ENTER_NOTIFY_MASK
GDK_LEAVE_NOTIFY_MASK))
@ -486,6 +490,7 @@
(define/override (on-client-size w h)
(on-size))
;; this `on-size' method is for `editor-canvas%', only:
(define/public (on-size) (void))
(define/public (show-scrollbars h? v?)

View File

@ -36,13 +36,19 @@
(define/public (on-client-size w h) (void))
(define client-size-key #f)
(define/public (save-client-size x y w h)
;; Called in the Gtk event-loop thread
(set! client-x x)
(set! client-y y)
(queue-window-event this (lambda ()
(internal-on-client-size w h)
(on-client-size w h))))
(when client-size-key (set-box! client-size-key #f))
(let ([key (box #t)])
(set! client-size-key key)
(queue-window-event this (lambda ()
(when (unbox key)
(internal-on-client-size w h)
(on-client-size w h))))))
(define/public (internal-on-client-size w h)
(void))

View File

@ -82,7 +82,7 @@
(connect-key-and-mouse gtk)
(gtk_widget_add_events gtk (bitwise-ior GDK_BUTTON_PRESS_MASK
GDK_BUTTON_RELEASE_MASK
GDK_POINTER_MOTION_MASK
GDK_POINTER_MOTION_HINT_MASK
GDK_FOCUS_CHANGE_MASK
GDK_ENTER_NOTIFY_MASK
GDK_LEAVE_NOTIFY_MASK))

View File

@ -249,6 +249,7 @@
(MoveWindow combo-hwnd 0 0 (max 1 w) (- h 2) #t)))
(on-size))
;; this `on-size' method is for `editor-canvas%', only:
(define/public (on-size) (void))
;; The `queue-paint' and `paint-children' methods