comparison dep/animia/src/animia.cc @ 236:4d461ef7d424

HUGE UPDATE: convert build system to autotools why? because cmake sucks :)
author Paper <mrpapersonic@gmail.com>
date Fri, 19 Jan 2024 00:24:02 -0500
parents 031a257ee019
children
comparison
equal deleted inserted replaced
235:593108b3d555 236:4d461ef7d424
25 return true; 25 return true;
26 26
27 return false; 27 return false;
28 } 28 }
29 29
30 static bool IsWindowInList(const Player& player, const std::string& name) { 30 static bool IsWindowInList(const Player& player, const Window& window) {
31 // if (util::CheckPattern(player.window_title_format, window.text))
32 // return true;
33
31 for (const auto& pattern : player.windows) 34 for (const auto& pattern : player.windows)
32 if (util::CheckPattern(pattern, name)) 35 if (util::CheckPattern(pattern, window.class_name))
33 return true; 36 return true;
34 37
35 return false; 38 return false;
36 } 39 }
37 40
63 }; 66 };
64 67
65 if (!internal::EnumerateOpenProcesses(process_proc)) 68 if (!internal::EnumerateOpenProcesses(process_proc))
66 return false; 69 return false;
67 70
68 /* Then add our cool windows.
69 Note: X11 is stupid and there's no reliable way to get a PID from a given window.
70 This is because some windows might not even have a process attached to them.
71 We should set the PID of the process if we can get it, but that'll be for when
72 I can actually be arsed to implement the X11 backend. */
73 auto window_proc = [&](const Process& process, const Window& window) -> bool { 71 auto window_proc = [&](const Process& process, const Window& window) -> bool {
74 for (const auto& player : players) { 72 for (const auto& player : players) {
75 if (!internal::PlayerHasStrategy(player, Strategy::WindowTitle)) 73 if (internal::IsWindowInList(player, window))
76 continue; 74 results.push_back({ResultType::Window, player, process, window, {}});
75 }
77 76
78 if (!internal::IsWindowInList(player, window.class_name))
79 continue;
80
81 results.push_back({ResultType::Window, player, process, window, {}});
82 break;
83 }
84 return true; 77 return true;
85 }; 78 };
86 79
87 if (!internal::EnumerateWindows(window_proc)) 80 if (!internal::EnumerateWindows(window_proc))
88 return false; 81 return false;