summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2024-02-20 18:38:52 +0000
committerSadie Powell <sadie@witchery.services>2024-02-20 18:38:52 +0000
commitb478a1cb5351180cd39b5a01e1891bfd30af1659 (patch)
treefc336455008d1dbf73cf481c172f657469ca231e /src
parent1fb77e414db20d9c7dd5bd4bf0690733bd90fb30 (diff)
Make ModuleManager::SetPriority more readable.
Diffstat (limited to 'src')
-rw-r--r--src/modulemanager.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp
index f210593b8..2da87c96f 100644
--- a/src/modulemanager.cpp
+++ b/src/modulemanager.cpp
@@ -435,43 +435,62 @@ bool ModuleManager::SetPriority(Module *mod, Implementation i, Priority s, Modul
{
/* Dummy value */
case PRIORITY_DONTCARE:
+ {
swap = false;
break;
+ }
/* Module wants to be first, sod everything else */
case PRIORITY_FIRST:
+ {
swap_pos = 0;
break;
+ }
/* Module is submissive and wants to be last... awww. */
case PRIORITY_LAST:
+ {
if (EventHandlers[i].empty())
swap_pos = 0;
else
swap_pos = EventHandlers[i].size() - 1;
break;
+ }
/* Place this module after a set of other modules */
case PRIORITY_AFTER:
+ {
/* Find the latest possible position */
swap_pos = 0;
swap = false;
for (size_t x = 0, end = EventHandlers[i].size(); x != end; ++x)
+ {
for (size_t n = 0; n < sz; ++n)
+ {
if (modules[n] && EventHandlers[i][x] == modules[n] && x >= swap_pos && source <= swap_pos)
{
swap_pos = x;
swap = true;
}
+ }
+ }
break;
+ }
/* Place this module before a set of other modules */
case PRIORITY_BEFORE:
+ {
swap_pos = EventHandlers[i].size() - 1;
swap = false;
for (size_t x = 0, end = EventHandlers[i].size(); x != end; ++x)
+ {
for (size_t n = 0; n < sz; ++n)
+ {
if (modules[n] && EventHandlers[i][x] == modules[n] && x <= swap_pos && source >= swap_pos)
{
swap = true;
swap_pos = x;
}
+ }
+ }
+ break;
+ }
}
/* Do we need to swap? */