mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 17:05:59 +01:00
windowrules: improve opacity
This commit is contained in:
parent
263b9c6e39
commit
27dd07f1b8
1 changed files with 23 additions and 13 deletions
|
@ -476,20 +476,30 @@ void CWindow::applyDynamicRule(const SWindowRule& r) {
|
|||
try {
|
||||
CVarList vars(r.szRule, 0, ' ');
|
||||
|
||||
for (size_t i = 1 /* first item is "opacity" */; i < vars.size(); ++i) {
|
||||
if (i == 1) {
|
||||
// first arg, alpha
|
||||
m_sSpecialRenderData.alpha = std::stof(vars[i]);
|
||||
} else {
|
||||
if (vars[i] == "override") {
|
||||
if (i == 2) {
|
||||
int opacityIDX = 0;
|
||||
|
||||
for (auto& r : vars) {
|
||||
if (r == "opacity")
|
||||
continue;
|
||||
|
||||
if (r == "override") {
|
||||
if (opacityIDX == 0) {
|
||||
m_sSpecialRenderData.alphaOverride = true;
|
||||
} else {
|
||||
m_sSpecialRenderData.alphaInactiveOverride = true;
|
||||
}
|
||||
} else
|
||||
m_sSpecialRenderData.alphaInactiveOverride = true;
|
||||
} else {
|
||||
m_sSpecialRenderData.alphaInactive = std::stof(vars[i]);
|
||||
if (opacityIDX == 0) {
|
||||
m_sSpecialRenderData.alpha = std::stof(r);
|
||||
m_sSpecialRenderData.alphaInactive = std::stof(r);
|
||||
} else if (opacityIDX == 1) {
|
||||
m_sSpecialRenderData.alphaInactive = std::stof(r);
|
||||
m_sSpecialRenderData.alphaInactiveOverride = false;
|
||||
} else {
|
||||
throw std::runtime_error("more than 2 alpha values");
|
||||
}
|
||||
|
||||
opacityIDX++;
|
||||
}
|
||||
}
|
||||
} catch (std::exception& e) { Debug::log(ERR, "Opacity rule \"%s\" failed with: %s", r.szRule.c_str(), e.what()); }
|
||||
|
|
Loading…
Reference in a new issue