summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authorculler <culler>2023-11-07 20:08:38 (GMT)
committerculler <culler>2023-11-07 20:08:38 (GMT)
commit8bdb67bc12553a955cef31caaf01f0f41a09f354 (patch)
tree8bccdedf09c749cc1d35f36dfe319978720560f3 /macosx
parent9bda6a9690126bd05e958983768caf99b11becb3 (diff)
downloadtk-8bdb67bc12553a955cef31caaf01f0f41a09f354.zip
tk-8bdb67bc12553a955cef31caaf01f0f41a09f354.tar.gz
tk-8bdb67bc12553a955cef31caaf01f0f41a09f354.tar.bz2
Implement touchpad events. See [de3bbbcb68]: macOS NSScrollWheel events not handled correctly by 8.7.
Diffstat (limited to 'macosx')
-rw-r--r--macosx/tkMacOSXMouseEvent.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c
index d4ed5ad..0cfa7d3 100644
--- a/macosx/tkMacOSXMouseEvent.c
+++ b/macosx/tkMacOSXMouseEvent.c
@@ -566,13 +566,18 @@ enum {
#define WHEEL_DELTA 120
#define WHEEL_DELAY 300000000
+#define WHEEL_INCREMENT 0.100006103515625
+
uint64_t wheelTick = clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW);
Bool timeout = (wheelTick - tsdPtr->wheelTickPrev) >= WHEEL_DELAY;
if (timeout) {
tsdPtr->vWheelAcc = tsdPtr->hWheelAcc = 0;
}
tsdPtr->wheelTickPrev = wheelTick;
- delta = [theEvent deltaY];
+ delta = [theEvent scrollingDeltaY];
+ if (![theEvent hasPreciseScrollingDeltas]) {
+ delta /= WHEEL_INCREMENT;
+ }
if (delta != 0.0) {
delta = (tsdPtr->vWheelAcc += delta);
if (timeout && fabs(delta) < 1.0) {
@@ -587,7 +592,10 @@ enum {
Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
}
}
- delta = [theEvent deltaX];
+ delta = [theEvent scrollingDeltaX];
+ if (![theEvent hasPreciseScrollingDeltas]) {
+ delta /= WHEEL_INCREMENT;
+ }
if (delta != 0.0) {
delta = (tsdPtr->hWheelAcc += delta);
if (timeout && fabs(delta) < 1.0) {