mirror of https://github.com/mpv-player/mpv
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.
This commit is contained in:
parent
53188a14bf
commit
b726f1eb90
|
@ -268,8 +268,18 @@
|
||||||
[self preciseScroll:event];
|
[self preciseScroll:event];
|
||||||
} else {
|
} else {
|
||||||
const int modifiers = [event modifierFlags];
|
const int modifiers = [event modifierFlags];
|
||||||
const int mpkey = ([event deltaX] + [event deltaY]) > 0 ?
|
const float deltaX = (modifiers & NSEventModifierFlagShift) ?
|
||||||
MP_MOUSE_BTN3 : MP_MOUSE_BTN4;
|
[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];
|
[self.adapter putKey:mpkey withModifiers:modifiers];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue