diff options
author | marc_culler <marc.culler@gmail.com> | 2023-11-22 03:31:45 (GMT) |
---|---|---|
committer | marc_culler <marc.culler@gmail.com> | 2023-11-22 03:31:45 (GMT) |
commit | 35f3b55d406eb50ce5da2d70ff50cba959f1f139 (patch) | |
tree | 5891e2105f5924feb403746751649cf38b8e8856 /macosx | |
parent | b0d31264c787b4be2ebc7c76087cab702a2a5aed (diff) | |
download | tk-35f3b55d406eb50ce5da2d70ff50cba959f1f139.zip tk-35f3b55d406eb50ce5da2d70ff50cba959f1f139.tar.gz tk-35f3b55d406eb50ce5da2d70ff50cba959f1f139.tar.bz2 |
Fix the low resolution events.
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/tkMacOSXMouseEvent.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c index 36ed501..b6e55eb 100644 --- a/macosx/tkMacOSXMouseEvent.c +++ b/macosx/tkMacOSXMouseEvent.c @@ -543,7 +543,8 @@ enum { Tk_UpdatePointer(target, global.x, global.y, state); } } else { - unsigned int delta; + int delta; + CGFloat Delta; Bool deltaIsPrecise = [theEvent hasPreciseScrollingDeltas]; XEvent xEvent = {0}; xEvent.xbutton.x = win_x; @@ -565,19 +566,23 @@ enum { Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL); } } else { - delta = (unsigned int)(int)[theEvent scrollingDeltaY]; - if (delta != 0.0) { + /* + * A low precision scroll is 120 or -120 wheel units per click. + * Each click generates one event. + */ + Delta = [theEvent scrollingDeltaY]; + if (Delta != 0.0) { xEvent.type = MouseWheelEvent; xEvent.xbutton.state = state; - xEvent.xkey.keycode = delta > 0 ? 120 : -120; + xEvent.xkey.keycode = Delta > 0.0 ? 120 : -120; xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin)); Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL); } - delta = (unsigned int)(int)[theEvent scrollingDeltaX]; - if (delta != 0.0) { + Delta = [theEvent scrollingDeltaX]; + if (Delta != 0.0) { xEvent.type = MouseWheelEvent; xEvent.xbutton.state = state | ShiftMask; - xEvent.xkey.keycode = delta > 0 ? 120 : -120; + xEvent.xkey.keycode = Delta > 0 ? 120 : -120; xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin)); Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL); } |