diff options
author | vaxerski <[email protected]> | 2022-11-07 21:23:19 +0000 |
---|---|---|
committer | vaxerski <[email protected]> | 2022-11-07 21:27:28 +0000 |
commit | 2a20cf5379161adc16424652313371c558b1467e (patch) | |
tree | 190530aa75bfbd81bcdf39ea79fc9cf019ab73d5 | |
parent | e3a3837164ab4372d818f9d6b0e71731a118576c (diff) | |
download | Hyprland-2a20cf5379161adc16424652313371c558b1467e.tar.gz Hyprland-2a20cf5379161adc16424652313371c558b1467e.zip |
Added decoration:shadow_scale
-rw-r--r-- | src/config/ConfigManager.cpp | 1 | ||||
-rw-r--r-- | src/render/decorations/CHyprDropShadowDecoration.cpp | 38 |
2 files changed, 31 insertions, 8 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 8de3639d..4bb7b7d8 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -84,6 +84,7 @@ void CConfigManager::setDefaultVars() { configValues["decoration:shadow_render_power"].intValue = 3; configValues["decoration:shadow_ignore_window"].intValue = 1; configValues["decoration:shadow_offset"].vecValue = Vector2D(); + configValues["decoration:shadow_scale"].floatValue = 1.f; configValues["decoration:col.shadow"].intValue = 0xee1a1a1a; configValues["decoration:col.shadow_inactive"].intValue = INT_MAX; configValues["decoration:dim_inactive"].intValue = 0; diff --git a/src/render/decorations/CHyprDropShadowDecoration.cpp b/src/render/decorations/CHyprDropShadowDecoration.cpp index f5f14f8b..cbaef6a0 100644 --- a/src/render/decorations/CHyprDropShadowDecoration.cpp +++ b/src/render/decorations/CHyprDropShadowDecoration.cpp @@ -66,6 +66,7 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D static auto *const PSHADOWSIZE = &g_pConfigManager->getConfigValuePtr("decoration:shadow_range")->intValue; static auto *const PROUNDING = &g_pConfigManager->getConfigValuePtr("decoration:rounding")->intValue; static auto *const PSHADOWIGNOREWINDOW = &g_pConfigManager->getConfigValuePtr("decoration:shadow_ignore_window")->intValue; + static auto *const PSHADOWSCALE = &g_pConfigManager->getConfigValuePtr("decoration:shadow_scale")->floatValue; static auto *const PSHADOWOFFSET = &g_pConfigManager->getConfigValuePtr("decoration:shadow_offset")->vecValue; if (*PSHADOWS != 1) @@ -73,22 +74,43 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D const auto ROUNDING = !m_pWindow->m_sSpecialRenderData.rounding ? 0 : (m_pWindow->m_sAdditionalConfigData.rounding == -1 ? *PROUNDING : m_pWindow->m_sAdditionalConfigData.rounding); - // update the extents - m_seExtents = {{*PSHADOWSIZE + 2 - PSHADOWOFFSET->x, *PSHADOWSIZE + 2 - PSHADOWOFFSET->y}, {*PSHADOWSIZE + 2 + PSHADOWOFFSET->x, *PSHADOWSIZE + 2 + PSHADOWOFFSET->y}}; - // draw the shadow - wlr_box fullBox = {m_vLastWindowPos.x - m_seExtents.topLeft.x + 2, m_vLastWindowPos.y - m_seExtents.topLeft.y + 2, m_vLastWindowSize.x + m_seExtents.topLeft.x + m_seExtents.bottomRight.x - 4, m_vLastWindowSize.y + m_seExtents.topLeft.y + m_seExtents.bottomRight.y - 4}; + wlr_box fullBox = { m_vLastWindowPos.x - *PSHADOWSIZE, m_vLastWindowPos.y - *PSHADOWSIZE, + m_vLastWindowSize.x + 2.0 * *PSHADOWSIZE, m_vLastWindowSize.y + 2.0 * *PSHADOWSIZE }; fullBox.x -= pMonitor->vecPosition.x; fullBox.y -= pMonitor->vecPosition.y; - fullBox.x += offset.x; - fullBox.y += offset.y; + // scale the box in relation to the center of the box + const Vector2D NEWSIZE = Vector2D { fullBox.width, fullBox.height } * *PSHADOWSCALE; + fullBox.width = NEWSIZE.x; + fullBox.height = NEWSIZE.y; + + if (PSHADOWOFFSET->x < 0) { + fullBox.x += PSHADOWOFFSET->x; + } else if (PSHADOWOFFSET->x > 0) { + fullBox.x = m_vLastWindowPos.x + m_vLastWindowSize.x - fullBox.width + (*PSHADOWSCALE * *PSHADOWSIZE) + PSHADOWOFFSET->x - pMonitor->vecPosition.x; + } else { + fullBox.x += ((m_vLastWindowSize.x + 2.0 * *PSHADOWSIZE) - NEWSIZE.x) / 2.0; + } + + if (PSHADOWOFFSET->y < 0) { + fullBox.y += PSHADOWOFFSET->y; + } else if (PSHADOWOFFSET->y > 0) { + fullBox.y = m_vLastWindowPos.y + m_vLastWindowSize.y - fullBox.height + (*PSHADOWSCALE * *PSHADOWSIZE) + PSHADOWOFFSET->y - pMonitor->vecPosition.y; + } else { + fullBox.y += ((m_vLastWindowSize.y + 2.0 * *PSHADOWSIZE) - NEWSIZE.y) / 2.0; + } + + m_seExtents = { { m_vLastWindowPos.x - fullBox.x + pMonitor->vecPosition.x + 2, + m_vLastWindowPos.y - fullBox.y + pMonitor->vecPosition.y + 2}, + { fullBox.x + fullBox.width + pMonitor->vecPosition.x - m_pWindow->m_vRealPosition.vec().x - m_pWindow->m_vRealSize.vec().x + 2, + fullBox.y + fullBox.height + pMonitor->vecPosition.y - m_pWindow->m_vRealPosition.vec().y - m_pWindow->m_vRealSize.vec().y + 2} }; if (fullBox.width < 1 || fullBox.height < 1) - return; // don't draw invisible shadows + return; // don't draw invisible shadows - g_pHyprOpenGL->scissor((wlr_box *)nullptr); + g_pHyprOpenGL->scissor((wlr_box*)nullptr); if (*PSHADOWIGNOREWINDOW) { glEnable(GL_STENCIL_TEST); |