Mercurial > minori
changeset 182:c413e475f496
dep/animia: various stylistic changes
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Mon, 04 Dec 2023 13:19:54 -0500 |
parents | d26cd2c00270 |
children | 01d259b9c89f |
files | dep/animia/CMakeLists.txt dep/animia/src/fd/proc.cc dep/animia/src/fd/win32.cc dep/animia/src/util/osx.cc dep/animia/src/win/quartz.mm |
diffstat | 5 files changed, 28 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/dep/animia/CMakeLists.txt Mon Dec 04 12:14:30 2023 -0500 +++ b/dep/animia/CMakeLists.txt Mon Dec 04 13:19:54 2023 -0500 @@ -30,6 +30,12 @@ # check anyway. if (HAVE_COREFOUNDATION) list(APPEND DEFINES HAVE_COREFOUNDATION) + + find_library(FOUNDATION_LIBRARY Foundation) + list(APPEND LIBRARIES ${FOUNDATION_LIBRARY}) + else() + message(STATUS "You don't have Core Foundation. How? What kind of voodoo magic did you do to cause this?") + message(WARNING "LaunchServices support will not be compiled.") endif() check_language(OBJCXX) @@ -38,10 +44,11 @@ list(APPEND SRC_FILES src/win/quartz.mm ) - find_library(FOUNDATION_LIBRARY Foundation) + + # we likely already have Foundation at this point. find_library(COREGRAPHICS_LIBRARY CoreGraphics) find_library(APPKIT_LIBRARY AppKit) - list(APPEND LIBRARIES ${FOUNDATION_LIBRARY} ${COREGRAPHICS_LIBRARY} ${APPKIT_LIBRARY}) + list(APPEND LIBRARIES ${COREGRAPHICS_LIBRARY} ${APPKIT_LIBRARY}) else() # NOT CMAKE_OBJCXX_COMPILER message(WARNING "An Objective-C++ compiler couldn't be found! Window enumeration support will not be compiled.") endif() # CMAKE_OBJCXX_COMPILER
--- a/dep/animia/src/fd/proc.cc Mon Dec 04 12:14:30 2023 -0500 +++ b/dep/animia/src/fd/proc.cc Mon Dec 04 13:19:54 2023 -0500 @@ -82,6 +82,8 @@ return false; // we got a bad result, i think } + out.resize(out.find('\0')); + return true; }
--- a/dep/animia/src/fd/win32.cc Mon Dec 04 12:14:30 2023 -0500 +++ b/dep/animia/src/fd/win32.cc Mon Dec 04 13:19:54 2023 -0500 @@ -32,8 +32,6 @@ * 32-bit PIDs, unlike SystemHandleInformation */ constexpr SYSTEM_INFORMATION_CLASS SystemExtendedHandleInformation = static_cast<SYSTEM_INFORMATION_CLASS>(0x40); - -/* more constants not in winternl.h */ constexpr NTSTATUS STATUS_INFO_LENGTH_MISMATCH = 0xC0000004UL; /* this is filled in at runtime because it's not guaranteed to be (and isn't)
--- a/dep/animia/src/util/osx.cc Mon Dec 04 12:14:30 2023 -0500 +++ b/dep/animia/src/util/osx.cc Mon Dec 04 13:19:54 2023 -0500 @@ -84,11 +84,13 @@ str.reset(rstr); } - result.reserve(CFStringGetMaximumSizeForEncoding(CFStringGetLength(str.get()), kCFStringEncodingUTF8) + 1); + result.resize(CFStringGetMaximumSizeForEncoding(CFStringGetLength(str.get()), kCFStringEncodingUTF8) + 1); if (!CFStringGetCString(str.get(), &result.front(), result.length(), result.length())) return false; + result.resize(result.find('\0')); + return true; } #endif // HAVE_COREFOUNDATION @@ -98,7 +100,11 @@ const int mib[3] = {CTL_KERN, KERN_PROCARGS2, static_cast<int>(pid)}; const size_t mib_size = sizeof(mib)/sizeof(*mib); - /* Get the initial size of the array */ + /* Get the initial size of the array + * + * NOTE: it IS possible for this value to change inbetween calls to sysctl(). + * Unfortunately, I couldn't care less about handling this. :) + */ size_t size; { int ret = sysctl((int*)mib, mib_size, nullptr, &size, nullptr, 0);
--- a/dep/animia/src/win/quartz.mm Mon Dec 04 12:14:30 2023 -0500 +++ b/dep/animia/src/win/quartz.mm Mon Dec 04 13:19:54 2023 -0500 @@ -1,3 +1,11 @@ +/* We actually DON'T need Objective-C for most of this file. + * GetWindowTitle() is the only function that really needs it. + * (and even then, we can use the C bindings for it...) + * + * However, being able to use the Foundation classes makes things + * so, so, so much easier, and so I've decided to make this file + * in Objective-C++. +*/ #include "animia/win/quartz.h" #include "animia.h" @@ -24,6 +32,7 @@ return true; } +/* This is really the only a*/ static bool GetWindowTitle(unsigned int wid, std::string& result) { NSWindow* window = [NSApp windowWithWindowNumber: wid]; if (!window)