wip: sequoia bug

This commit is contained in:
lwouis
2025-04-27 18:31:13 +02:00
parent 397457cacb
commit 5411bdca1a
5 changed files with 47 additions and 2 deletions
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -259,4 +259,4 @@ func SLSWindowIteratorGetParentID(_ iterator: CFTypeRef) -> CGWindowID
func SLSWindowIteratorGetWindowID(_ iterator: CFTypeRef) -> CGWindowID
@_silgen_name("SLSWindowIteratorGetTags")
func SLSWindowIteratorGetTags(_ iterator: CFTypeRef) -> UInt
func SLSWindowIteratorGetTags(_ iterator: CFTypeRef) -> UInt
+3
View File
@@ -129,6 +129,9 @@ class Windows {
if list.count > ThumbnailsView.recycledViews.count {
ThumbnailsView.recycledViews.append(ThumbnailView())
}
var windowIds = list.compactMap { $0.cgWindowId }
let cgError = SLSRequestNotificationsForWindows(CGS_CONNECTION, &windowIds, windowIds.count);
Logger.error(cgError.rawValue, windowIds)
}
static func removeAndUpdateFocus(_ window: Window) {
+16 -1
View File
@@ -127,9 +127,14 @@ fileprivate func focusedWindowChanged(_ element: AXUIElement, _ pid: pid_t) thro
fileprivate func windowDestroyed(_ element: AXUIElement, _ pid: pid_t) throws {
let wid = try element.cgWindowId()
windowDestroyed_(wid, element, pid)
}
fileprivate func windowDestroyed_(_ wid: CGWindowID?, _ element: AXUIElement?, _ pid: pid_t?) {
DispatchQueue.main.async {
if let index = (Windows.list.firstIndex { $0.isEqualRobust(element, wid) }) {
if let index = (Windows.list.firstIndex { element == nil ? $0.cgWindowId == wid : $0.isEqualRobust(element!, wid) }) {
let window = Windows.list[index]
let pid = pid != nil ? pid : window.application.pid
Windows.removeAndUpdateFocus(window)
if window.application.addWindowlessWindowIfNeeded() != nil {
Applications.find(pid)?.focusedWindow = nil
@@ -199,3 +204,13 @@ func updateWindowSizeAndPositionAndFullscreen(_ element: AXUIElement, _ wid: CGW
}
}
}
let notifyCallback: NotifyCallback = { type, data, dataLength, context, cid in
Logger.error("-----", type)
if type == 804, let data {
// var wid: UInt32
// memcpy(&wid, &data, MemoryLayout<UInt32>.size)
let wid = data.load(as: UInt32.self)
windowDestroyed_(wid, nil, nil)
}
}
+4
View File
@@ -326,6 +326,10 @@ extension App: NSApplicationDelegate {
#if DEBUG
// self.showPreferencesWindow()
#endif
// if (workspace_is_macos_sequoia()) {
let cgError = SLSRegisterConnectionNotifyProc(CGS_CONNECTION, notifyCallback, NotifyEvent.windowDestroyed.rawValue, nil)
Logger.error(cgError.rawValue)
// }
}
}