racket/gui win32: try to make pan gestures work

A pan gesture is turned into a WM_{H.V}SCROLL event in a
way that `racket/gui` did not recognize as a change to the
scrollbar. I'm not sure that this change fixes the problem,
but it seems worth a try.

original commit: 40f0682075f86149a72a87cd028bd71f8e51cbbe
This commit is contained in:
Matthew Flatt 2014-09-23 17:17:09 -06:00
parent dd3dfc6617
commit 1167e184b8
2 changed files with 16 additions and 2 deletions

View File

@ -158,6 +158,8 @@
(define hwnd (or panel-hwnd canvas-hwnd)) (define hwnd (or panel-hwnd canvas-hwnd))
(define dc #f) (define dc #f)
(define next-scroll-is-change? #f)
(super-new [parent parent] (super-new [parent parent]
[hwnd hwnd] [hwnd hwnd]
[extra-hwnds (if panel-hwnd [extra-hwnds (if panel-hwnd
@ -237,7 +239,15 @@
(when vscroll? (when vscroll?
(on-scroll-change SB_VERT (LOWORD wParam))) (on-scroll-change SB_VERT (LOWORD wParam)))
0] 0]
[else (super wndproc w msg wParam lParam default)])) [else
(when (= msg WM_GESTURE)
;; The fall-though wndproc might generate a WM_*SCROLL
;; event for us, but we need to force an update,
;; because the generated event happens after the position
;; is changed. And if it doesn't generate a scroll, then
;; it's ok to have an occassional spurious update.
(set! next-scroll-is-change? #t))
(super wndproc w msg wParam lParam default)]))
(define/override (wndproc-for-ctlproc w msg wParam lParam default) (define/override (wndproc-for-ctlproc w msg wParam lParam default)
;; act on clicks for a combo field: ;; act on clicks for a combo field:
@ -492,7 +502,9 @@
[(= part SB_PAGEDOWN) (min (SCROLLINFO-nMax i) (+ (SCROLLINFO-nPos i) (SCROLLINFO-nPage i)))] [(= part SB_PAGEDOWN) (min (SCROLLINFO-nMax i) (+ (SCROLLINFO-nPos i) (SCROLLINFO-nPage i)))]
[(= part SB_THUMBTRACK) (SCROLLINFO-nTrackPos i)] [(= part SB_THUMBTRACK) (SCROLLINFO-nTrackPos i)]
[else (SCROLLINFO-nPos i)])]) [else (SCROLLINFO-nPos i)])])
(unless (= new-pos (SCROLLINFO-nPos i)) (unless (or (= new-pos (SCROLLINFO-nPos i))
next-scroll-is-change?)
(set! next-scroll-is-change? #f)
(set-SCROLLINFO-nPos! i new-pos) (set-SCROLLINFO-nPos! i new-pos)
(set-SCROLLINFO-fMask! i SIF_POS) (set-SCROLLINFO-fMask! i SIF_POS)
(SetScrollInfo canvas-hwnd dir i #t) (SetScrollInfo canvas-hwnd dir i #t)

View File

@ -65,6 +65,8 @@
(define WM_POWER #x0048) (define WM_POWER #x0048)
(define WM_GESTURE #x0119)
;; wParam for WM_POWER window message and DRV_POWER driver notification ;; wParam for WM_POWER window message and DRV_POWER driver notification
(define PWR_OK 1) (define PWR_OK 1)
(define PWR_FAIL -1) (define PWR_FAIL -1)