From fbd2b4799d9c205cb0283432ef9ae3778ff68aa7 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sat, 3 Sep 2022 22:49:45 +0200 Subject: [PATCH] Fix some more crimes against humanity --- src/layout/DwindleLayout.cpp | 45 ++++++++++--------- src/layout/MasterLayout.cpp | 22 ++++----- src/managers/KeybindManager.cpp | 4 -- src/managers/input/InputManager.cpp | 3 +- .../decorations/CHyprGroupBarDecoration.cpp | 9 ++-- 5 files changed, 43 insertions(+), 40 deletions(-) diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index 8caa1b88..217ac9ae 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -166,9 +166,9 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for const bool DISPLAYTOP = STICKS(pNode->position.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y); const bool DISPLAYBOTTOM = STICKS(pNode->position.y + pNode->size.y, PMONITOR->vecPosition.y + PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y); - const auto BORDERSIZE = g_pConfigManager->getInt("general:border_size"); - const auto GAPSIN = g_pConfigManager->getInt("general:gaps_in"); - const auto GAPSOUT = g_pConfigManager->getInt("general:gaps_out"); + const auto PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue; + const auto PGAPSIN = &g_pConfigManager->getConfigValuePtr("general:gaps_in")->intValue; + const auto PGAPSOUT = &g_pConfigManager->getConfigValuePtr("general:gaps_out")->intValue; const auto PWINDOW = pNode->pWindow; @@ -183,14 +183,14 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for 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); + auto calcPos = PWINDOW->m_vPosition + Vector2D(*PBORDERSIZE, *PBORDERSIZE); + auto calcSize = PWINDOW->m_vSize - Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE); const auto NODESONWORKSPACE = getNodesOnWorkspace(PWINDOW->m_iWorkspaceID); if (*PNOGAPSWHENONLY && PWINDOW->m_iWorkspaceID != SPECIAL_WORKSPACE_ID && (NODESONWORKSPACE == 1 || (pNode->isGroupMember() && pNode->getGroupMemberCount() == NODESONWORKSPACE))) { - PWINDOW->m_vRealPosition = calcPos - Vector2D(BORDERSIZE, BORDERSIZE); - PWINDOW->m_vRealSize = calcSize + Vector2D(2 * BORDERSIZE, 2 * BORDERSIZE); + PWINDOW->m_vRealPosition = calcPos - Vector2D(*PBORDERSIZE, *PBORDERSIZE); + PWINDOW->m_vRealSize = calcSize + Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE); PWINDOW->updateWindowDecos(); @@ -203,11 +203,11 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for PWINDOW->m_sSpecialRenderData.rounding = true; PWINDOW->m_sSpecialRenderData.border = true; - const auto OFFSETTOPLEFT = Vector2D(DISPLAYLEFT ? GAPSOUT : GAPSIN, - DISPLAYTOP ? GAPSOUT : GAPSIN); + const auto OFFSETTOPLEFT = Vector2D(DISPLAYLEFT ? *PGAPSOUT : *PGAPSIN, + DISPLAYTOP ? *PGAPSOUT : *PGAPSIN); - const auto OFFSETBOTTOMRIGHT = Vector2D(DISPLAYRIGHT ? GAPSOUT : GAPSIN, - DISPLAYBOTTOM ? GAPSOUT : GAPSIN); + const auto OFFSETBOTTOMRIGHT = Vector2D(DISPLAYRIGHT ? *PGAPSOUT : *PGAPSIN, + DISPLAYBOTTOM ? *PGAPSOUT : *PGAPSIN); calcPos = calcPos + OFFSETTOPLEFT; calcSize = calcSize - OFFSETTOPLEFT - OFFSETBOTTOMRIGHT; @@ -371,19 +371,19 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) { NEWPARENT->pParent = OPENINGON->pParent; NEWPARENT->isNode = true; // it is a node - const auto WIDTHMULTIPLIER = g_pConfigManager->getFloat("dwindle:split_width_multiplier"); + const auto PWIDTHMULTIPLIER = &g_pConfigManager->getConfigValuePtr("dwindle:split_width_multiplier")->floatValue; // if cursor over first child, make it first, etc - const auto SIDEBYSIDE = NEWPARENT->size.x > NEWPARENT->size.y * WIDTHMULTIPLIER; + const auto SIDEBYSIDE = NEWPARENT->size.x > NEWPARENT->size.y * *PWIDTHMULTIPLIER; NEWPARENT->splitTop = !SIDEBYSIDE; const auto MOUSECOORDS = g_pInputManager->getMouseCoordsInternal(); - const auto FORCESPLIT = g_pConfigManager->getInt("dwindle:force_split"); + const auto PFORCESPLIT = &g_pConfigManager->getConfigValuePtr("dwindle:force_split")->intValue; - if (FORCESPLIT == 0) { - if ((SIDEBYSIDE && VECINRECT(MOUSECOORDS, NEWPARENT->position.x, NEWPARENT->position.y / WIDTHMULTIPLIER, NEWPARENT->position.x + NEWPARENT->size.x / 2.f, NEWPARENT->position.y + NEWPARENT->size.y)) - || (!SIDEBYSIDE && VECINRECT(MOUSECOORDS, NEWPARENT->position.x, NEWPARENT->position.y / WIDTHMULTIPLIER, NEWPARENT->position.x + NEWPARENT->size.x, NEWPARENT->position.y + NEWPARENT->size.y / 2.f))) { + if (*PFORCESPLIT == 0) { + if ((SIDEBYSIDE && VECINRECT(MOUSECOORDS, NEWPARENT->position.x, NEWPARENT->position.y / *PWIDTHMULTIPLIER, NEWPARENT->position.x + NEWPARENT->size.x / 2.f, NEWPARENT->position.y + NEWPARENT->size.y)) + || (!SIDEBYSIDE && VECINRECT(MOUSECOORDS, NEWPARENT->position.x, NEWPARENT->position.y / *PWIDTHMULTIPLIER, NEWPARENT->position.x + NEWPARENT->size.x, NEWPARENT->position.y + NEWPARENT->size.y / 2.f))) { // we are hovering over the first node, make PNODE first. NEWPARENT->children[1] = OPENINGON; NEWPARENT->children[0] = PNODE; @@ -393,7 +393,7 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) { NEWPARENT->children[1] = PNODE; } } else { - if (FORCESPLIT == 1) { + if (*PFORCESPLIT == 1) { NEWPARENT->children[1] = OPENINGON; NEWPARENT->children[0] = PNODE; } else { @@ -414,7 +414,7 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) { // Update the children - if (NEWPARENT->size.x * WIDTHMULTIPLIER > NEWPARENT->size.y) { + if (NEWPARENT->size.x * *PWIDTHMULTIPLIER > NEWPARENT->size.y) { // split left/right OPENINGON->position = NEWPARENT->position; OPENINGON->size = Vector2D(NEWPARENT->size.x / 2.f, NEWPARENT->size.y); @@ -973,6 +973,9 @@ SWindowRenderLayoutHints CHyprDwindleLayout::requestRenderHints(CWindow* pWindow SWindowRenderLayoutHints hints; + static auto *const PGROUPCOLACTIVE = &g_pConfigManager->getConfigValuePtr("dwindle:col.group_border_active")->intValue; + static auto *const PGROUPCOLINACTIVE = &g_pConfigManager->getConfigValuePtr("dwindle:col.group_border")->intValue; + const auto PNODE = getNodeFromWindow(pWindow); if (!PNODE) return hints; // left for the future, maybe floating funkiness @@ -981,9 +984,9 @@ SWindowRenderLayoutHints CHyprDwindleLayout::requestRenderHints(CWindow* pWindow hints.isBorderColor = true; if (pWindow == g_pCompositor->m_pLastWindow) - hints.borderColor = CColor(g_pConfigManager->getInt("dwindle:col.group_border_active")); + hints.borderColor = CColor(*PGROUPCOLACTIVE); else - hints.borderColor = CColor(g_pConfigManager->getInt("dwindle:col.group_border")); + hints.borderColor = CColor(*PGROUPCOLINACTIVE); } return hints; diff --git a/src/layout/MasterLayout.cpp b/src/layout/MasterLayout.cpp index 9c143a13..8f00db47 100644 --- a/src/layout/MasterLayout.cpp +++ b/src/layout/MasterLayout.cpp @@ -215,9 +215,9 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) { const bool DISPLAYTOP = STICKS(pNode->position.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y); const bool DISPLAYBOTTOM = STICKS(pNode->position.y + pNode->size.y, PMONITOR->vecPosition.y + PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y); - const auto BORDERSIZE = g_pConfigManager->getInt("general:border_size"); - const auto GAPSIN = g_pConfigManager->getInt("general:gaps_in"); - const auto GAPSOUT = g_pConfigManager->getInt("general:gaps_out"); + const auto PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue; + const auto PGAPSIN = &g_pConfigManager->getConfigValuePtr("general:gaps_in")->intValue; + const auto PGAPSOUT = &g_pConfigManager->getConfigValuePtr("general:gaps_out")->intValue; const auto PWINDOW = pNode->pWindow; @@ -231,12 +231,12 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) { PWINDOW->m_vSize = pNode->size; PWINDOW->m_vPosition = pNode->position; - auto calcPos = PWINDOW->m_vPosition + Vector2D(BORDERSIZE, BORDERSIZE); - auto calcSize = PWINDOW->m_vSize - Vector2D(2 * BORDERSIZE, 2 * BORDERSIZE); + auto calcPos = PWINDOW->m_vPosition + Vector2D(*PBORDERSIZE, *PBORDERSIZE); + auto calcSize = PWINDOW->m_vSize - Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE); if (*PNOGAPSWHENONLY && PWINDOW->m_iWorkspaceID != SPECIAL_WORKSPACE_ID && getNodesOnWorkspace(PWINDOW->m_iWorkspaceID) == 1) { - PWINDOW->m_vRealPosition = calcPos - Vector2D(BORDERSIZE, BORDERSIZE); - PWINDOW->m_vRealSize = calcSize + Vector2D(2 * BORDERSIZE, 2 * BORDERSIZE); + PWINDOW->m_vRealPosition = calcPos - Vector2D(*PBORDERSIZE, *PBORDERSIZE); + PWINDOW->m_vRealSize = calcSize + Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE); PWINDOW->updateWindowDecos(); @@ -249,11 +249,11 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) { PWINDOW->m_sSpecialRenderData.rounding = true; PWINDOW->m_sSpecialRenderData.border = true; - const auto OFFSETTOPLEFT = Vector2D(DISPLAYLEFT ? GAPSOUT : GAPSIN, - DISPLAYTOP ? GAPSOUT : GAPSIN); + const auto OFFSETTOPLEFT = Vector2D(DISPLAYLEFT ? *PGAPSOUT : *PGAPSIN, + DISPLAYTOP ? *PGAPSOUT : *PGAPSIN); - const auto OFFSETBOTTOMRIGHT = Vector2D(DISPLAYRIGHT ? GAPSOUT : GAPSIN, - DISPLAYBOTTOM ? GAPSOUT : GAPSIN); + const auto OFFSETBOTTOMRIGHT = Vector2D(DISPLAYRIGHT ? *PGAPSOUT : *PGAPSIN, + DISPLAYBOTTOM ? *PGAPSOUT : *PGAPSIN); calcPos = calcPos + OFFSETTOPLEFT; calcSize = calcSize - OFFSETTOPLEFT - OFFSETBOTTOMRIGHT; diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index edb6cfde..e7acc23c 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -1207,16 +1207,12 @@ void CKeybindManager::toggleSpecialWorkspace(std::string args) { Debug::log(LOG, "Toggling special workspace to open"); if (open) { - uint64_t monID = -1; - for (auto& m : g_pCompositor->m_vMonitors) { if (m->specialWorkspaceOpen != !open) { m->specialWorkspaceOpen = !open; g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m->ID); g_pCompositor->getWorkspaceByID(SPECIAL_WORKSPACE_ID)->startAnim(false, false); - - monID = m->ID; } } diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 2e24404d..ada25565 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -369,6 +369,7 @@ void CInputManager::processMouseDownNormal(wlr_pointer_button_event* e) { // notify the keybind manager static auto *const PPASSMOUSE = &g_pConfigManager->getConfigValuePtr("binds:pass_mouse_when_bound")->intValue; + static auto *const PMAINMODINTERNAL = &g_pConfigManager->getConfigValuePtr("general:main_mod_internal")->intValue; const auto PASS = g_pKeybindManager->onMouseEvent(e); if (!PASS && !*PPASSMOUSE) @@ -383,7 +384,7 @@ void CInputManager::processMouseDownNormal(wlr_pointer_button_event* e) { if (g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow) && g_pCompositor->m_pLastWindow->m_bIsFloating) g_pCompositor->moveWindowToTop(g_pCompositor->m_pLastWindow); - if ((e->button == BTN_LEFT || e->button == BTN_RIGHT) && wlr_keyboard_get_modifiers(PKEYBOARD) == (uint32_t)g_pConfigManager->getInt("general:main_mod_internal")) { + if ((e->button == BTN_LEFT || e->button == BTN_RIGHT) && wlr_keyboard_get_modifiers(PKEYBOARD) == (uint32_t)*PMAINMODINTERNAL) { currentlyDraggedWindow = g_pCompositor->windowFromCursor(); dragButton = e->button; diff --git a/src/render/decorations/CHyprGroupBarDecoration.cpp b/src/render/decorations/CHyprGroupBarDecoration.cpp index 08e3540c..0823ea94 100644 --- a/src/render/decorations/CHyprGroupBarDecoration.cpp +++ b/src/render/decorations/CHyprGroupBarDecoration.cpp @@ -26,9 +26,9 @@ void CHyprGroupBarDecoration::updateWindow(CWindow* pWindow) { if (pWindow->m_vRealPosition.vec() + WORKSPACEOFFSET != m_vLastWindowPos || pWindow->m_vRealSize.vec() != m_vLastWindowSize) { // we draw 3px above the window's border with 3px - const auto BORDERSIZE = g_pConfigManager->getInt("general:border_size"); + const auto PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue; - m_seExtents.topLeft = Vector2D(0, BORDERSIZE + 3 + 3); + m_seExtents.topLeft = Vector2D(0, *PBORDERSIZE + 3 + 3); m_seExtents.bottomRight = Vector2D(); m_vLastWindowPos = pWindow->m_vRealPosition.vec() + WORKSPACEOFFSET; @@ -82,7 +82,10 @@ void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a) { if (rect.width <= 0 || rect.height <= 0) break; - CColor color = m_dwGroupMembers[i] == g_pCompositor->m_pLastWindow ? CColor(g_pConfigManager->getInt("dwindle:col.group_border_active")) : CColor(g_pConfigManager->getInt("dwindle:col.group_border")); + static auto *const PGROUPCOLACTIVE = &g_pConfigManager->getConfigValuePtr("dwindle:col.group_border_active")->intValue; + static auto *const PGROUPCOLINACTIVE = &g_pConfigManager->getConfigValuePtr("dwindle:col.group_border")->intValue; + + CColor color = m_dwGroupMembers[i] == g_pCompositor->m_pLastWindow ? CColor(*PGROUPCOLACTIVE) : CColor(*PGROUPCOLINACTIVE); color.a *= a; g_pHyprOpenGL->renderRect(&rect, color);