# HG changeset patch # User Paper # Date 1713148130 14400 # Node ID f80b3c3ec7f05ec2cbc4206a4c6b2de221ea030b # Parent f26b08274dcfdef9cfa4173210a6a3ef0a19d87e dep/animone: make OS X code build diff -r f26b08274dcf -r f80b3c3ec7f0 src/win/quartz.cc --- a/src/win/quartz.cc Fri Apr 12 19:13:50 2024 -0400 +++ b/src/win/quartz.cc Sun Apr 14 22:28:50 2024 -0400 @@ -18,7 +18,13 @@ namespace animone::internal::quartz { template -using CFPtr = std::unique_ptr>; +struct CFDeconstructor { + using pointer = T; + void operator()(pointer t) const { ::CFRelease(t); }; +}; + +template +using CFPtr = std::unique_ptr>; #if __LP64__ typedef long NSInteger; @@ -100,23 +106,17 @@ return true; } -template -struct CFDeconstructor { - using pointer = T; - void operator()(pointer t) const { ::CFRelease(t); }; -}; - static bool GetWindowTitleAccessibility(unsigned int wid, pid_t pid, std::string& result) { CGRect bounds = {0}; { const CGWindowID wids[1] = {wid}; CFPtr arr(CFArrayCreate(kCFAllocatorDefault, (CFTypeRef*)wids, 1, NULL)); - CFPtr dicts(CGWindowListCreateDescriptionFromArray(arr)); + CFPtr dicts(CGWindowListCreateDescriptionFromArray(arr.get())); if (!dicts.get() || CFArrayGetCount(dicts.get()) < 1) return false; - CFDictionaryRef dict = reinterpret_cast(CFArrayGetValueAtIndex(dicts, 0)); + CFDictionaryRef dict = reinterpret_cast(CFArrayGetValueAtIndex(dicts.get(), 0)); if (!dict) return false; @@ -151,7 +151,7 @@ if (AXUIElementCopyAttributeValue(window, kAXPositionAttribute, reinterpret_cast(&val)) == kAXErrorSuccess) { CGPoint point; - if (!AXValueGetValue(val, kAXValueTypeCGPoint, reinterpret_cast(&point)) || + if (!AXValueGetValue(val, kAXValueCGPointType, reinterpret_cast(&point)) || (point.x != bounds.origin.x || point.y != bounds.origin.y)) { CFRelease(val); continue; @@ -166,7 +166,7 @@ if (AXUIElementCopyAttributeValue(window, kAXSizeAttribute, reinterpret_cast(&val)) == kAXErrorSuccess) { CGSize size; - if (!AXValueGetValue(val, kAXValueTypeCGSize, reinterpret_cast(&size)) || + if (!AXValueGetValue(val, kAXValueCGSizeType, reinterpret_cast(&size)) || (size.width != bounds.size.width || size.height != bounds.size.height)) { CFRelease(val); continue; @@ -211,7 +211,7 @@ static bool GetProcessBundleIdentifierNew(pid_t pid, std::string& result) { /* 10.6 and higher */ const id app = - cls_send(objc_getClass("NSRunningApplication"), sel_getUid("runningApplicationWithProcessIdentifier:"), pid); + cls_send((Class)objc_getClass("NSRunningApplication"), sel_getUid("runningApplicationWithProcessIdentifier:"), pid); if (!app) return false; @@ -228,11 +228,11 @@ if (GetProcessForPID(pid, &psn)) return false; - CFPtr info = ProcessInformationCopyDictionary(psn, kProcessDictionaryIncludeAllInformationMask); + CFPtr info(ProcessInformationCopyDictionary(&psn, kProcessDictionaryIncludeAllInformationMask)); if (!info) return false; - CFStringRef value = reinterpret_cast(CFDictionaryGetValue(dict, CFSTR("CFBundleIdentifier"))); + CFStringRef value = reinterpret_cast(CFDictionaryGetValue(info.get(), CFSTR("CFBundleIdentifier"))); if (!value) return false; @@ -247,7 +247,7 @@ if (GetProcessBundleIdentifierNew(pid, result)) return true; - return GetProcessBundleIdentifierOld(); + return GetProcessBundleIdentifierOld(pid, result); } bool EnumerateWindows(window_proc_t window_proc) {