Mercurial > libanimone
diff include/animone/util/osx.h @ 4:cce3a81b03bf
dep/animone: make osx code a bit less hacky
it would be nice if macos actually provided a real API for getting
window titles (outside of the accessibility api). the accessibility
API is a real mess to work with; the user has to give permission to
access it under newer versions.
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Fri, 12 Apr 2024 05:21:45 -0400 |
parents | a76fa32bdc92 |
children |
line wrap: on
line diff
--- a/include/animone/util/osx.h Thu Apr 11 22:05:41 2024 -0400 +++ b/include/animone/util/osx.h Fri Apr 12 05:21:45 2024 -0400 @@ -4,35 +4,12 @@ #include "animone/types.h" #include <cstdint> #include <string> +#include <memory> #include <CoreFoundation/CoreFoundation.h> namespace animone::internal::osx::util { -template<typename T> -bool GetCFNumber(CFNumberRef num, T& result) { - if (!num) - return false; - - int64_t res; - if (!CFNumberGetValue(num, static_cast<CFNumberType>(4), &res)) - return false; - - result = static_cast<T>(res); - return true; -} - -template<typename T> -struct CFDeconstructor { - using pointer = T; - void operator()(pointer t) const { ::CFRelease(t); }; -}; - -template<typename T> -using CFPtr = vector<T, CFDecontructor<T>>; // type-id is vector<T, Alloc<T>> - -bool StringFromCFString(CFStringRef string, std::string& result); - bool GetProcessName(pid_t pid, std::string& result); } // namespace animone::internal::osx::util