mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-23 03:05:59 +01:00
renderer: allow blurring ls popups
This commit is contained in:
parent
356414639f
commit
ca17a89d86
8 changed files with 85 additions and 22 deletions
|
@ -1906,7 +1906,8 @@ bool windowRuleValid(const std::string& RULE) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool layerRuleValid(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) {
|
std::optional<std::string> CConfigManager::handleWindowRule(const std::string& command, const std::string& value) {
|
||||||
|
|
|
@ -117,6 +117,9 @@ void CPopup::onMap() {
|
||||||
|
|
||||||
unconstrain();
|
unconstrain();
|
||||||
sendScale();
|
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() {
|
void CPopup::onUnmap() {
|
||||||
|
@ -131,6 +134,9 @@ void CPopup::onUnmap() {
|
||||||
m_pSubsurfaceHead.reset();
|
m_pSubsurfaceHead.reset();
|
||||||
|
|
||||||
g_pInputManager->simulateMouseMovement();
|
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) {
|
void CPopup::onCommit(bool ignoreSiblings) {
|
||||||
|
@ -158,6 +164,9 @@ void CPopup::onCommit(bool ignoreSiblings) {
|
||||||
g_pHyprRenderer->damageSurface(m_sWLSurface.wlr(), COORDS.x, COORDS.y);
|
g_pHyprRenderer->damageSurface(m_sWLSurface.wlr(), COORDS.x, COORDS.y);
|
||||||
|
|
||||||
m_bRequestedReposition = false;
|
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() {
|
void CPopup::onReposition() {
|
||||||
|
|
|
@ -1151,3 +1151,13 @@ void CWindow::setAnimationsToMove() {
|
||||||
m_vRealSize.setConfig(PANIMCFG);
|
m_vRealSize.setConfig(PANIMCFG);
|
||||||
m_bAnimatingIn = false;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -404,6 +404,7 @@ class CWindow {
|
||||||
void onBorderAngleAnimEnd(void* ptr);
|
void onBorderAngleAnimEnd(void* ptr);
|
||||||
bool isInCurvedCorner(double x, double y);
|
bool isInCurvedCorner(double x, double y);
|
||||||
bool hasPopupAt(const Vector2D& pos);
|
bool hasPopupAt(const Vector2D& pos);
|
||||||
|
int popupsCount();
|
||||||
|
|
||||||
void applyGroupRules();
|
void applyGroupRules();
|
||||||
void createGroup();
|
void createGroup();
|
||||||
|
|
|
@ -37,6 +37,8 @@ void SLayerSurface::applyRules() {
|
||||||
noAnimations = true;
|
noAnimations = true;
|
||||||
else if (rule.rule == "blur")
|
else if (rule.rule == "blur")
|
||||||
forceBlur = true;
|
forceBlur = true;
|
||||||
|
else if (rule.rule == "blurpopups")
|
||||||
|
forceBlurPopups = true;
|
||||||
else if (rule.rule.starts_with("ignorealpha") || rule.rule.starts_with("ignorezero")) {
|
else if (rule.rule.starts_with("ignorealpha") || rule.rule.starts_with("ignorezero")) {
|
||||||
const auto FIRST_SPACE_POS = rule.rule.find_first_of(' ');
|
const auto FIRST_SPACE_POS = rule.rule.find_first_of(' ');
|
||||||
std::string alphaValue = "";
|
std::string alphaValue = "";
|
||||||
|
@ -168,6 +170,13 @@ bool SLayerSurface::isFadedOut() {
|
||||||
return !realPosition.isBeingAnimated() && !realSize.isBeingAnimated() && !alpha.isBeingAnimated();
|
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) {
|
void SKeyboard::updateXKBTranslationState(xkb_keymap* const keymap) {
|
||||||
xkb_state_unref(xkbTranslationState);
|
xkb_state_unref(xkbTranslationState);
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ struct SLayerSurface {
|
||||||
void applyRules();
|
void applyRules();
|
||||||
void startAnimation(bool in, bool instant = false);
|
void startAnimation(bool in, bool instant = false);
|
||||||
bool isFadedOut();
|
bool isFadedOut();
|
||||||
|
int popupsCount();
|
||||||
|
|
||||||
CAnimatedVariable<Vector2D> realPosition;
|
CAnimatedVariable<Vector2D> realPosition;
|
||||||
CAnimatedVariable<Vector2D> realSize;
|
CAnimatedVariable<Vector2D> realSize;
|
||||||
|
@ -58,6 +59,7 @@ struct SLayerSurface {
|
||||||
bool noAnimations = false;
|
bool noAnimations = false;
|
||||||
|
|
||||||
bool forceBlur = false;
|
bool forceBlur = false;
|
||||||
|
bool forceBlurPopups = false;
|
||||||
int xray = -1;
|
int xray = -1;
|
||||||
bool ignoreAlpha = false;
|
bool ignoreAlpha = false;
|
||||||
float ignoreAlphaValue = 0.f;
|
float ignoreAlphaValue = 0.f;
|
||||||
|
|
|
@ -147,6 +147,7 @@ bool CHyprOpenGLImpl::passRequiresIntrospection(CMonitor* pMonitor) {
|
||||||
static auto PXRAY = CConfigValue<Hyprlang::INT>("decoration:blur:xray");
|
static auto PXRAY = CConfigValue<Hyprlang::INT>("decoration:blur:xray");
|
||||||
static auto POPTIM = CConfigValue<Hyprlang::INT>("decoration:blur:new_optimizations");
|
static auto POPTIM = CConfigValue<Hyprlang::INT>("decoration:blur:new_optimizations");
|
||||||
static auto PBLURSPECIAL = CConfigValue<Hyprlang::INT>("decoration:blur:special");
|
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)
|
if (m_RenderData.mouseZoomFactor != 1.0 || g_pHyprRenderer->m_bCrashingInProgress)
|
||||||
return true;
|
return true;
|
||||||
|
@ -167,23 +168,35 @@ bool CHyprOpenGLImpl::passRequiresIntrospection(CMonitor* pMonitor) {
|
||||||
const auto XRAYMODE = ls->xray == -1 ? *PXRAY : ls->xray;
|
const auto XRAYMODE = ls->xray == -1 ? *PXRAY : ls->xray;
|
||||||
if (ls->forceBlur && !XRAYMODE)
|
if (ls->forceBlur && !XRAYMODE)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (ls->popupsCount() > 0 && ls->forceBlurPopups)
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& ls : pMonitor->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]) {
|
for (auto& ls : pMonitor->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]) {
|
||||||
const auto XRAYMODE = ls->xray == -1 ? *PXRAY : ls->xray;
|
const auto XRAYMODE = ls->xray == -1 ? *PXRAY : ls->xray;
|
||||||
if (ls->forceBlur && !XRAYMODE)
|
if (ls->forceBlur && !XRAYMODE)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (ls->popupsCount() > 0 && ls->forceBlurPopups)
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// these two block optimization
|
// these two block optimization
|
||||||
for (auto& ls : pMonitor->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND]) {
|
for (auto& ls : pMonitor->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND]) {
|
||||||
if (ls->forceBlur)
|
if (ls->forceBlur)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (ls->popupsCount() > 0 && ls->forceBlurPopups)
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& ls : pMonitor->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM]) {
|
for (auto& ls : pMonitor->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM]) {
|
||||||
if (ls->forceBlur)
|
if (ls->forceBlur)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (ls->popupsCount() > 0 && ls->forceBlurPopups)
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*PBLURSPECIAL) {
|
if (*PBLURSPECIAL) {
|
||||||
|
@ -202,12 +215,18 @@ bool CHyprOpenGLImpl::passRequiresIntrospection(CMonitor* pMonitor) {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (auto& w : g_pCompositor->m_vWindows) {
|
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;
|
continue;
|
||||||
|
|
||||||
if (!g_pHyprRenderer->shouldRenderWindow(w.get()))
|
if (!g_pHyprRenderer->shouldRenderWindow(w.get()))
|
||||||
continue;
|
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)
|
if (w->m_sAdditionalConfigData.forceNoBlur.toUnderlying() == true || w->m_sAdditionalConfigData.xray.toUnderlying() == true)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -55,9 +55,6 @@ CHyprRenderer::CHyprRenderer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void renderSurface(struct wlr_surface* surface, int x, int y, void* data) {
|
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 TEXTURE = wlr_surface_get_texture(surface);
|
||||||
const auto RDATA = (SRenderData*)data;
|
const auto RDATA = (SRenderData*)data;
|
||||||
const auto INTERACTIVERESIZEINPROGRESS = RDATA->pWindow && g_pInputManager->currentlyDraggedWindow == RDATA->pWindow && g_pInputManager->dragMode == MBIND_RESIZE;
|
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);
|
g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, rounding, true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (RDATA->blur && RDATA->popup && *PBLURPOPUPS) {
|
if (RDATA->blur && RDATA->popup)
|
||||||
|
g_pHyprOpenGL->renderTextureWithBlur(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, surface, rounding, true, RDATA->fadeAlpha);
|
||||||
if (*PBLURPOPUPSIGNOREALPHA != 1.f) {
|
else
|
||||||
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
|
|
||||||
g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, rounding, true);
|
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.squishOversized = false; // don't squish popups
|
||||||
renderdata.popup = true;
|
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())
|
if (pWindow->m_sAdditionalConfigData.nearestNeighbor.toUnderlying())
|
||||||
g_pHyprOpenGL->m_RenderData.useNearestNeighbor = true;
|
g_pHyprOpenGL->m_RenderData.useNearestNeighbor = true;
|
||||||
|
|
||||||
wlr_xdg_surface_for_each_popup_surface(pWindow->m_uSurface.xdg, renderSurface, &renderdata);
|
wlr_xdg_surface_for_each_popup_surface(pWindow->m_uSurface.xdg, renderSurface, &renderdata);
|
||||||
|
|
||||||
g_pHyprOpenGL->m_RenderData.useNearestNeighbor = false;
|
g_pHyprOpenGL->m_RenderData.useNearestNeighbor = false;
|
||||||
|
|
||||||
|
g_pHyprOpenGL->m_RenderData.discardMode = DM;
|
||||||
|
g_pHyprOpenGL->m_RenderData.discardOpacity = DA;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (decorate) {
|
if (decorate) {
|
||||||
|
@ -664,20 +670,26 @@ void CHyprRenderer::renderLayer(SLayerSurface* pLayer, CMonitor* pMonitor, times
|
||||||
|
|
||||||
g_pHyprOpenGL->m_pCurrentLayer = pLayer;
|
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.discardMode |= DISCARD_ALPHA;
|
||||||
g_pHyprOpenGL->m_RenderData.discardOpacity = pLayer->ignoreAlphaValue;
|
g_pHyprOpenGL->m_RenderData.discardOpacity = pLayer->ignoreAlphaValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_surface_for_each_surface(pLayer->layerSurface->surface, renderSurface, &renderdata);
|
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.squishOversized = false; // don't squish popups
|
||||||
renderdata.dontRound = true;
|
renderdata.dontRound = true;
|
||||||
renderdata.popup = true;
|
renderdata.popup = true;
|
||||||
|
renderdata.blur = pLayer->forceBlurPopups;
|
||||||
wlr_layer_surface_v1_for_each_popup_surface(pLayer->layerSurface, renderSurface, &renderdata);
|
wlr_layer_surface_v1_for_each_popup_surface(pLayer->layerSurface, renderSurface, &renderdata);
|
||||||
|
|
||||||
g_pHyprOpenGL->m_pCurrentLayer = nullptr;
|
g_pHyprOpenGL->m_pCurrentLayer = nullptr;
|
||||||
g_pHyprOpenGL->m_RenderData.clipBox = {};
|
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) {
|
void CHyprRenderer::renderIMEPopup(CInputPopup* pPopup, CMonitor* pMonitor, timespec* time) {
|
||||||
|
|
Loading…
Reference in a new issue