From f2e7e81bda653c1f2cb3b27cf867e9195d184ddc Mon Sep 17 00:00:00 2001 From: Ken <21211439+kencu@users.noreply.github.com> Date: Fri, 25 Jan 2019 19:50:43 -0800 Subject: mac: add missing semicolon to macosx_compat.h fixes build on older systems --- osdep/macosx_compat.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'osdep') diff --git a/osdep/macosx_compat.h b/osdep/macosx_compat.h index 747aa159af..d5f8dab571 100644 --- a/osdep/macosx_compat.h +++ b/osdep/macosx_compat.h @@ -55,7 +55,7 @@ static const NSEventModifierFlags NSEventModifierFlagOption = NSAlternateKeyMask #if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_9) typedef NSUInteger NSModalResponse; -static const NSModalResponse NSModalResponseOK = NSFileHandlingPanelOKButton +static const NSModalResponse NSModalResponseOK = NSFileHandlingPanelOKButton; #endif #endif -- cgit v1.2.3 From ace61c120f18733f3cfc88273fdbad6fb1db5bc6 Mon Sep 17 00:00:00 2001 From: Akemi Date: Sun, 30 Sep 2018 11:36:14 +0200 Subject: cocoa-cb: use Swift Extensions for convenience preparations for the following commit. --- osdep/macOS_swift_extensions.swift | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 osdep/macOS_swift_extensions.swift (limited to 'osdep') diff --git a/osdep/macOS_swift_extensions.swift b/osdep/macOS_swift_extensions.swift new file mode 100644 index 0000000000..61e61aaffd --- /dev/null +++ b/osdep/macOS_swift_extensions.swift @@ -0,0 +1,28 @@ +/* + * This file is part of mpv. + * + * mpv is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * mpv is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with mpv. If not, see . + */ + +import Cocoa + +extension NSScreen { + + public var displayID: CGDirectDisplayID { + get { + return deviceDescription["NSScreenNumber"] as! CGDirectDisplayID + } + } + +} -- cgit v1.2.3 From 6ce570359aa06469d3ead822227058ec87c86b30 Mon Sep 17 00:00:00 2001 From: Akemi Date: Wed, 26 Sep 2018 15:33:34 +0200 Subject: cocoa-cb: add support for VOCTRL_GET_DISPLAY_NAMES --- osdep/macOS_swift_bridge.h | 8 ++++++++ osdep/macOS_swift_extensions.swift | 30 ++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) (limited to 'osdep') diff --git a/osdep/macOS_swift_bridge.h b/osdep/macOS_swift_bridge.h index 4204b514d1..f0b549ca40 100644 --- a/osdep/macOS_swift_bridge.h +++ b/osdep/macOS_swift_bridge.h @@ -49,3 +49,11 @@ static int SWIFT_KEY_MOUSE_LEAVE = MP_KEY_MOUSE_LEAVE; static int SWIFT_KEY_MOUSE_ENTER = MP_KEY_MOUSE_ENTER; static int SWIFT_KEY_STATE_DOWN = MP_KEY_STATE_DOWN; static int SWIFT_KEY_STATE_UP = MP_KEY_STATE_UP; + +// only used from Swift files and therefore seen as unused by the c compiler +static void SWIFT_TARRAY_STRING_APPEND(void *t, char ***a, int *i, char *s) __attribute__ ((unused)); + +static void SWIFT_TARRAY_STRING_APPEND(void *t, char ***a, int *i, char *s) +{ + MP_TARRAY_APPEND(t, *a, *i, s); +} diff --git a/osdep/macOS_swift_extensions.swift b/osdep/macOS_swift_extensions.swift index 61e61aaffd..14d217f589 100644 --- a/osdep/macOS_swift_extensions.swift +++ b/osdep/macOS_swift_extensions.swift @@ -25,4 +25,34 @@ extension NSScreen { } } + public var displayName: String? { + get { + var name: String? = nil + var object: io_object_t + var iter = io_iterator_t() + let matching = IOServiceMatching("IODisplayConnect") + let result = IOServiceGetMatchingServices(kIOMasterPortDefault, matching, &iter) + + if result != KERN_SUCCESS || iter == 0 { return nil } + + repeat { + object = IOIteratorNext(iter) + let info = IODisplayCreateInfoDictionary(object, IOOptionBits(kIODisplayOnlyPreferredName)).takeRetainedValue() as! [String:AnyObject] + if (info[kDisplayVendorID] as? UInt32 == CGDisplayVendorNumber(displayID) && + info[kDisplayProductID] as? UInt32 == CGDisplayModelNumber(displayID) && + info[kDisplaySerialNumber] as? UInt32 ?? 0 == CGDisplaySerialNumber(displayID)) + { + if let productNames = info["DisplayProductName"] as? [String:String], + let productName = productNames.first?.value + { + name = productName + break + } + } + } while object != 0 + + IOObjectRelease(iter) + return name + } + } } -- cgit v1.2.3