summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2023-01-25 15:34:13 +0000
committervaxerski <43317083+vaxerski@users.noreply.github.com>2023-01-25 15:34:13 +0000
commit8ae1fd01730ebd8382d850d1d5526fee0fb076f1 (patch)
tree04db54c3ef3cc62cc2a29b501329f1d127770252 /src
parent9813ba2f567a2e489b95bf15168cdcd26a31bec9 (diff)
added layer rules
Diffstat (limited to 'src')
-rw-r--r--src/config/ConfigManager.cpp45
-rw-r--r--src/config/ConfigManager.hpp4
-rw-r--r--src/events/Layers.cpp13
-rw-r--r--src/helpers/WLClasses.hpp14
4 files changed, 71 insertions, 5 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index 397ec6c9..0c8ca2f0 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -740,6 +740,10 @@ bool windowRuleValid(const std::string& RULE) {
RULE.find("rounding") != 0 && RULE.find("workspace") != 0 && RULE.find("bordercolor") != 0);
}
+bool layerRuleValid(const std::string& RULE) {
+ return !(RULE != "noanim");
+}
+
void CConfigManager::handleWindowRule(const std::string& command, const std::string& value) {
const auto RULE = removeBeginEndSpacesTabs(value.substr(0, value.find_first_of(',')));
const auto VALUE = removeBeginEndSpacesTabs(value.substr(value.find_first_of(',') + 1));
@@ -764,6 +768,29 @@ void CConfigManager::handleWindowRule(const std::string& command, const std::str
m_dWindowRules.push_back({RULE, VALUE});
}
+void CConfigManager::handleLayerRule(const std::string& command, const std::string& value) {
+ const auto RULE = removeBeginEndSpacesTabs(value.substr(0, value.find_first_of(',')));
+ const auto VALUE = removeBeginEndSpacesTabs(value.substr(value.find_first_of(',') + 1));
+
+ // check rule and value
+ if (RULE == "" || VALUE == "") {
+ return;
+ }
+
+ if (RULE == "unset") {
+ std::erase_if(m_dLayerRules, [&](const SLayerRule& other) { return other.targetNamespace == VALUE; });
+ return;
+ }
+
+ if (!layerRuleValid(RULE)) {
+ Debug::log(ERR, "Invalid rule found: %s", RULE.c_str());
+ parseError = "Invalid rule found: " + RULE;
+ return;
+ }
+
+ m_dLayerRules.push_back({VALUE, RULE});
+}
+
void CConfigManager::handleWindowRuleV2(const std::string& command, const std::string& value) {
const auto RULE = value.substr(0, value.find_first_of(','));
const auto VALUE = value.substr(value.find_first_of(',') + 1);
@@ -1009,6 +1036,8 @@ std::string CConfigManager::parseKeyword(const std::string& COMMAND, const std::
handleWindowRule(COMMAND, VALUE);
else if (COMMAND == "windowrulev2")
handleWindowRuleV2(COMMAND, VALUE);
+ else if (COMMAND == "layerrule")
+ handleLayerRule(COMMAND, VALUE);
else if (COMMAND == "bezier")
handleBezier(COMMAND, VALUE);
else if (COMMAND == "animation")
@@ -1525,6 +1554,22 @@ std::vector<SWindowRule> CConfigManager::getMatchingRules(CWindow* pWindow) {
return returns;
}
+std::vector<SLayerRule> CConfigManager::getMatchingRules(SLayerSurface* pLS) {
+ std::vector<SLayerRule> returns;
+
+ for (auto& lr : m_dLayerRules) {
+ std::regex NSCHECK(lr.targetNamespace);
+
+ if (!pLS->layerSurface->_namespace || !std::regex_search(pLS->layerSurface->_namespace, NSCHECK))
+ continue;
+
+ // hit
+ returns.push_back(lr);
+ }
+
+ return returns;
+}
+
void CConfigManager::dispatchExecOnce() {
if (firstExecDispatched || isFirstLaunch)
return;
diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp
index 2b8ea8ab..80971966 100644
--- a/src/config/ConfigManager.hpp
+++ b/src/config/ConfigManager.hpp
@@ -11,6 +11,7 @@
#include <algorithm>
#include <regex>
#include "../Window.hpp"
+#include "../helpers/WLClasses.hpp"
#include "defaultConfig.hpp"
#include "ConfigDataValues.hpp"
@@ -152,6 +153,7 @@ class CConfigManager {
std::string getBoundMonitorStringForWS(const std::string&);
std::vector<SWindowRule> getMatchingRules(CWindow*);
+ std::vector<SLayerRule> getMatchingRules(SLayerSurface*);
std::unordered_map<std::string, SMonitorAdditionalReservedArea> m_mAdditionalReservedAreas;
@@ -200,6 +202,7 @@ class CConfigManager {
std::deque<SMonitorRule> m_dMonitorRules;
std::deque<SWindowRule> m_dWindowRules;
+ std::deque<SLayerRule> m_dLayerRules;
std::deque<std::string> m_dBlurLSNamespaces;
bool firstExecDispatched = false;
@@ -224,6 +227,7 @@ class CConfigManager {
void handleBind(const std::string&, const std::string&);
void handleUnbind(const std::string&, const std::string&);
void handleWindowRule(const std::string&, const std::string&);
+ void handleLayerRule(const std::string&, const std::string&);
void handleWindowRuleV2(const std::string&, const std::string&);
void handleDefaultWorkspace(const std::string&, const std::string&);
void handleBezier(const std::string&, const std::string&);
diff --git a/src/events/Layers.cpp b/src/events/Layers.cpp
index 4ecb8ed8..0d581267 100644
--- a/src/events/Layers.cpp
+++ b/src/events/Layers.cpp
@@ -121,6 +121,11 @@ void Events::listener_mapLayerSurface(void* owner, void* data) {
if (!PMONITOR)
return;
+ for (auto& rule : g_pConfigManager->getMatchingRules(layersurface)) {
+ if (rule.rule == "noanim")
+ layersurface->noAnimations = true;
+ }
+
if ((uint64_t)layersurface->monitorID != PMONITOR->ID) {
const auto POLDMON = g_pCompositor->getMonitorFromID(layersurface->monitorID);
for (auto it = POLDMON->m_aLayerSurfaceLayers[layersurface->layer].begin(); it != POLDMON->m_aLayerSurfaceLayers[layersurface->layer].end(); it++) {
@@ -160,6 +165,9 @@ void Events::listener_mapLayerSurface(void* owner, void* data) {
layersurface->readyToDelete = false;
layersurface->fadingOut = false;
+ if (layersurface->noAnimations)
+ layersurface->alpha.setValueAndWarp(1.f);
+
g_pEventManager->postEvent(SHyprIPCEvent{"openlayer", std::string(layersurface->layerSurface->_namespace ? layersurface->layerSurface->_namespace : "")});
}
@@ -190,6 +198,9 @@ void Events::listener_unmapLayerSurface(void* owner, void* data) {
g_pHyprOpenGL->makeLayerSnapshot(layersurface);
layersurface->alpha = 0.f;
+ if (layersurface->noAnimations)
+ layersurface->alpha.setValueAndWarp(0.f);
+
layersurface->mapped = false;
layersurface->fadingOut = true;
@@ -241,7 +252,7 @@ void Events::listener_unmapLayerSurface(void* owner, void* data) {
g_pHyprRenderer->damageBox(&geomFixed);
geomFixed = {layersurface->geometry.x, layersurface->geometry.y, (int)layersurface->layerSurface->surface->current.width,
- (int)layersurface->layerSurface->surface->current.height};
+ (int)layersurface->layerSurface->surface->current.height};
layersurface->geometry = geomFixed; // because the surface can overflow... for some reason?
}
diff --git a/src/helpers/WLClasses.hpp b/src/helpers/WLClasses.hpp
index af070c78..41f7b6a7 100644
--- a/src/helpers/WLClasses.hpp
+++ b/src/helpers/WLClasses.hpp
@@ -7,6 +7,11 @@
#include "SubsurfaceTree.hpp"
#include "AnimatedVariable.hpp"
+struct SLayerRule {
+ std::string targetNamespace = "";
+ std::string rule = "";
+};
+
struct SLayerSurface {
SLayerSurface();
@@ -33,6 +38,7 @@ struct SLayerSurface {
bool fadingOut = false;
bool readyToDelete = false;
bool noProcess = false;
+ bool noAnimations = false;
bool forceBlur = false;
@@ -45,9 +51,9 @@ struct SLayerSurface {
class CMonitor;
struct SRenderData {
- CMonitor* pMonitor;
- timespec* when;
- int x, y;
+ CMonitor* pMonitor;
+ timespec* when;
+ int x, y;
// for iters
void* data = nullptr;
@@ -224,7 +230,7 @@ struct STablet {
std::string name = "";
bool operator==(const STablet& b) {
- return wlrDevice == b.wlrDevice;
+ return wlrDevice == b.wlrDevice;
}
};