summaryrefslogtreecommitdiffstats
path: root/osdep
diff options
context:
space:
mode:
authorder richter <der.richter@gmx.de>2023-11-29 01:18:53 +0100
committerder richter <der.richter@gmx.de>2023-12-02 14:59:59 +0100
commitf551a9da3471fcb2568e9c4d031e2ffb867e35a8 (patch)
treeec457608eff3e599407f973be6f2b7e8f75b456c /osdep
parentaaff9edf57bd9a7911bb4da172fbde9ed393f05e (diff)
downloadmpv-f551a9da3471fcb2568e9c4d031e2ffb867e35a8.tar.bz2
mpv-f551a9da3471fcb2568e9c4d031e2ffb867e35a8.tar.xz
mac: report modifier keys on precise scrolling
modifier keys weren't reported when using the trackpad to scroll. Fixes #11195
Diffstat (limited to 'osdep')
-rw-r--r--osdep/macos/mpv_helper.swift25
1 files changed, 23 insertions, 2 deletions
diff --git a/osdep/macos/mpv_helper.swift b/osdep/macos/mpv_helper.swift
index 6e5a80dc89..532a5f723c 100644
--- a/osdep/macos/mpv_helper.swift
+++ b/osdep/macos/mpv_helper.swift
@@ -67,8 +67,8 @@ class MPVHelper {
mp_input_set_mouse_pos(input, Int32(pos.x), Int32(pos.y))
}
- func putAxis(_ mpkey: Int32, delta: Double) {
- mp_input_put_wheel(input, mpkey, delta)
+ func putAxis(_ mpkey: Int32, modifiers: NSEvent.ModifierFlags, delta: Double) {
+ mp_input_put_wheel(input, mpkey | mapModifier(modifiers), delta)
}
func nextChangedOption(property: inout UnsafeMutableRawPointer?) -> Bool {
@@ -111,6 +111,27 @@ class MPVHelper {
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*)
class func bridge<T: AnyObject>(obj: T) -> UnsafeMutableRawPointer {
return UnsafeMutableRawPointer(Unmanaged.passUnretained(obj).toOpaque())