2022-05-14 17:23:46 +02:00
|
|
|
#include "WLClasses.hpp"
|
|
|
|
#include "../config/ConfigManager.hpp"
|
2023-09-20 17:47:05 +02:00
|
|
|
#include "../Compositor.hpp"
|
2022-05-14 17:23:46 +02:00
|
|
|
|
|
|
|
SLayerSurface::SLayerSurface() {
|
2022-07-28 13:28:43 +02:00
|
|
|
alpha.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("fadeIn"), nullptr, AVARDAMAGE_ENTIRE);
|
2022-05-14 17:23:46 +02:00
|
|
|
alpha.m_pLayer = this;
|
2022-11-04 16:56:31 +01:00
|
|
|
alpha.registerVar();
|
2023-03-18 00:16:13 +01:00
|
|
|
}
|
|
|
|
|
2023-12-04 03:08:34 +01:00
|
|
|
SLayerSurface::~SLayerSurface() {
|
2023-12-06 15:46:18 +01:00
|
|
|
if (!g_pHyprOpenGL)
|
|
|
|
return;
|
|
|
|
|
2023-12-04 03:08:34 +01:00
|
|
|
g_pHyprRenderer->makeEGLCurrent();
|
|
|
|
std::erase_if(g_pHyprOpenGL->m_mLayerFramebuffers, [&](const auto& other) { return other.first == this; });
|
|
|
|
}
|
|
|
|
|
2023-03-18 00:16:13 +01:00
|
|
|
void SLayerSurface::applyRules() {
|
2023-06-11 19:30:31 +02:00
|
|
|
noAnimations = false;
|
|
|
|
forceBlur = false;
|
|
|
|
ignoreAlpha = false;
|
|
|
|
ignoreAlphaValue = 0.f;
|
2023-08-09 22:03:24 +02:00
|
|
|
xray = -1;
|
2023-03-18 00:16:13 +01:00
|
|
|
|
|
|
|
for (auto& rule : g_pConfigManager->getMatchingRules(this)) {
|
|
|
|
if (rule.rule == "noanim")
|
|
|
|
noAnimations = true;
|
|
|
|
else if (rule.rule == "blur")
|
|
|
|
forceBlur = true;
|
2023-10-15 20:07:23 +02:00
|
|
|
else if (rule.rule.starts_with("ignorealpha") || rule.rule.starts_with("ignorezero")) {
|
2023-06-11 19:30:31 +02:00
|
|
|
const auto FIRST_SPACE_POS = rule.rule.find_first_of(' ');
|
|
|
|
std::string alphaValue = "";
|
|
|
|
if (FIRST_SPACE_POS != std::string::npos)
|
|
|
|
alphaValue = rule.rule.substr(FIRST_SPACE_POS + 1);
|
|
|
|
|
|
|
|
try {
|
|
|
|
ignoreAlpha = true;
|
|
|
|
if (!alphaValue.empty())
|
|
|
|
ignoreAlphaValue = std::stof(alphaValue);
|
|
|
|
} catch (...) { Debug::log(ERR, "Invalid value passed to ignoreAlpha"); }
|
2023-10-15 20:07:23 +02:00
|
|
|
} else if (rule.rule.starts_with("xray")) {
|
2023-08-09 22:03:24 +02:00
|
|
|
CVarList vars{rule.rule, 0, ' '};
|
|
|
|
try {
|
|
|
|
xray = configStringToInt(vars[1]);
|
|
|
|
} catch (...) {}
|
2023-06-11 19:30:31 +02:00
|
|
|
}
|
2023-03-18 00:16:13 +01:00
|
|
|
}
|
2023-09-20 17:47:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CRegion SConstraint::getLogicCoordsRegion() {
|
|
|
|
CRegion result;
|
|
|
|
|
|
|
|
if (!constraint)
|
|
|
|
return result;
|
|
|
|
|
|
|
|
const auto PWINDOWOWNER = g_pCompositor->getWindowFromSurface(constraint->surface);
|
|
|
|
|
|
|
|
if (!PWINDOWOWNER)
|
|
|
|
return result;
|
|
|
|
|
|
|
|
result.add(&constraint->region); // surface-local coords
|
|
|
|
|
|
|
|
if (!PWINDOWOWNER->m_bIsX11) {
|
|
|
|
result.translate(PWINDOWOWNER->m_vRealPosition.goalv());
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto COORDS = PWINDOWOWNER->m_bIsMapped ? PWINDOWOWNER->m_vRealPosition.goalv() :
|
|
|
|
g_pXWaylandManager->xwaylandToWaylandCoords({PWINDOWOWNER->m_uSurface.xwayland->x, PWINDOWOWNER->m_uSurface.xwayland->y});
|
|
|
|
|
|
|
|
const auto PMONITOR = PWINDOWOWNER->m_bIsMapped ? g_pCompositor->getMonitorFromID(PWINDOWOWNER->m_iMonitorID) : g_pCompositor->getMonitorFromVector(COORDS);
|
|
|
|
|
|
|
|
if (!PMONITOR)
|
|
|
|
return CRegion{};
|
|
|
|
|
|
|
|
result.scale(PMONITOR->xwaylandScale);
|
|
|
|
|
|
|
|
result.translate(COORDS);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
Vector2D SConstraint::getLogicConstraintPos() {
|
|
|
|
if (!constraint)
|
|
|
|
return {};
|
|
|
|
|
|
|
|
const auto PWINDOWOWNER = g_pCompositor->getWindowFromSurface(constraint->surface);
|
|
|
|
|
|
|
|
if (!PWINDOWOWNER)
|
|
|
|
return {};
|
|
|
|
|
|
|
|
if (!PWINDOWOWNER->m_bIsX11)
|
|
|
|
return PWINDOWOWNER->m_vRealPosition.goalv();
|
|
|
|
|
|
|
|
const auto COORDS = PWINDOWOWNER->m_bIsMapped ? PWINDOWOWNER->m_vRealPosition.goalv() :
|
|
|
|
g_pXWaylandManager->xwaylandToWaylandCoords({PWINDOWOWNER->m_uSurface.xwayland->x, PWINDOWOWNER->m_uSurface.xwayland->y});
|
|
|
|
|
|
|
|
return COORDS;
|
|
|
|
}
|
|
|
|
|
|
|
|
Vector2D SConstraint::getLogicConstraintSize() {
|
|
|
|
if (!constraint)
|
|
|
|
return {};
|
|
|
|
|
|
|
|
const auto PWINDOWOWNER = g_pCompositor->getWindowFromSurface(constraint->surface);
|
|
|
|
|
|
|
|
if (!PWINDOWOWNER)
|
|
|
|
return {};
|
|
|
|
|
|
|
|
if (!PWINDOWOWNER->m_bIsX11)
|
|
|
|
return PWINDOWOWNER->m_vRealSize.goalv();
|
|
|
|
|
|
|
|
const auto PMONITOR = PWINDOWOWNER->m_bIsMapped ?
|
|
|
|
g_pCompositor->getMonitorFromID(PWINDOWOWNER->m_iMonitorID) :
|
|
|
|
g_pCompositor->getMonitorFromVector(g_pXWaylandManager->xwaylandToWaylandCoords({PWINDOWOWNER->m_uSurface.xwayland->x, PWINDOWOWNER->m_uSurface.xwayland->y}));
|
|
|
|
|
|
|
|
if (!PMONITOR)
|
|
|
|
return {};
|
|
|
|
|
|
|
|
const auto SIZE = PWINDOWOWNER->m_bIsMapped ? PWINDOWOWNER->m_vRealSize.goalv() :
|
|
|
|
Vector2D{PWINDOWOWNER->m_uSurface.xwayland->width, PWINDOWOWNER->m_uSurface.xwayland->height} * PMONITOR->xwaylandScale;
|
|
|
|
|
|
|
|
return SIZE;
|
2022-05-14 17:23:46 +02:00
|
|
|
}
|