fix: occasional crash when focusing a window (closes #459)

This commit is contained in:
Louis Pontoise authored and lwouis committed 2020-07-22 23:19:45 +09:00
1 parent 6df92da76f
commit 19be9a174a
1 file changed
+5 -2
+5 -2
View File
@@ -166,8 +166,11 @@ class Window {
memset(&bytes1[0x20], 0xFF, 0x10)
memcpy(&bytes2[0x3c], &cgWindowId, MemoryLayout<UInt32>.size)
memset(&bytes2[0x20], 0xFF, 0x10)
SLPSPostEventRecordTo(&psn_, &(UnsafeMutablePointer(mutating: UnsafePointer<UInt8>(bytes1)).pointee))
SLPSPostEventRecordTo(&psn_, &(UnsafeMutablePointer(mutating: UnsafePointer<UInt8>(bytes2)).pointee))
[bytes1, bytes2].forEach { bytes in
_ = bytes.withUnsafeBufferPointer() { pointer in
SLPSPostEventRecordTo(&psn_, &UnsafeMutablePointer(mutating: pointer.baseAddress)!.pointee)
}
}
}
// for some windows (e.g. Slack), the AX API doesn't return a title; we try CG API; finally we resort to the app name