mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 14:45:59 +01:00
LS: add blur and ignorezero rules
This commit is contained in:
parent
91a565c7b0
commit
e5870d47c7
9 changed files with 61 additions and 18 deletions
|
@ -768,7 +768,7 @@ bool windowRuleValid(const std::string& RULE) {
|
|||
}
|
||||
|
||||
bool layerRuleValid(const std::string& RULE) {
|
||||
return !(RULE != "noanim");
|
||||
return !(RULE != "noanim" && RULE != "blur" && RULE != "ignorezero");
|
||||
}
|
||||
|
||||
void CConfigManager::handleWindowRule(const std::string& command, const std::string& value) {
|
||||
|
@ -800,9 +800,8 @@ void CConfigManager::handleLayerRule(const std::string& command, const std::stri
|
|||
const auto VALUE = removeBeginEndSpacesTabs(value.substr(value.find_first_of(',') + 1));
|
||||
|
||||
// check rule and value
|
||||
if (RULE == "" || VALUE == "") {
|
||||
if (RULE == "" || VALUE == "")
|
||||
return;
|
||||
}
|
||||
|
||||
if (RULE == "unset") {
|
||||
std::erase_if(m_dLayerRules, [&](const SLayerRule& other) { return other.targetNamespace == VALUE; });
|
||||
|
@ -816,6 +815,11 @@ void CConfigManager::handleLayerRule(const std::string& command, const std::stri
|
|||
}
|
||||
|
||||
m_dLayerRules.push_back({VALUE, RULE});
|
||||
|
||||
for (auto& m : g_pCompositor->m_vMonitors)
|
||||
for (auto& lsl : m->m_aLayerSurfaceLayers)
|
||||
for (auto& ls : lsl)
|
||||
ls->applyRules();
|
||||
}
|
||||
|
||||
void CConfigManager::handleWindowRuleV2(const std::string& command, const std::string& value) {
|
||||
|
|
|
@ -121,10 +121,7 @@ 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;
|
||||
}
|
||||
layersurface->applyRules();
|
||||
|
||||
if ((uint64_t)layersurface->monitorID != PMONITOR->ID) {
|
||||
const auto POLDMON = g_pCompositor->getMonitorFromID(layersurface->monitorID);
|
||||
|
|
|
@ -6,3 +6,18 @@ SLayerSurface::SLayerSurface() {
|
|||
alpha.m_pLayer = this;
|
||||
alpha.registerVar();
|
||||
}
|
||||
|
||||
void SLayerSurface::applyRules() {
|
||||
noAnimations = false;
|
||||
forceBlur = false;
|
||||
ignoreZero = false;
|
||||
|
||||
for (auto& rule : g_pConfigManager->getMatchingRules(this)) {
|
||||
if (rule.rule == "noanim")
|
||||
noAnimations = true;
|
||||
else if (rule.rule == "blur")
|
||||
forceBlur = true;
|
||||
else if (rule.rule == "ignorezero")
|
||||
ignoreZero = true;
|
||||
}
|
||||
}
|
|
@ -15,6 +15,8 @@ struct SLayerRule {
|
|||
struct SLayerSurface {
|
||||
SLayerSurface();
|
||||
|
||||
void applyRules();
|
||||
|
||||
wlr_layer_surface_v1* layerSurface;
|
||||
wl_list link;
|
||||
|
||||
|
@ -41,6 +43,7 @@ struct SLayerSurface {
|
|||
bool noAnimations = false;
|
||||
|
||||
bool forceBlur = false;
|
||||
bool ignoreZero = false;
|
||||
|
||||
// For the list lookup
|
||||
bool operator==(const SLayerSurface& rhs) const {
|
||||
|
|
|
@ -190,6 +190,7 @@ void CHyprOpenGLImpl::initShaders() {
|
|||
m_RenderData.pCurrentMonData->m_shRGBA.texAttrib = glGetAttribLocation(prog, "texcoord");
|
||||
m_RenderData.pCurrentMonData->m_shRGBA.posAttrib = glGetAttribLocation(prog, "pos");
|
||||
m_RenderData.pCurrentMonData->m_shRGBA.discardOpaque = glGetUniformLocation(prog, "discardOpaque");
|
||||
m_RenderData.pCurrentMonData->m_shRGBA.discardAlphaZero = glGetUniformLocation(prog, "discardAlphaZero");
|
||||
m_RenderData.pCurrentMonData->m_shRGBA.topLeft = glGetUniformLocation(prog, "topLeft");
|
||||
m_RenderData.pCurrentMonData->m_shRGBA.fullSize = glGetUniformLocation(prog, "fullSize");
|
||||
m_RenderData.pCurrentMonData->m_shRGBA.radius = glGetUniformLocation(prog, "radius");
|
||||
|
@ -466,15 +467,15 @@ void CHyprOpenGLImpl::renderTexture(wlr_texture* tex, wlr_box* pBox, float alpha
|
|||
renderTexture(CTexture(tex), pBox, alpha, round, false, allowCustomUV);
|
||||
}
|
||||
|
||||
void CHyprOpenGLImpl::renderTexture(const CTexture& tex, wlr_box* pBox, float alpha, int round, bool discardopaque, bool allowCustomUV) {
|
||||
void CHyprOpenGLImpl::renderTexture(const CTexture& tex, wlr_box* pBox, float alpha, int round, bool discardActive, bool allowCustomUV) {
|
||||
RASSERT(m_RenderData.pMonitor, "Tried to render texture without begin()!");
|
||||
|
||||
renderTextureInternalWithDamage(tex, pBox, alpha, m_RenderData.pDamage, round, discardopaque, false, allowCustomUV, true);
|
||||
renderTextureInternalWithDamage(tex, pBox, alpha, m_RenderData.pDamage, round, discardActive, false, allowCustomUV, true);
|
||||
|
||||
scissor((wlr_box*)nullptr);
|
||||
}
|
||||
|
||||
void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_box* pBox, float alpha, pixman_region32_t* damage, int round, bool discardOpaque, bool noAA,
|
||||
void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_box* pBox, float alpha, pixman_region32_t* damage, int round, bool discardActive, bool noAA,
|
||||
bool allowCustomUV, bool allowDim) {
|
||||
RASSERT(m_RenderData.pMonitor, "Tried to render texture without begin()!");
|
||||
RASSERT((tex.m_iTexID > 0), "Attempted to draw NULL texture!");
|
||||
|
@ -542,7 +543,14 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b
|
|||
|
||||
if (!usingFinalShader) {
|
||||
glUniform1f(shader->alpha, alpha);
|
||||
glUniform1i(shader->discardOpaque, (int)discardOpaque);
|
||||
|
||||
if (discardActive) {
|
||||
glUniform1i(shader->discardOpaque, !!(m_RenderData.discardMode & DISCARD_OPAQUE));
|
||||
glUniform1i(shader->discardAlphaZero, !!(m_RenderData.discardMode & DISCARD_ALPHAZERO));
|
||||
} else {
|
||||
glUniform1i(shader->discardOpaque, 0);
|
||||
glUniform1i(shader->discardAlphaZero, 0);
|
||||
}
|
||||
}
|
||||
|
||||
wlr_box transformedBox;
|
||||
|
|
|
@ -23,6 +23,12 @@ inline const float fullVerts[] = {
|
|||
};
|
||||
inline const float fanVertsFull[] = {-1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f};
|
||||
|
||||
enum eDiscardMode
|
||||
{
|
||||
DISCARD_OPAQUE = 1,
|
||||
DISCARD_ALPHAZERO = 1 << 1
|
||||
};
|
||||
|
||||
struct SMonitorRenderData {
|
||||
CFramebuffer primaryFB;
|
||||
CFramebuffer mirrorFB; // these are used for some effects,
|
||||
|
@ -64,6 +70,8 @@ struct SCurrentRenderData {
|
|||
Vector2D primarySurfaceUVBottomRight = Vector2D(-1, -1);
|
||||
|
||||
wlr_box clipBox = {};
|
||||
|
||||
uint32_t discardMode = DISCARD_OPAQUE;
|
||||
};
|
||||
|
||||
class CGradientValueData;
|
||||
|
@ -78,7 +86,7 @@ class CHyprOpenGLImpl {
|
|||
void renderRect(wlr_box*, const CColor&, int round = 0);
|
||||
void renderRectWithDamage(wlr_box*, const CColor&, pixman_region32_t* damage, int round = 0);
|
||||
void renderTexture(wlr_texture*, wlr_box*, float a, int round = 0, bool allowCustomUV = false);
|
||||
void renderTexture(const CTexture&, wlr_box*, float a, int round = 0, bool discardOpaque = false, bool allowCustomUV = false);
|
||||
void renderTexture(const CTexture&, wlr_box*, float a, int round = 0, bool discardActive = false, bool allowCustomUV = false);
|
||||
void renderTextureWithBlur(const CTexture&, wlr_box*, float a, wlr_surface* pSurface, int round = 0, bool blockBlurOptimization = false);
|
||||
void renderRoundedShadow(wlr_box*, int round, int range, float a = 1.0);
|
||||
void renderBorder(wlr_box*, const CGradientValueData&, int round, float a = 1.0);
|
||||
|
|
|
@ -376,7 +376,11 @@ void CHyprRenderer::renderLayer(SLayerSurface* pLayer, CMonitor* pMonitor, times
|
|||
renderdata.w = pLayer->geometry.width;
|
||||
renderdata.h = pLayer->geometry.height;
|
||||
renderdata.blockBlurOptimization = pLayer->layer == ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM || pLayer->layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND;
|
||||
|
||||
if (pLayer->ignoreZero)
|
||||
g_pHyprOpenGL->m_RenderData.discardMode |= DISCARD_ALPHAZERO;
|
||||
wlr_surface_for_each_surface(pLayer->layerSurface->surface, renderSurface, &renderdata);
|
||||
g_pHyprOpenGL->m_RenderData.discardMode &= ~DISCARD_ALPHAZERO;
|
||||
|
||||
renderdata.squishOversized = false; // don't squish popups
|
||||
renderdata.dontRound = true;
|
||||
|
|
|
@ -15,6 +15,7 @@ class CShader {
|
|||
GLint posAttrib;
|
||||
GLint texAttrib;
|
||||
GLint discardOpaque;
|
||||
GLint discardAlphaZero;
|
||||
|
||||
GLint topLeft;
|
||||
GLint bottomRight;
|
||||
|
|
|
@ -96,6 +96,7 @@ uniform vec2 fullSize;
|
|||
uniform float radius;
|
||||
|
||||
uniform int discardOpaque;
|
||||
uniform int discardAlphaZero;
|
||||
|
||||
uniform int applyTint;
|
||||
uniform vec3 tint;
|
||||
|
@ -109,6 +110,8 @@ void main() {
|
|||
if (discardOpaque == 1 && pixColor[3] * alpha == 1.0)
|
||||
discard;
|
||||
|
||||
if (discardAlphaZero == 1 && pixColor[3] == 0.0)
|
||||
discard;
|
||||
|
||||
if (applyTint == 1) {
|
||||
pixColor[0] = pixColor[0] * tint[0];
|
||||
|
|
Loading…
Reference in a new issue