Skip to content

Commit

Permalink
config: add order rule for layers (#7697)
Browse files Browse the repository at this point in the history
  • Loading branch information
darkwater authored Sep 9, 2024
1 parent 43e1415 commit 0442106
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/config/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2239,7 +2239,7 @@ bool windowRuleValid(const std::string& RULE) {

bool layerRuleValid(const std::string& RULE) {
static const auto rules = std::unordered_set<std::string>{"noanim", "blur", "blurpopups", "dimaround"};
static const auto rulesPrefix = std::vector<std::string>{"ignorealpha", "ignorezero", "xray", "animation"};
static const auto rulesPrefix = std::vector<std::string>{"ignorealpha", "ignorezero", "xray", "animation", "order"};

return rules.contains(RULE) || std::any_of(rulesPrefix.begin(), rulesPrefix.end(), [&RULE](auto prefix) { return RULE.starts_with(prefix); });
}
Expand Down
5 changes: 5 additions & 0 deletions src/desktop/LayerSurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,11 @@ void CLayerSurface::applyRules() {
} else if (rule.rule.starts_with("animation")) {
CVarList vars{rule.rule, 2, 's'};
animationStyle = vars[1];
} else if (rule.rule.starts_with("order")) {
CVarList vars{rule.rule, 2, 's'};
try {
order = std::stoi(vars[1]);
} catch (...) { Debug::log(ERR, "Invalid value passed to order"); }
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/desktop/LayerSurface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class CLayerSurface {
bool ignoreAlpha = false;
float ignoreAlphaValue = 0.f;
bool dimAround = false;
int64_t order = 0;

std::optional<std::string> animationStyle;

Expand Down
4 changes: 4 additions & 0 deletions src/render/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1742,6 +1742,10 @@ void CHyprRenderer::arrangeLayersForMonitor(const MONITORID& monitor) {

CBox usableArea = {PMONITOR->vecPosition.x, PMONITOR->vecPosition.y, PMONITOR->vecSize.x, PMONITOR->vecSize.y};

for (auto& la : PMONITOR->m_aLayerSurfaceLayers) {
std::stable_sort(la.begin(), la.end(), [](const PHLLSREF& a, const PHLLSREF& b) { return a->order > b->order; });
}

for (auto const& la : PMONITOR->m_aLayerSurfaceLayers)
arrangeLayerArray(PMONITOR, la, true, &usableArea);

Expand Down

0 comments on commit 0442106

Please sign in to comment.