diff options
author | culler <culler> | 2023-11-21 03:05:03 (GMT) |
---|---|---|
committer | culler <culler> | 2023-11-21 03:05:03 (GMT) |
commit | e248b31dcf690c7e53152483247d999679106ca5 (patch) | |
tree | 0727e544eafab92a9ac43d7218bc72c330049276 /win/tkWinX.c | |
parent | edaf075b9b0ff023177a8167a0ad159d56336fe3 (diff) | |
download | tk-e248b31dcf690c7e53152483247d999679106ca5.zip tk-e248b31dcf690c7e53152483247d999679106ca5.tar.gz tk-e248b31dcf690c7e53152483247d999679106ca5.tar.bz2 |
Make touchpad scrolling work for Text widgets on Windows.
Diffstat (limited to 'win/tkWinX.c')
-rw-r--r-- | win/tkWinX.c | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/win/tkWinX.c b/win/tkWinX.c index f73c739..67411f0 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -1139,51 +1139,58 @@ GenerateXEvent( switch (message) { case WM_MOUSEWHEEL: { + /* - * Support for high resolution wheels (vertical). + * Send an Xevent using a KeyPress struct, but with the type field + * set to MouseWheelEventq and the keypress field set to the value + * of the MouseWheel delta. For high resolution events the + * ControlMask bit is set and delta is stored in the high word of + * the keycode. For low resolution scrolls the delta is in the + * low word of the keycode. Set nbytes to 0 to prevent conversion + * of the keycode to a keysym in TkpGetString. [Bug 1118340]. */ int delta = (short) HIWORD(wParam); int mod = delta % WHEELDELTA; if ( mod != 0 || lastMod != 0) { - printf("Trackpad scroll\n"); + /* High resolution. */ + event.x.type = MouseWheelEvent; + event.x.xany.send_event = -1; + event.key.nbytes = 0; + event.x.xkey.state = state | ControlMask ; + event.x.xkey.keycode = (unsigned int) delta; } else { - - /* - * We have invented a new X event type to handle this - * event. It still uses the KeyPress struct. However, the - * keycode field has been overloaded to hold the zDelta of the - * wheel. Set nbytes to 0 to prevent conversion of the keycode - * to a keysym in TkpGetString. [Bug 1118340]. - */ - event.x.type = MouseWheelEvent; event.x.xany.send_event = -1; event.key.nbytes = 0; - event.x.xkey.keycode = (unsigned int)delta; + event.x.xkey.keycode = (unsigned int) delta; } lastMod = mod; break; } case WM_MOUSEHWHEEL: { + /* - * Support for high resolution wheels (horizontal). + * Send an Xevent using a KeyPress struct, but with the type field + * set to MouseWheelEventq and the keypress field set to the value + * of the MouseWheel delta. For high resolution scrolls the + * ControlMask bit is set and deltaX is stored in the high word of + * the keycode. For low resolution scrolls the delta is in the + * low word of the keycode and the ShiftMask bit is set. Set + * nbytes to 0 to prevent conversion of the keycode to a keysym in + * TkpGetString. [Bug 1118340]. */ int delta = (short) HIWORD(wParam); int mod = delta % WHEELDELTA; if ( mod != 0 || lastMod != 0) { - printf("Trackpad scroll\n"); + /* High resolution. */ + event.x.type = MouseWheelEvent; + event.x.xany.send_event = -1; + event.key.nbytes = 0; + event.x.xkey.state = state | ControlMask ; + event.x.xkey.keycode = delta << 16; } else { - - /* - * We have invented a new X event type to handle this event. It - * still uses the KeyPress struct. However, the keycode field has - * been overloaded to hold the zDelta of the wheel. Set nbytes to - * 0 to prevent conversion of the keycode to a keysym in - * TkpGetString. [Bug 1118340]. - */ - event.x.type = MouseWheelEvent; event.x.xany.send_event = -1; event.key.nbytes = 0; |