From 89e4403cc8725df79ef18428eba944c20eb260aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 2 Jan 2025 10:37:27 +0800 Subject: [PATCH] WM (macOS): add WindowServer version detection --- CMakeLists.txt | 2 +- src/detection/wm/{wm_apple.c => wm_apple.m} | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) rename src/detection/wm/{wm_apple.c => wm_apple.m} (66%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b552b45e..d4b1cd98d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -922,7 +922,7 @@ elseif(APPLE) src/detection/users/users_linux.c src/detection/wallpaper/wallpaper_apple.m src/detection/wifi/wifi_apple.m - src/detection/wm/wm_apple.c + src/detection/wm/wm_apple.m src/detection/de/de_nosupport.c src/detection/wmtheme/wmtheme_apple.m src/detection/camera/camera_apple.m diff --git a/src/detection/wm/wm_apple.c b/src/detection/wm/wm_apple.m similarity index 66% rename from src/detection/wm/wm_apple.c rename to src/detection/wm/wm_apple.m index dca3b600b..c2395d811 100644 --- a/src/detection/wm/wm_apple.c +++ b/src/detection/wm/wm_apple.m @@ -5,6 +5,7 @@ #include "util/stringUtils.h" #include +#import const char* ffDetectWMPlugin(FFstrbuf* pluginName) { @@ -39,7 +40,18 @@ const char* ffDetectWMPlugin(FFstrbuf* pluginName) return NULL; } -const char* ffDetectWMVersion(FF_MAYBE_UNUSED const FFstrbuf* wmName, FF_MAYBE_UNUSED FFstrbuf* result, FF_MAYBE_UNUSED FFWMOptions* options) +const char* ffDetectWMVersion(const FFstrbuf* wmName, FFstrbuf* result, FF_MAYBE_UNUSED FFWMOptions* options) { - return "Not supported on this platform"; + if (!wmName) + return "No WM detected"; + + if (ffStrbufEqualS(wmName, "WindowServer")) + { + NSError* error; + NSDictionary* dict = [NSDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:@"file:///System/Library/CoreServices/WindowManager.app/Contents/version.plist"] + error:&error]; + ffStrbufInitS(result, ((NSString*) dict[@"CFBundleVersion"]).UTF8String); + } + + return NULL; }