mirror of https://github.com/mpv-player/mpv
mac: report modifier keys on precise scrolling
modifier keys weren't reported when using the trackpad to scroll. Fixes #11195
This commit is contained in:
parent
aaff9edf57
commit
f551a9da34
|
@ -67,8 +67,8 @@ class MPVHelper {
|
||||||
mp_input_set_mouse_pos(input, Int32(pos.x), Int32(pos.y))
|
mp_input_set_mouse_pos(input, Int32(pos.x), Int32(pos.y))
|
||||||
}
|
}
|
||||||
|
|
||||||
func putAxis(_ mpkey: Int32, delta: Double) {
|
func putAxis(_ mpkey: Int32, modifiers: NSEvent.ModifierFlags, delta: Double) {
|
||||||
mp_input_put_wheel(input, mpkey, delta)
|
mp_input_put_wheel(input, mpkey | mapModifier(modifiers), delta)
|
||||||
}
|
}
|
||||||
|
|
||||||
func nextChangedOption(property: inout UnsafeMutableRawPointer?) -> Bool {
|
func nextChangedOption(property: inout UnsafeMutableRawPointer?) -> Bool {
|
||||||
|
@ -111,6 +111,27 @@ class MPVHelper {
|
||||||
free(UnsafeMutablePointer(mutating: cCmd))
|
free(UnsafeMutablePointer(mutating: cCmd))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func mapModifier(_ modifiers: NSEvent.ModifierFlags) -> Int32 {
|
||||||
|
var mask: UInt32 = 0;
|
||||||
|
|
||||||
|
if modifiers.contains(.shift) {
|
||||||
|
mask |= MP_KEY_MODIFIER_SHIFT
|
||||||
|
}
|
||||||
|
if modifiers.contains(.control) {
|
||||||
|
mask |= MP_KEY_MODIFIER_CTRL
|
||||||
|
}
|
||||||
|
if modifiers.contains(.command) {
|
||||||
|
mask |= MP_KEY_MODIFIER_META
|
||||||
|
}
|
||||||
|
if modifiers.rawValue & UInt(NX_DEVICELALTKEYMASK) != 0 ||
|
||||||
|
modifiers.rawValue & UInt(NX_DEVICERALTKEYMASK) != 0 && !mp_input_use_alt_gr(input)
|
||||||
|
{
|
||||||
|
mask |= MP_KEY_MODIFIER_ALT
|
||||||
|
}
|
||||||
|
|
||||||
|
return Int32(mask)
|
||||||
|
}
|
||||||
|
|
||||||
// (__bridge void*)
|
// (__bridge void*)
|
||||||
class func bridge<T: AnyObject>(obj: T) -> UnsafeMutableRawPointer {
|
class func bridge<T: AnyObject>(obj: T) -> UnsafeMutableRawPointer {
|
||||||
return UnsafeMutableRawPointer(Unmanaged.passUnretained(obj).toOpaque())
|
return UnsafeMutableRawPointer(Unmanaged.passUnretained(obj).toOpaque())
|
||||||
|
|
|
@ -227,7 +227,7 @@ class View: NSView {
|
||||||
cmd = delta > 0 ? SWIFT_WHEEL_LEFT : SWIFT_WHEEL_RIGHT
|
cmd = delta > 0 ? SWIFT_WHEEL_LEFT : SWIFT_WHEEL_RIGHT
|
||||||
}
|
}
|
||||||
|
|
||||||
mpv?.putAxis(cmd, delta: abs(delta))
|
mpv?.putAxis(cmd, modifiers: event.modifierFlags, delta: abs(delta))
|
||||||
}
|
}
|
||||||
|
|
||||||
override func scrollWheel(with event: NSEvent) {
|
override func scrollWheel(with event: NSEvent) {
|
||||||
|
|
Loading…
Reference in New Issue