renderer: allow blurring ls popups

This commit is contained in:
Vaxry 2024-03-25 16:08:55 +00:00
parent 356414639f
commit ca17a89d86
8 changed files with 85 additions and 22 deletions

View file

@ -1906,7 +1906,8 @@ bool windowRuleValid(const std::string& RULE) {
}
bool layerRuleValid(const std::string& RULE) {
return RULE == "noanim" || RULE == "blur" || RULE.starts_with("ignorealpha") || RULE.starts_with("ignorezero") || RULE.starts_with("xray") || RULE.starts_with("animation");
return RULE == "noanim" || RULE == "blur" || RULE == "blurpopups" || RULE.starts_with("ignorealpha") || RULE.starts_with("ignorezero") || RULE.starts_with("xray") ||
RULE.starts_with("animation");
}
std::optional<std::string> CConfigManager::handleWindowRule(const std::string& command, const std::string& value) {

View file

@ -117,6 +117,9 @@ void CPopup::onMap() {
unconstrain();
sendScale();
if (m_pLayerOwner && m_pLayerOwner->layer < ZWLR_LAYER_SHELL_V1_LAYER_TOP)
g_pHyprOpenGL->markBlurDirtyForMonitor(g_pCompositor->getMonitorFromID(m_pLayerOwner->layer));
}
void CPopup::onUnmap() {
@ -131,6 +134,9 @@ void CPopup::onUnmap() {
m_pSubsurfaceHead.reset();
g_pInputManager->simulateMouseMovement();
if (m_pLayerOwner && m_pLayerOwner->layer < ZWLR_LAYER_SHELL_V1_LAYER_TOP)
g_pHyprOpenGL->markBlurDirtyForMonitor(g_pCompositor->getMonitorFromID(m_pLayerOwner->layer));
}
void CPopup::onCommit(bool ignoreSiblings) {
@ -158,6 +164,9 @@ void CPopup::onCommit(bool ignoreSiblings) {
g_pHyprRenderer->damageSurface(m_sWLSurface.wlr(), COORDS.x, COORDS.y);
m_bRequestedReposition = false;
if (m_pLayerOwner && m_pLayerOwner->layer < ZWLR_LAYER_SHELL_V1_LAYER_TOP)
g_pHyprOpenGL->markBlurDirtyForMonitor(g_pCompositor->getMonitorFromID(m_pLayerOwner->layer));
}
void CPopup::onReposition() {

View file

@ -1151,3 +1151,13 @@ void CWindow::setAnimationsToMove() {
m_vRealSize.setConfig(PANIMCFG);
m_bAnimatingIn = false;
}
int CWindow::popupsCount() {
if (m_bIsX11)
return 1;
int no = 0;
wlr_xdg_surface_for_each_popup_surface(
m_uSurface.xdg, [](wlr_surface* s, int x, int y, void* data) { *(int*)data += 1; }, &no);
return no;
}

View file

@ -404,6 +404,7 @@ class CWindow {
void onBorderAngleAnimEnd(void* ptr);
bool isInCurvedCorner(double x, double y);
bool hasPopupAt(const Vector2D& pos);
int popupsCount();
void applyGroupRules();
void createGroup();

View file

@ -37,6 +37,8 @@ void SLayerSurface::applyRules() {
noAnimations = true;
else if (rule.rule == "blur")
forceBlur = true;
else if (rule.rule == "blurpopups")
forceBlurPopups = true;
else if (rule.rule.starts_with("ignorealpha") || rule.rule.starts_with("ignorezero")) {
const auto FIRST_SPACE_POS = rule.rule.find_first_of(' ');
std::string alphaValue = "";
@ -168,6 +170,13 @@ bool SLayerSurface::isFadedOut() {
return !realPosition.isBeingAnimated() && !realSize.isBeingAnimated() && !alpha.isBeingAnimated();
}
int SLayerSurface::popupsCount() {
int no = 0;
wlr_layer_surface_v1_for_each_popup_surface(
layerSurface, [](wlr_surface* s, int x, int y, void* data) { *(int*)data += 1; }, &no);
return no;
}
void SKeyboard::updateXKBTranslationState(xkb_keymap* const keymap) {
xkb_state_unref(xkbTranslationState);

View file

@ -22,6 +22,7 @@ struct SLayerSurface {
void applyRules();
void startAnimation(bool in, bool instant = false);
bool isFadedOut();
int popupsCount();
CAnimatedVariable<Vector2D> realPosition;
CAnimatedVariable<Vector2D> realSize;
@ -58,6 +59,7 @@ struct SLayerSurface {
bool noAnimations = false;
bool forceBlur = false;
bool forceBlurPopups = false;
int xray = -1;
bool ignoreAlpha = false;
float ignoreAlphaValue = 0.f;

View file

@ -147,6 +147,7 @@ bool CHyprOpenGLImpl::passRequiresIntrospection(CMonitor* pMonitor) {
static auto PXRAY = CConfigValue<Hyprlang::INT>("decoration:blur:xray");
static auto POPTIM = CConfigValue<Hyprlang::INT>("decoration:blur:new_optimizations");
static auto PBLURSPECIAL = CConfigValue<Hyprlang::INT>("decoration:blur:special");
static auto PBLURPOPUPS = CConfigValue<Hyprlang::INT>("decoration:blur:popups");
if (m_RenderData.mouseZoomFactor != 1.0 || g_pHyprRenderer->m_bCrashingInProgress)
return true;
@ -167,23 +168,35 @@ bool CHyprOpenGLImpl::passRequiresIntrospection(CMonitor* pMonitor) {
const auto XRAYMODE = ls->xray == -1 ? *PXRAY : ls->xray;
if (ls->forceBlur && !XRAYMODE)
return true;
if (ls->popupsCount() > 0 && ls->forceBlurPopups)
return true;
}
for (auto& ls : pMonitor->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]) {
const auto XRAYMODE = ls->xray == -1 ? *PXRAY : ls->xray;
if (ls->forceBlur && !XRAYMODE)
return true;
if (ls->popupsCount() > 0 && ls->forceBlurPopups)
return true;
}
// these two block optimization
for (auto& ls : pMonitor->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND]) {
if (ls->forceBlur)
return true;
if (ls->popupsCount() > 0 && ls->forceBlurPopups)
return true;
}
for (auto& ls : pMonitor->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM]) {
if (ls->forceBlur)
return true;
if (ls->popupsCount() > 0 && ls->forceBlurPopups)
return true;
}
if (*PBLURSPECIAL) {
@ -202,12 +215,18 @@ bool CHyprOpenGLImpl::passRequiresIntrospection(CMonitor* pMonitor) {
return false;
for (auto& w : g_pCompositor->m_vWindows) {
if (!w->m_bIsMapped || w->isHidden() || (!w->m_bIsFloating && *POPTIM && !g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID)))
if (!w->m_bIsMapped || w->isHidden())
continue;
if (!g_pHyprRenderer->shouldRenderWindow(w.get()))
continue;
if (w->popupsCount() > 0 && *PBLURPOPUPS)
return true;
if (!w->m_bIsFloating && *POPTIM && !g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID))
continue;
if (w->m_sAdditionalConfigData.forceNoBlur.toUnderlying() == true || w->m_sAdditionalConfigData.xray.toUnderlying() == true)
continue;

View file

@ -55,9 +55,6 @@ CHyprRenderer::CHyprRenderer() {
}
static void renderSurface(struct wlr_surface* surface, int x, int y, void* data) {
static auto PBLURPOPUPS = CConfigValue<Hyprlang::INT>("decoration:blur:popups");
static auto PBLURPOPUPSIGNOREALPHA = CConfigValue<Hyprlang::FLOAT>("decoration:blur:popups_ignorealpha");
const auto TEXTURE = wlr_surface_get_texture(surface);
const auto RDATA = (SRenderData*)data;
const auto INTERACTIVERESIZEINPROGRESS = RDATA->pWindow && g_pInputManager->currentlyDraggedWindow == RDATA->pWindow && g_pInputManager->dragMode == MBIND_RESIZE;
@ -168,16 +165,9 @@ static void renderSurface(struct wlr_surface* surface, int x, int y, void* data)
g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, rounding, true);
}
} else {
if (RDATA->blur && RDATA->popup && *PBLURPOPUPS) {
if (*PBLURPOPUPSIGNOREALPHA != 1.f) {
g_pHyprOpenGL->m_RenderData.discardMode |= DISCARD_ALPHA;
g_pHyprOpenGL->m_RenderData.discardOpacity = *PBLURPOPUPSIGNOREALPHA;
}
g_pHyprOpenGL->renderTextureWithBlur(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, surface, rounding, true);
g_pHyprOpenGL->m_RenderData.discardMode &= ~DISCARD_ALPHA;
} else
if (RDATA->blur && RDATA->popup)
g_pHyprOpenGL->renderTextureWithBlur(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, surface, rounding, true, RDATA->fadeAlpha);
else
g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, rounding, true);
}
@ -616,12 +606,28 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec*
renderdata.squishOversized = false; // don't squish popups
renderdata.popup = true;
static CConfigValue PBLURPOPUPS = CConfigValue<Hyprlang::INT>("decoration:blur:popups");
static CConfigValue PBLURIGNOREA = CConfigValue<Hyprlang::FLOAT>("decoration:blur:popups_ignorealpha");
renderdata.blur = *PBLURPOPUPS;
const auto DM = g_pHyprOpenGL->m_RenderData.discardMode;
const auto DA = g_pHyprOpenGL->m_RenderData.discardOpacity;
if (renderdata.blur) {
g_pHyprOpenGL->m_RenderData.discardMode |= DISCARD_ALPHA;
g_pHyprOpenGL->m_RenderData.discardOpacity = *PBLURIGNOREA;
}
if (pWindow->m_sAdditionalConfigData.nearestNeighbor.toUnderlying())
g_pHyprOpenGL->m_RenderData.useNearestNeighbor = true;
wlr_xdg_surface_for_each_popup_surface(pWindow->m_uSurface.xdg, renderSurface, &renderdata);
g_pHyprOpenGL->m_RenderData.useNearestNeighbor = false;
g_pHyprOpenGL->m_RenderData.discardMode = DM;
g_pHyprOpenGL->m_RenderData.discardOpacity = DA;
}
if (decorate) {
@ -664,20 +670,26 @@ void CHyprRenderer::renderLayer(SLayerSurface* pLayer, CMonitor* pMonitor, times
g_pHyprOpenGL->m_pCurrentLayer = pLayer;
if (pLayer->ignoreAlpha) {
const auto DM = g_pHyprOpenGL->m_RenderData.discardMode;
const auto DA = g_pHyprOpenGL->m_RenderData.discardOpacity;
if (renderdata.blur && pLayer->ignoreAlpha) {
g_pHyprOpenGL->m_RenderData.discardMode |= DISCARD_ALPHA;
g_pHyprOpenGL->m_RenderData.discardOpacity = pLayer->ignoreAlphaValue;
}
wlr_surface_for_each_surface(pLayer->layerSurface->surface, renderSurface, &renderdata);
g_pHyprOpenGL->m_RenderData.discardMode &= ~DISCARD_ALPHA;
renderdata.squishOversized = false; // don't squish popups
renderdata.dontRound = true;
renderdata.popup = true;
renderdata.blur = pLayer->forceBlurPopups;
wlr_layer_surface_v1_for_each_popup_surface(pLayer->layerSurface, renderSurface, &renderdata);
g_pHyprOpenGL->m_pCurrentLayer = nullptr;
g_pHyprOpenGL->m_RenderData.clipBox = {};
g_pHyprOpenGL->m_RenderData.discardMode = DM;
g_pHyprOpenGL->m_RenderData.discardOpacity = DA;
}
void CHyprRenderer::renderIMEPopup(CInputPopup* pPopup, CMonitor* pMonitor, timespec* time) {