summaryrefslogtreecommitdiff
path: root/src/config/ConfigManager.cpp
diff options
context:
space:
mode:
authorUjinT34 <41110182+UjinT34@users.noreply.github.com>2025-02-02 22:25:29 +0300
committerGitHub <noreply@github.com>2025-02-02 20:25:29 +0100
commit31431a92714ab7f53c25d2ececb26c5b7264b7e3 (patch)
treeb5a9ff0e57493b503b09eb9f0e70e96075d70add /src/config/ConfigManager.cpp
parent70d94fec134c4b91916812901310e7765acf8405 (diff)
protocols: Support content-type-v1 proto (#9226)
Diffstat (limited to 'src/config/ConfigManager.cpp')
-rw-r--r--src/config/ConfigManager.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index 8bb6d157..42a1a91c 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -26,6 +26,7 @@
#include "../plugins/PluginSystem.hpp"
#include "managers/HookSystemManager.hpp"
+#include "protocols/types/ContentType.hpp"
#include <cstddef>
#include <cstdint>
#include <hyprutils/path/Path.hpp>
@@ -621,7 +622,7 @@ CConfigManager::CConfigManager() {
m_pConfig->addConfigValue("opengl:nvidia_anti_flicker", Hyprlang::INT{1});
m_pConfig->addConfigValue("cursor:no_hardware_cursors", Hyprlang::INT{0});
- m_pConfig->addConfigValue("cursor:no_break_fs_vrr", Hyprlang::INT{0});
+ m_pConfig->addConfigValue("cursor:no_break_fs_vrr", Hyprlang::INT{2});
m_pConfig->addConfigValue("cursor:min_refresh_rate", Hyprlang::INT{24});
m_pConfig->addConfigValue("cursor:hotspot_padding", Hyprlang::INT{0});
m_pConfig->addConfigValue("cursor:inactive_timeout", {0.f});
@@ -1347,6 +1348,14 @@ std::vector<SP<CWindowRule>> CConfigManager::getMatchingRules(PHLWINDOW pWindow,
continue;
}
+ if (!rule->szContentType.empty()) {
+ try {
+ const auto contentType = NContentType::fromString(rule->szContentType);
+ if (pWindow->getContentType() != contentType)
+ continue;
+ } catch (std::exception& e) { Debug::log(ERR, "Rule \"content:{}\" failed with: {}", rule->szContentType, e.what()); }
+ }
+
if (!rule->szWorkspace.empty()) {
const auto PWORKSPACE = pWindow->m_pWorkspace;
@@ -2361,6 +2370,7 @@ std::optional<std::string> CConfigManager::handleWindowRuleV2(const std::string&
const auto FOCUSPOS = VALUE.find("focus:");
const auto FULLSCREENSTATEPOS = VALUE.find("fullscreenstate:");
const auto ONWORKSPACEPOS = VALUE.find("onworkspace:");
+ const auto CONTENTTYPEPOS = VALUE.find("content:");
// find workspacepos that isn't onworkspacepos
size_t WORKSPACEPOS = std::string::npos;
@@ -2373,8 +2383,8 @@ std::optional<std::string> CConfigManager::handleWindowRuleV2(const std::string&
currentPos = VALUE.find("workspace:", currentPos + 1);
}
- const auto checkPos = std::unordered_set{TAGPOS, TITLEPOS, CLASSPOS, INITIALTITLEPOS, INITIALCLASSPOS, X11POS, FLOATPOS,
- FULLSCREENPOS, PINNEDPOS, FULLSCREENSTATEPOS, WORKSPACEPOS, FOCUSPOS, ONWORKSPACEPOS};
+ const auto checkPos = std::unordered_set{TAGPOS, TITLEPOS, CLASSPOS, INITIALTITLEPOS, INITIALCLASSPOS, X11POS, FLOATPOS,
+ FULLSCREENPOS, PINNEDPOS, FULLSCREENSTATEPOS, WORKSPACEPOS, FOCUSPOS, ONWORKSPACEPOS, CONTENTTYPEPOS};
if (checkPos.size() == 1 && checkPos.contains(std::string::npos)) {
Debug::log(ERR, "Invalid rulev2 syntax: {}", VALUE);
return "Invalid rulev2 syntax: " + VALUE;
@@ -2411,6 +2421,8 @@ std::optional<std::string> CConfigManager::handleWindowRuleV2(const std::string&
min = WORKSPACEPOS;
if (FOCUSPOS > pos && FOCUSPOS < min)
min = FOCUSPOS;
+ if (CONTENTTYPEPOS > pos && CONTENTTYPEPOS < min)
+ min = CONTENTTYPEPOS;
result = result.substr(0, min - pos);
@@ -2469,6 +2481,9 @@ std::optional<std::string> CConfigManager::handleWindowRuleV2(const std::string&
if (ONWORKSPACEPOS != std::string::npos)
rule->szOnWorkspace = extract(ONWORKSPACEPOS + 12);
+ if (CONTENTTYPEPOS != std::string::npos)
+ rule->szContentType = extract(CONTENTTYPEPOS + 8);
+
if (RULE == "unset") {
std::erase_if(m_vWindowRules, [&](const auto& other) {
if (!other->v2)
@@ -2513,6 +2528,9 @@ std::optional<std::string> CConfigManager::handleWindowRuleV2(const std::string&
if (!rule->szOnWorkspace.empty() && rule->szOnWorkspace != other->szOnWorkspace)
return false;
+ if (!rule->szContentType.empty() && rule->szContentType != other->szContentType)
+ return false;
+
return true;
}
});