diff dep/animone/src/animone.cc @ 266:1a6a5d3a94cd

dep/animone: make bsd.cc and x11.cc actually work apparently I broke these, and even now the x11 code *still* doesn't want to work correctly (at least on FreeBSD). half of the PID response codes are just 0 or the PID for the X server itself... wtf? maybe dwm just doesn't support the XRes extension, or I'm just stupid. i don't know.
author Paper <paper@paper.us.eu.org>
date Thu, 11 Apr 2024 22:05:41 -0400
parents 862d0d8619f6
children b1f625b0227c
line wrap: on
line diff
--- a/dep/animone/src/animone.cc	Thu Apr 11 10:22:05 2024 -0400
+++ b/dep/animone/src/animone.cc	Thu Apr 11 22:05:41 2024 -0400
@@ -9,19 +9,15 @@
 #include <string>
 #include <vector>
 
+#include <iostream>
+
 namespace animone {
 
 namespace internal {
 
-static bool IsExecutableInList(const Player& player, const std::string& name) {
-	std::string stem;
-#ifdef WIN32
-	if (!util::Stem(name, stem))
-#endif
-		stem = name;
-
+static bool IsExecutableInList(const Player& player, const Process& proc) {
 	for (const auto& pattern : player.executables)
-		if (util::CheckPattern(pattern, stem))
+		if (util::CheckPattern(pattern, proc.name))
 			return true;
 
 	return false;
@@ -47,28 +43,27 @@
 
 bool GetResults(const std::vector<Player>& players, std::vector<Result>& results) {
 	auto window_proc = [&](const Process& process, const Window& window) -> bool {
-		for (const auto& player : players) {
-			if (internal::IsWindowInList(player, window))
+		for (const auto& player : players)
+			if (internal::IsWindowInList(player, window) && internal::IsExecutableInList(player, process))
 				results.push_back({player, process, window, {}});
-		}
 
 		return true;
 	};
 
-	if (internal::EnumerateWindows(window_proc))
-		return internal::ApplyStrategies(results);
+	if (internal::EnumerateWindows(window_proc) && internal::ApplyStrategies(results))
+		return true;
 
 	/* fallback, enumerate over open processes instead */
 	auto process_proc = [&](const Process& process) -> bool {
 		for (const auto& player : players)
-			if (internal::IsExecutableInList(player, process.name))
+			if (internal::IsExecutableInList(player, process))
 				results.push_back({player, process, {}, {}});
 
 		return true;
 	};
 
-	if (internal::EnumerateOpenProcesses(process_proc))
-		return internal::ApplyStrategies(results);
+	if (internal::EnumerateOpenProcesses(process_proc) && internal::ApplyStrategies(results))
+		return true;
 
 	return false;
 }