From 7c47bc265600c03cd4526e9cc6c3d4f1376453fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 6 Mar 2026 11:10:35 +0800 Subject: [PATCH] WM: honors `general.detectVersion` --- src/detection/wm/wm_apple.m | 43 +++++++++++++++++++---------------- src/detection/wm/wm_windows.c | 23 +++++++++++-------- 2 files changed, 36 insertions(+), 30 deletions(-) diff --git a/src/detection/wm/wm_apple.m b/src/detection/wm/wm_apple.m index a1421107d..a310f5774 100644 --- a/src/detection/wm/wm_apple.m +++ b/src/detection/wm/wm_apple.m @@ -36,32 +36,35 @@ const char* ffDetectWMPlugin(FFstrbuf* pluginName) !ffStrEqualsIgnCase(comm, "rectangle") ) continue; - char buf[PROC_PIDPATHINFO_MAXSIZE]; - int length = proc_pidpath(proc->kp_proc.p_pid, buf, ARRAY_SIZE(buf)); - if (length > 0) + if (instance.config.general.detectVersion) { - char* lastSlash = strrchr(buf, '/'); - if (lastSlash) + char buf[PROC_PIDPATHINFO_MAXSIZE]; + int length = proc_pidpath(proc->kp_proc.p_pid, buf, ARRAY_SIZE(buf)); + if (length > 0) { - *lastSlash = '\0'; - if (ffStrEndsWith(buf, ".app/Contents/MacOS")) + char* lastSlash = strrchr(buf, '/'); + if (lastSlash) { - lastSlash -= strlen("MacOS"); - strcpy(lastSlash, "Info.plist"); // X.app/Contents/Info.plist - NSError* error; - NSDictionary* dict = [NSDictionary dictionaryWithContentsOfURL:[NSURL fileURLWithPath:@(buf)] - error:&error]; - if (dict) + *lastSlash = '\0'; + if (ffStrEndsWith(buf, ".app/Contents/MacOS")) { - ffStrbufSetS(pluginName, [dict[@"CFBundleName"] UTF8String]); - NSString* version = dict[@"CFBundleShortVersionString"]; - if (version) + lastSlash -= strlen("MacOS"); + strcpy(lastSlash, "Info.plist"); // X.app/Contents/Info.plist + NSError* error; + NSDictionary* dict = [NSDictionary dictionaryWithContentsOfURL:[NSURL fileURLWithPath:@(buf)] + error:&error]; + if (dict) { - ffStrbufAppendC(pluginName, ' '); - ffStrbufAppendS(pluginName, version.UTF8String); - } + ffStrbufSetS(pluginName, [dict[@"CFBundleName"] UTF8String]); + NSString* version = dict[@"CFBundleShortVersionString"]; + if (version) + { + ffStrbufAppendC(pluginName, ' '); + ffStrbufAppendS(pluginName, version.UTF8String); + } - break; + break; + } } } } diff --git a/src/detection/wm/wm_windows.c b/src/detection/wm/wm_windows.c index c89339a7f..f8514f972 100644 --- a/src/detection/wm/wm_windows.c +++ b/src/detection/wm/wm_windows.c @@ -140,7 +140,7 @@ const char* ffDetectWMPlugin(FFstrbuf* pluginName) memcmp(ptr->ImageName.Buffer, L"FancyWM-GUI.exe", ptr->ImageName.Length) == 0 && isProcessTrusted((DWORD) (uintptr_t) ptr->UniqueProcessId, FF_PROCESS_TYPE_WINDOWS_STORE | FF_PROCESS_TYPE_GUI, filePath, sizeof(buffer)) ) { - if (ffGetFileVersion(filePath->Buffer, NULL, pluginName)) + if (instance.config.general.detectVersion && ffGetFileVersion(filePath->Buffer, NULL, pluginName)) ffStrbufPrependS(pluginName, "FancyWM "); else ffStrbufSetStatic(pluginName, "FancyWM"); @@ -150,7 +150,7 @@ const char* ffDetectWMPlugin(FFstrbuf* pluginName) memcmp(ptr->ImageName.Buffer, L"glazewm-watcher.exe", ptr->ImageName.Length) == 0 && isProcessTrusted((DWORD) (uintptr_t) ptr->UniqueProcessId, FF_PROCESS_TYPE_SIGNED | FF_PROCESS_TYPE_GUI, filePath, sizeof(buffer)) ) { - if (ffGetFileVersion(filePath->Buffer, NULL, pluginName)) + if (instance.config.general.detectVersion && ffGetFileVersion(filePath->Buffer, NULL, pluginName)) ffStrbufPrependS(pluginName, "GlazeWM "); else ffStrbufSetStatic(pluginName, "GlazeWM"); @@ -160,14 +160,17 @@ const char* ffDetectWMPlugin(FFstrbuf* pluginName) memcmp(ptr->ImageName.Buffer, L"komorebi.exe", ptr->ImageName.Length) == 0 && isProcessTrusted((DWORD) (uintptr_t) ptr->UniqueProcessId, FF_PROCESS_TYPE_CUI, filePath, sizeof(buffer)) ) { - FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateNWS(filePath->Length / sizeof(wchar_t), filePath->Buffer); - if (ffProcessAppendStdOut(pluginName, (char *const[]) { - path.chars, - "--version", - NULL, - }) == NULL) - ffStrbufSubstrBeforeFirstC(pluginName, '\n'); - else + if (instance.config.general.detectVersion) + { + FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateNWS(filePath->Length / sizeof(wchar_t), filePath->Buffer); + if (ffProcessAppendStdOut(pluginName, (char *const[]) { + path.chars, + "--version", + NULL, + }) == NULL) + ffStrbufSubstrBeforeFirstC(pluginName, '\n'); + } + if (pluginName->length == 0) ffStrbufSetStatic(pluginName, "Komorebi"); break; }