summaryrefslogtreecommitdiffstats
path: root/win/tkWinX.c
diff options
context:
space:
mode:
authormarcc <marcc>2023-11-11 20:17:17 (GMT)
committermarcc <marcc>2023-11-11 20:17:17 (GMT)
commitef6e4da40e621eefc7b7b943a534529a0cb1a907 (patch)
tree92bd58e1f9ec9e4a7042cdd935d1650203503e7b /win/tkWinX.c
parentb7c0646739693134b8a50bfdbea4c111fcb023ec (diff)
downloadtk-ef6e4da40e621eefc7b7b943a534529a0cb1a907.zip
tk-ef6e4da40e621eefc7b7b943a534529a0cb1a907.tar.gz
tk-ef6e4da40e621eefc7b7b943a534529a0cb1a907.tar.bz2
Clean up.
Diffstat (limited to 'win/tkWinX.c')
-rw-r--r--win/tkWinX.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/win/tkWinX.c b/win/tkWinX.c
index 4b34a1c..9583335 100644
--- a/win/tkWinX.c
+++ b/win/tkWinX.c
@@ -20,6 +20,7 @@
# pragma comment (lib, "advapi32.lib")
#endif
+
/*
* The zmouse.h file includes the definition for WM_MOUSEWHEEL.
*/
@@ -35,6 +36,20 @@
#define WM_MOUSEHWHEEL 0x020E
#endif
+/* This flag is set in the state of the MouseWheelEvent to indicate
+ * that the value stored in the keycode field should be interpreted
+ * as the number of pixels to scroll. A WM_MOUSEWHEEL message sent
+ * by a trackpad contains the number of pixels as the delta value,
+ * while low precision scrollwheels always send an integer multiple
+ * of WHEELDELTA (= 120) as the delta value. We set this flag
+ * whenever the WM_MOUSEWHEEL delta is not a multiple of 120. This
+ * ignores the (rare) possibility that a trackpad might generate
+ * a message with delta a multiple of 120, intended to be interpreted
+ * as pixels. If that proves annoying it will need to be addressed.
+ */
+
+#define HiresScrollMask (1 << 9)
+
/*
* imm.h is needed by HandleIMEComposition
*/
@@ -1139,7 +1154,7 @@ GenerateXEvent(
event.key.nbytes = 0;
event.x.xkey.keycode = (unsigned int)delta;
if ( delta % 120 != 0) {
- event.x.xkey.state |= (1 << 9);
+ event.x.xkey.state |= HiresScrollMask;
}
break;
}
@@ -1164,7 +1179,7 @@ GenerateXEvent(
event.x.xkey.state |= ShiftMask;
event.x.xkey.keycode = delta;
if ( delta % 120 != 0) {
- event.x.xkey.state |= (1 << 9);
+ event.x.xkey.state |= HiresScrollMask;
}
break;
}