Skip to content

Commit

Permalink
fix: code compile compatibility with old macos
Browse files Browse the repository at this point in the history
- .zero in Int/Int32/UInt32 is missing here
  • Loading branch information
gingerr authored and lwouis committed Nov 12, 2019
1 parent bdb51b6 commit 10552a0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion alt-tab-macos/logic/CoreGraphicsApis.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion alt-tab-macos/logic/SystemPermissions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
4 changes: 2 additions & 2 deletions alt-tab-macos/ui/Application.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 10552a0

Please sign in to comment.