diff --git a/MonitorControl/AppDelegate.swift b/MonitorControl/AppDelegate.swift index ba96e8d..2772b82 100644 --- a/MonitorControl/AppDelegate.swift +++ b/MonitorControl/AppDelegate.swift @@ -89,18 +89,37 @@ class AppDelegate: NSObject, NSApplicationDelegate { func updateDisplays() { self.clearDisplays() - for screen in NSScreen.screens { - let name: String - if #available(OSX 10.15, *) { - name = screen.localizedName - } else { - name = screen.displayName ?? NSLocalizedString("Unknown", comment: "Unknown display name") + var onlineDisplayIDs = [CGDirectDisplayID](repeating: 0, count: 10) + var displayCount: UInt32 = 0 + + guard CGGetOnlineDisplayList(10, &onlineDisplayIDs, &displayCount) == .success else { + os_log("Unable to get display list.", type: .info) + return + } + + for onlineDisplayID in onlineDisplayIDs where onlineDisplayID != 0 { + var name: String = NSLocalizedString("Unknown", comment: "Unknown display name") + String(CGDisplaySerialNumber(onlineDisplayID)) + if let screen = NSScreen.getByDisplayID(displayID: onlineDisplayID) { + if #available(OSX 10.15, *) { + name = screen.localizedName + } else { + name = screen.displayName ?? name + } + } else if CGDisplayIsInHWMirrorSet(onlineDisplayID) != 0 || CGDisplayIsInMirrorSet(onlineDisplayID) != 0 { + if let mirroredScreen = NSScreen.getByDisplayID(displayID: CGDisplayMirrorsDisplay(onlineDisplayID)) { + name = NSLocalizedString("Mirror of", comment: "Shown in case a display mirrors an other display - like 'Mirror of DisplayName") + if #available(OSX 10.15, *) { + name = "" + name + " " + String(mirroredScreen.localizedName) + } else { + name = "" + name + " " + String(mirroredScreen.displayName ?? NSLocalizedString("Unknown", comment: "Unknown display name")) + } + } } - let id = screen.displayID - let vendorNumber = screen.vendorNumber - let modelNumber = screen.modelNumber + let id = onlineDisplayID + let vendorNumber = CGDisplayVendorNumber(onlineDisplayID) + let modelNumber = CGDisplayVendorNumber(onlineDisplayID) let display: Display - if screen.isBuiltin { + if CGDisplayIsBuiltin(onlineDisplayID) != 0 { display = InternalDisplay(id, name: name, vendorNumber: vendorNumber, modelNumber: modelNumber) } else { display = ExternalDisplay(id, name: name, vendorNumber: vendorNumber, modelNumber: modelNumber) diff --git a/MonitorControl/Info.plist b/MonitorControl/Info.plist index 1ccfe0f..fdd77de 100644 --- a/MonitorControl/Info.plist +++ b/MonitorControl/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString $(MARKETING_VERSION) CFBundleVersion - 1065 + 1097 LSApplicationCategoryType public.app-category.utilities LSMinimumSystemVersion diff --git a/MonitorControl/Support/de.lproj/Localizable.strings b/MonitorControl/Support/de.lproj/Localizable.strings index 42a62ed..a605129 100644 --- a/MonitorControl/Support/de.lproj/Localizable.strings +++ b/MonitorControl/Support/de.lproj/Localizable.strings @@ -31,6 +31,12 @@ /* Shown in the main prefs window */ "Keys" = "Tasten"; +/* Shown in case a display mirrors an other display - like 'Mirror of DisplayName */ +"Mirror of" = "Mirror of"; + +/* Mirrors */ +"Mirrors" = "Mirrors"; + /* Shown in the alert dialog */ "No" = "No"; diff --git a/MonitorControl/Support/en.lproj/Localizable.strings b/MonitorControl/Support/en.lproj/Localizable.strings index d16cd64..9900e94 100644 --- a/MonitorControl/Support/en.lproj/Localizable.strings +++ b/MonitorControl/Support/en.lproj/Localizable.strings @@ -31,6 +31,12 @@ /* Shown in the main prefs window */ "Keys" = "Keys"; +/* Shown in case a display mirrors an other display - like 'Mirror of DisplayName */ +"Mirror of" = "Mirror of"; + +/* Mirrors */ +"Mirrors" = "Mirrors"; + /* Shown in the alert dialog */ "No" = "No"; diff --git a/MonitorControl/Support/fr.lproj/Localizable.strings b/MonitorControl/Support/fr.lproj/Localizable.strings index dbb1a22..19900e3 100644 --- a/MonitorControl/Support/fr.lproj/Localizable.strings +++ b/MonitorControl/Support/fr.lproj/Localizable.strings @@ -31,6 +31,12 @@ /* Shown in the main prefs window */ "Keys" = "Touches"; +/* Shown in case a display mirrors an other display - like 'Mirror of DisplayName */ +"Mirror of" = "Mirror of"; + +/* Mirrors */ +"Mirrors" = "Mirrors"; + /* Shown in the alert dialog */ "No" = "No"; diff --git a/MonitorControl/Support/it.lproj/Localizable.strings b/MonitorControl/Support/it.lproj/Localizable.strings index 50d4a61..7972cf1 100644 --- a/MonitorControl/Support/it.lproj/Localizable.strings +++ b/MonitorControl/Support/it.lproj/Localizable.strings @@ -31,6 +31,12 @@ /* Shown in the main prefs window */ "Keys" = "Tasti"; +/* Shown in case a display mirrors an other display - like 'Mirror of DisplayName */ +"Mirror of" = "Mirror of"; + +/* Mirrors */ +"Mirrors" = "Mirrors"; + /* Shown in the alert dialog */ "No" = "No"; diff --git a/MonitorControl/Support/ja.lproj/Localizable.strings b/MonitorControl/Support/ja.lproj/Localizable.strings index 8776ebd..c47b9de 100644 --- a/MonitorControl/Support/ja.lproj/Localizable.strings +++ b/MonitorControl/Support/ja.lproj/Localizable.strings @@ -31,6 +31,12 @@ /* Shown in the main prefs window */ "Keys" = "キー"; +/* Shown in case a display mirrors an other display - like 'Mirror of DisplayName */ +"Mirror of" = "Mirror of"; + +/* Mirrors */ +"Mirrors" = "Mirrors"; + /* Shown in the alert dialog */ "No" = "No"; diff --git a/MonitorControl/Support/pl.lproj/Localizable.strings b/MonitorControl/Support/pl.lproj/Localizable.strings index 62e1538..e7cc8c0 100644 --- a/MonitorControl/Support/pl.lproj/Localizable.strings +++ b/MonitorControl/Support/pl.lproj/Localizable.strings @@ -31,6 +31,12 @@ /* Shown in the main prefs window */ "Keys" = "Klawisze"; +/* Shown in case a display mirrors an other display - like 'Mirror of DisplayName */ +"Mirror of" = "Mirror of"; + +/* Mirrors */ +"Mirrors" = "Mirrors"; + /* Shown in the alert dialog */ "No" = "Nie"; diff --git a/MonitorControl/Support/ru.lproj/Localizable.strings b/MonitorControl/Support/ru.lproj/Localizable.strings index b5f3081..a260ab5 100644 --- a/MonitorControl/Support/ru.lproj/Localizable.strings +++ b/MonitorControl/Support/ru.lproj/Localizable.strings @@ -31,6 +31,12 @@ /* Shown in the main prefs window */ "Keys" = "Сочетания клавиш"; +/* Shown in case a display mirrors an other display - like 'Mirror of DisplayName */ +"Mirror of" = "Mirror of"; + +/* Mirrors */ +"Mirrors" = "Mirrors"; + /* Shown in the alert dialog */ "No" = "No"; diff --git a/MonitorControl/Support/uk.lproj/Localizable.strings b/MonitorControl/Support/uk.lproj/Localizable.strings index c150714..1c5604c 100644 --- a/MonitorControl/Support/uk.lproj/Localizable.strings +++ b/MonitorControl/Support/uk.lproj/Localizable.strings @@ -31,6 +31,12 @@ /* Shown in the main prefs window */ "Keys" = "Клавіші"; +/* Shown in case a display mirrors an other display - like 'Mirror of DisplayName */ +"Mirror of" = "Mirror of"; + +/* Mirrors */ +"Mirrors" = "Mirrors"; + /* Shown in the alert dialog */ "No" = "No"; diff --git a/MonitorControl/Support/zh-Hans.lproj/Localizable.strings b/MonitorControl/Support/zh-Hans.lproj/Localizable.strings index d35f1bc..cb36d6a 100644 --- a/MonitorControl/Support/zh-Hans.lproj/Localizable.strings +++ b/MonitorControl/Support/zh-Hans.lproj/Localizable.strings @@ -31,6 +31,12 @@ /* Shown in the main prefs window */ "Keys" = "快捷键"; +/* Shown in case a display mirrors an other display - like 'Mirror of DisplayName */ +"Mirror of" = "Mirror of"; + +/* Mirrors */ +"Mirrors" = "Mirrors"; + /* Shown in the alert dialog */ "No" = "No"; diff --git a/MonitorControlHelper/Info.plist b/MonitorControlHelper/Info.plist index 2f7af92..109c2cc 100644 --- a/MonitorControlHelper/Info.plist +++ b/MonitorControlHelper/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString $(MARKETING_VERSION) CFBundleVersion - 1065 + 1097 LSApplicationCategoryType public.app-category.utilities LSBackgroundOnly