diff options
author | marc_culler <marc.culler@gmail.com> | 2023-11-27 17:02:20 (GMT) |
---|---|---|
committer | marc_culler <marc.culler@gmail.com> | 2023-11-27 17:02:20 (GMT) |
commit | 4cd583363c4980aacbd905f39eb33a7db39ae56b (patch) | |
tree | ff27168581ab59f9dcc27caadaa19f4bdbc48873 /win | |
parent | c60d0f8978d1ebd2ec490caa1464b450c70b9d9f (diff) | |
download | tk-4cd583363c4980aacbd905f39eb33a7db39ae56b.zip tk-4cd583363c4980aacbd905f39eb33a7db39ae56b.tar.gz tk-4cd583363c4980aacbd905f39eb33a7db39ae56b.tar.bz2 |
Use the serial field of TouchpadScroll events as a counter.
Diffstat (limited to 'win')
-rw-r--r-- | win/tkWinX.c | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/win/tkWinX.c b/win/tkWinX.c index d3a2d55..2d6fe1b 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -53,7 +53,14 @@ */ static int lastMod = 0; - + +/* + * The serial field of TouchpadScroll events is a counter for + * events of this type only. + */ + +static int scrollCounter = 0; + /* * imm.h is needed by HandleIMEComposition */ @@ -1142,22 +1149,22 @@ GenerateXEvent( /* * 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 - * EXTENDED_MASK 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]. + * set to MouseWheelEvent for low resolution scrolls and to + * TouchpadScroll for high resolution scroll events. The Y delta + * is stored in the low order 16 bits of the keycode field. 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) { /* High resolution. */ - event.x.type = MouseWheelEvent; + event.x.type = TouchpadScroll; event.x.xany.send_event = -1; event.key.nbytes = 0; - event.x.xkey.state = state | EXTENDED_MASK ; + event.x.xkey.state = state; + event.xany.serial = scrollCounter++; event.x.xkey.keycode = (unsigned int) delta; } else { event.x.type = MouseWheelEvent; @@ -1169,26 +1176,26 @@ GenerateXEvent( break; } case WM_MOUSEHWHEEL: { - + /* * 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 - * EXTENDEDMASK 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]. + * set to MouseWheelEvent for low resolution scrolls and to + * TouchpadScroll for high resolution scroll events. For low + * resolution scrolls the X delta is stored in the keycode field + * and For high resolution scrolls the X delta is in the high 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) { /* High resolution. */ - event.x.type = MouseWheelEvent; + event.x.type = TouchpadScroll; event.x.xany.send_event = -1; event.key.nbytes = 0; - event.x.xkey.state = state | EXTENDED_MASK ; + event.x.xkey.state = state; + event.xany.serial = scrollCounter++; event.x.xkey.keycode = (unsigned int)(-(delta << 16)); } else { event.x.type = MouseWheelEvent; |