diff options
author | Akemi <der.richter@gmx.de> | 2017-07-26 21:08:14 +0200 |
---|---|---|
committer | Akemi <der.richter@gmx.de> | 2017-07-31 20:22:33 +0200 |
commit | b726f1eb9060bf9abbd83a06298c557e25557612 (patch) | |
tree | b04b6b8925e325652779fcb44ae82aee6a8f5541 /video | |
parent | 53188a14bf89e70b77139783230789330d8f571f (diff) | |
download | mpv-b726f1eb9060bf9abbd83a06298c557e25557612.tar.bz2 mpv-b726f1eb9060bf9abbd83a06298c557e25557612.tar.xz |
cocoa: distinguish between horizontal and vertical scroll
we need to switch the x and y deltas when Shift is being held because
macOS switches them around. otherwise we would get a horizontal scroll
on a vertical one and vice versa.
additional we switch from deltaX/Y to scrollingDeltaX/Y since the Apple
docs suggest it's the preferred way now. in my tests both reported the
same values on imprecise scrolls though.
Diffstat (limited to 'video')
-rw-r--r-- | video/out/cocoa/events_view.m | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/video/out/cocoa/events_view.m b/video/out/cocoa/events_view.m index b9b2bbb9b9..3162e5e9c9 100644 --- a/video/out/cocoa/events_view.m +++ b/video/out/cocoa/events_view.m @@ -268,8 +268,18 @@ [self preciseScroll:event]; } else { const int modifiers = [event modifierFlags]; - const int mpkey = ([event deltaX] + [event deltaY]) > 0 ? - MP_MOUSE_BTN3 : MP_MOUSE_BTN4; + const float deltaX = (modifiers & NSEventModifierFlagShift) ? + [event scrollingDeltaY] : [event scrollingDeltaX]; + const float deltaY = (modifiers & NSEventModifierFlagShift) ? + [event scrollingDeltaX] : [event scrollingDeltaY]; + int mpkey; + + if (fabs(deltaY) >= fabs(deltaX)) { + mpkey = deltaY > 0 ? MP_MOUSE_BTN3 : MP_MOUSE_BTN4; + } else { + mpkey = deltaX > 0 ? MP_MOUSE_BTN5 : MP_MOUSE_BTN6; + } + [self.adapter putKey:mpkey withModifiers:modifiers]; } } |