From f892387b7020ce27dbcf370244e26e09c9ecc1e5 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Mon, 1 Aug 2022 12:51:52 +0200 Subject: [PATCH] added dwindle:no_gaps_when_only --- src/Window.hpp | 3 +++ src/config/ConfigManager.cpp | 1 + src/layout/DwindleLayout.cpp | 20 +++++++++++++++++++- src/layout/DwindleLayout.hpp | 2 ++ src/render/Renderer.cpp | 2 +- 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/Window.hpp b/src/Window.hpp index e63eba65..2514af14 100644 --- a/src/Window.hpp +++ b/src/Window.hpp @@ -10,6 +10,9 @@ struct SWindowSpecialRenderData { float alpha = 1.f; float alphaInactive = -1.f; // -1 means unset + + // set by the layout + bool rounding = true; }; struct SWindowAdditionalConfigData { diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 61427e80..c6b8a634 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -87,6 +87,7 @@ void CConfigManager::setDefaultVars() { configValues["dwindle:preserve_split"].intValue = 0; configValues["dwindle:special_scale_factor"].floatValue = 0.8f; configValues["dwindle:split_width_multiplier"].floatValue = 1.0f; + configValues["dwindle:no_gaps_when_only"].intValue = 0; configValues["master:special_scale_factor"].floatValue = 0.8f; configValues["master:new_is_master"].intValue = 1; diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index 3ff24aa0..be1c23d8 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -63,7 +63,7 @@ void SDwindleNodeData::getAllChildrenRecursive(std::deque* pD int CHyprDwindleLayout::getNodesOnWorkspace(const int& id) { int no = 0; for (auto& n : m_lDwindleNodesData) { - if (n.workspaceID == id) + if (n.workspaceID == id && n.valid) ++no; } return no; @@ -137,9 +137,24 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode) { PWINDOW->m_vSize = pNode->size; PWINDOW->m_vPosition = pNode->position; + static auto *const PNOGAPSWHENONLY = &g_pConfigManager->getConfigValuePtr("dwindle:no_gaps_when_only")->intValue; + auto calcPos = PWINDOW->m_vPosition + Vector2D(BORDERSIZE, BORDERSIZE); auto calcSize = PWINDOW->m_vSize - Vector2D(2 * BORDERSIZE, 2 * BORDERSIZE); + if (*PNOGAPSWHENONLY && PWINDOW->m_iWorkspaceID != SPECIAL_WORKSPACE_ID && getNodesOnWorkspace(PWINDOW->m_iWorkspaceID) == 1) { + PWINDOW->m_vRealPosition = calcPos; + PWINDOW->m_vRealSize = calcSize; + + PWINDOW->updateWindowDecos(); + + PWINDOW->m_sSpecialRenderData.rounding = false; + + return; + } + + PWINDOW->m_sSpecialRenderData.rounding = true; + const auto OFFSETTOPLEFT = Vector2D(DISPLAYLEFT ? GAPSOUT : GAPSIN, DISPLAYTOP ? GAPSOUT : GAPSIN); @@ -378,6 +393,9 @@ void CHyprDwindleLayout::onWindowRemovedTiling(CWindow* pWindow) { } } + PPARENT->valid = false; + PNODE->valid = false; + if (PSIBLING->pParent) PSIBLING->pParent->recalcSizePosRecursive(); else diff --git a/src/layout/DwindleLayout.hpp b/src/layout/DwindleLayout.hpp index b60b87e0..1dceb0c5 100644 --- a/src/layout/DwindleLayout.hpp +++ b/src/layout/DwindleLayout.hpp @@ -30,6 +30,8 @@ struct SDwindleNodeData { float splitRatio = 1.f; + bool valid = true; + // For list lookup bool operator==(const SDwindleNodeData& rhs) { return pWindow == rhs.pWindow && workspaceID == rhs.workspaceID && position == rhs.position && size == rhs.size && pParent == rhs.pParent && children[0] == rhs.children[0] && children[1] == rhs.children[1]; diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 1de132f3..5103c92c 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -201,7 +201,7 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec* renderdata.fadeAlpha = pWindow->m_fAlpha.fl() * (PWORKSPACE->m_fAlpha.fl() / 255.f); renderdata.alpha = pWindow->m_fActiveInactiveAlpha.fl(); renderdata.decorate = decorate && !pWindow->m_bX11DoesntWantBorders && (pWindow->m_bIsFloating ? *PNOFLOATINGBORDERS == 0 : true) && (!pWindow->m_bIsFullscreen || PWORKSPACE->m_efFullscreenMode != FULLSCREEN_FULL); - renderdata.rounding = pWindow->m_sAdditionalConfigData.rounding; + renderdata.rounding = pWindow->m_sAdditionalConfigData.rounding && pWindow->m_sSpecialRenderData.rounding; renderdata.blur = true; // if it shouldn't, it will be ignored later // apply window special data