summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorItsOhen <TNordfeldt@gmail.com>2025-09-26 18:19:53 +0200
committerGitHub <noreply@github.com>2025-09-26 18:19:53 +0200
commitae445606e26020225e50d71e8ffd5282f68a9961 (patch)
tree704bb76e883ff832bb740f306def2b3bbe965c50
parent4f3dd1ddb44c0798a7c1c9485b179b36304de098 (diff)
config: allow negative to be used with tags. (#11779)
-rw-r--r--hyprtester/src/tests/main/tags.cpp48
-rw-r--r--src/helpers/TagKeeper.cpp5
2 files changed, 52 insertions, 1 deletions
diff --git a/hyprtester/src/tests/main/tags.cpp b/hyprtester/src/tests/main/tags.cpp
new file mode 100644
index 00000000..22bedcde
--- /dev/null
+++ b/hyprtester/src/tests/main/tags.cpp
@@ -0,0 +1,48 @@
+#include "../../shared.hpp"
+#include "../../hyprctlCompat.hpp"
+#include "../shared.hpp"
+#include "tests.hpp"
+
+static int ret = 0;
+
+static bool testTags() {
+ NLog::log("{}Testing tags", Colors::GREEN);
+
+ EXPECT(Tests::windowCount(), 0);
+
+ NLog::log("{}Spawning kittyProcA&B on ws 1", Colors::YELLOW);
+ auto kittyProcA = Tests::spawnKitty("tagged");
+ auto kittyProcB = Tests::spawnKitty("untagged");
+
+ if (!kittyProcA || !kittyProcB) {
+ NLog::log("{}Error: kitty did not spawn", Colors::RED);
+ return false;
+ }
+
+ NLog::log("{}Testing testTag tags", Colors::YELLOW);
+
+ OK(getFromSocket("/keyword windowrule tag +testTag, class:tagged"));
+ OK(getFromSocket("/keyword windowrule noshadow, tag:negative:testTag"));
+ OK(getFromSocket("/keyword windowrule noborder, tag:testTag"));
+
+ EXPECT(Tests::windowCount(), 2);
+ OK(getFromSocket("/dispatch focuswindow class:tagged"));
+ NLog::log("{}Testing tagged window for noborder & noshadow", Colors::YELLOW);
+ EXPECT_CONTAINS(getFromSocket("/activewindow"), "testTag");
+ EXPECT_CONTAINS(getFromSocket("/getprop activewindow noborder"), "true");
+ EXPECT_CONTAINS(getFromSocket("/getprop activewindow noshadow"), "false");
+ NLog::log("{}Testing untagged window for noborder & noshadow", Colors::YELLOW);
+ OK(getFromSocket("/dispatch focuswindow class:untagged"));
+ EXPECT_NOT_CONTAINS(getFromSocket("/activewindow"), "testTag");
+ EXPECT_CONTAINS(getFromSocket("/getprop activewindow noborder"), "false");
+ EXPECT_CONTAINS(getFromSocket("/getprop activewindow noshadow"), "true");
+
+ Tests::killAllWindows();
+ EXPECT(Tests::windowCount(), 0);
+
+ OK(getFromSocket("/reload"));
+
+ return ret == 0;
+}
+
+REGISTER_TEST_FN(testTags)
diff --git a/src/helpers/TagKeeper.cpp b/src/helpers/TagKeeper.cpp
index f960accb..3c7071d5 100644
--- a/src/helpers/TagKeeper.cpp
+++ b/src/helpers/TagKeeper.cpp
@@ -1,7 +1,10 @@
#include "TagKeeper.hpp"
bool CTagKeeper::isTagged(const std::string& tag, bool strict) {
- return m_tags.contains(tag) || (!strict && m_tags.contains(tag + "*"));
+ const bool NEGATIVE = tag.starts_with("negative");
+ const auto MATCH = NEGATIVE ? tag.substr(9) : tag;
+ const bool TAGGED = m_tags.contains(MATCH) || (!strict && m_tags.contains(MATCH + "*"));
+ return NEGATIVE ? !TAGGED : TAGGED;
}
bool CTagKeeper::applyTag(const std::string& tag, bool dynamic) {