summaryrefslogtreecommitdiff
path: root/src/desktop/Window.cpp
diff options
context:
space:
mode:
authorgiskard <rtgiskard@gmail.com>2024-05-29 05:37:24 +0800
committerGitHub <noreply@github.com>2024-05-28 23:37:24 +0200
commitebf258788e46cd0320fb17138ba413f719180418 (patch)
treed7b96e24caab26cb3d46b2857eebf90ad475b2a9 /src/desktop/Window.cpp
parent73b133d0155d376f35833cd992f821399a42f76b (diff)
config: add tag dispacther and window rule (#6211)
Diffstat (limited to 'src/desktop/Window.cpp')
-rw-r--r--src/desktop/Window.cpp26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/desktop/Window.cpp b/src/desktop/Window.cpp
index 093cab5e..60592452 100644
--- a/src/desktop/Window.cpp
+++ b/src/desktop/Window.cpp
@@ -1,10 +1,12 @@
+#include <any>
+#include <string_view>
+#include <algorithm>
#include "Window.hpp"
#include "../Compositor.hpp"
#include "../render/decorations/CHyprDropShadowDecoration.hpp"
#include "../render/decorations/CHyprGroupBarDecoration.hpp"
#include "../render/decorations/CHyprBorderDecoration.hpp"
#include "../config/ConfigValue.hpp"
-#include <any>
#include "../managers/TokenManager.hpp"
#include "../protocols/XDGShell.hpp"
#include "../xwayland/XWayland.hpp"
@@ -619,6 +621,13 @@ void CWindow::applyDynamicRule(const SWindowRule& r) {
m_sAdditionalConfigData.forceTearing = true;
} else if (r.szRule == "nearestneighbor") {
m_sAdditionalConfigData.nearestNeighbor = true;
+ } else if (r.szRule.starts_with("tag")) {
+ CVarList vars{r.szRule, 0, 's', true};
+
+ if (vars.size() == 2 && vars[0] == "tag")
+ m_tags.applyTag(vars[1], true);
+ else
+ Debug::log(ERR, "Tag rule invalid: {}", r.szRule);
} else if (r.szRule.starts_with("rounding")) {
try {
m_sAdditionalConfigData.rounding = std::stoi(r.szRule.substr(r.szRule.find_first_of(' ') + 1));
@@ -800,6 +809,8 @@ void CWindow::updateDynamicRules() {
m_sAdditionalConfigData.nearestNeighbor = false;
m_eIdleInhibitMode = IDLEINHIBIT_NONE;
+ m_tags.removeDynamicTags();
+
m_vMatchedRules = g_pConfigManager->getMatchingRules(m_pSelf.lock());
for (auto& r : m_vMatchedRules) {
applyDynamicRule(r);
@@ -1370,6 +1381,7 @@ void CWindow::onUpdateState() {
void CWindow::onUpdateMeta() {
const auto NEWTITLE = fetchTitle();
+ bool doUpdate = false;
if (m_szTitle != NEWTITLE) {
m_szTitle = NEWTITLE;
@@ -1382,11 +1394,8 @@ void CWindow::onUpdateMeta() {
EMIT_HOOK_EVENT("activeWindow", m_pSelf.lock());
}
- updateDynamicRules();
- g_pCompositor->updateWindowAnimatedDecorationValues(m_pSelf.lock());
- updateToplevel();
-
Debug::log(LOG, "Window {:x} set title to {}", (uintptr_t)this, m_szTitle);
+ doUpdate = true;
}
const auto NEWCLASS = fetchClass();
@@ -1399,11 +1408,14 @@ void CWindow::onUpdateMeta() {
EMIT_HOOK_EVENT("activeWindow", m_pSelf.lock());
}
+ Debug::log(LOG, "Window {:x} set class to {}", (uintptr_t)this, m_szClass);
+ doUpdate = true;
+ }
+
+ if (doUpdate) {
updateDynamicRules();
g_pCompositor->updateWindowAnimatedDecorationValues(m_pSelf.lock());
updateToplevel();
-
- Debug::log(LOG, "Window {:x} set class to {}", (uintptr_t)this, m_szClass);
}
}