From 10552a017a0e223b561ead2fdea241ff54492cfe Mon Sep 17 00:00:00 2001 From: Mariusz Bieniek Date: Mon, 11 Nov 2019 22:52:01 +0100 Subject: [PATCH] fix: code compile compatibility with old macos - .zero in Int/Int32/UInt32 is missing here --- alt-tab-macos/logic/CoreGraphicsApis.swift | 2 +- alt-tab-macos/logic/SystemPermissions.swift | 2 +- alt-tab-macos/ui/Application.swift | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/alt-tab-macos/logic/CoreGraphicsApis.swift b/alt-tab-macos/logic/CoreGraphicsApis.swift index eed0a1d4..7d4eb5fb 100644 --- a/alt-tab-macos/logic/CoreGraphicsApis.swift +++ b/alt-tab-macos/logic/CoreGraphicsApis.swift @@ -6,7 +6,7 @@ class CoreGraphicsApis { return (CGWindowListCopyWindowInfo([.excludeDesktopElements, .optionOnScreenOnly], kCGNullWindowID) as! [NSDictionary]) .filter { // workaround: filtering this criteria seems to remove non-windows UI elements - let isWindowNotMenubarOrOthers = value($0, kCGWindowLayer, Int.zero) == 0 + let isWindowNotMenubarOrOthers = value($0, kCGWindowLayer, Int(0)) == 0 let windowBounds = CGRect(dictionaryRepresentation: value($0, kCGWindowBounds, [:] as CFDictionary))! // workaround: some apps like chrome use a window to implement the search popover let isReasonablyBig = windowBounds.width > Preferences.minimumWindowSize && windowBounds.height > Preferences.minimumWindowSize diff --git a/alt-tab-macos/logic/SystemPermissions.swift b/alt-tab-macos/logic/SystemPermissions.swift index 9cb7b366..55c8a280 100644 --- a/alt-tab-macos/logic/SystemPermissions.swift +++ b/alt-tab-macos/logic/SystemPermissions.swift @@ -14,7 +14,7 @@ class SystemPermissions { static func ensureScreenRecordingCheckboxIsChecked() { let firstWindow = CoreGraphicsApis.windows()[0] - let windowNumber = CoreGraphicsApis.value(firstWindow, kCGWindowNumber, CGWindowID.zero) + let windowNumber = CoreGraphicsApis.value(firstWindow, kCGWindowNumber, UInt32(0)) if CoreGraphicsApis.image(windowNumber) == nil { debugPrint("Before using this app, you need to give permission in System Preferences > Security & Privacy > Privacy > Screen Recording.", "Please authorize and re-launch.", diff --git a/alt-tab-macos/ui/Application.swift b/alt-tab-macos/ui/Application.swift index 1eb1c111..6405cf7b 100644 --- a/alt-tab-macos/ui/Application.swift +++ b/alt-tab-macos/ui/Application.swift @@ -74,10 +74,10 @@ class Application: NSApplication, NSApplicationDelegate, NSWindowDelegate { // we rely on the fact that CG and AX APIs arrays follow the same order to match objects from both APIs var pidAndCurrentIndex: [pid_t: Int] = [:] for cgWindow in CoreGraphicsApis.windows() { - let cgId = CoreGraphicsApis.value(cgWindow, kCGWindowNumber, CGWindowID.zero) + let cgId = CoreGraphicsApis.value(cgWindow, kCGWindowNumber, UInt32(0)) let cgTitle = CoreGraphicsApis.value(cgWindow, kCGWindowName, "") let cgOwnerName = CoreGraphicsApis.value(cgWindow, kCGWindowOwnerName, "") - let cgOwnerPid = CoreGraphicsApis.value(cgWindow, kCGWindowOwnerPID, pid_t.zero) + let cgOwnerPid = CoreGraphicsApis.value(cgWindow, kCGWindowOwnerPID, Int32(0)) let i = pidAndCurrentIndex.index(forKey: cgOwnerPid) pidAndCurrentIndex[cgOwnerPid] = (i == nil ? 0 : pidAndCurrentIndex[i!].value + 1) let axWindows_ = AccessibilityApis.windows(cgOwnerPid)