From 3d46c739815b178fa77787083d02fabee8e79a21 Mon Sep 17 00:00:00 2001 From: Caleb Owens Date: Mon, 20 Jun 2022 14:37:27 +0100 Subject: Added a multiplier for the width to height ratio --- src/layout/DwindleLayout.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/layout') diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index ce63ace6..1a22bec0 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -23,8 +23,10 @@ void SDwindleNodeData::recalcSizePosRecursive() { const auto REVERSESPLITRATIO = 2.f - splitRatio; - if (g_pConfigManager->getInt("dwindle:preserve_split") == 0) - splitTop = size.y > size.x; + if (g_pConfigManager->getInt("dwindle:preserve_split") == 0) { + const auto WIDTHMULTIPLIER = g_pConfigManager->getFloat("dwindle:split_width_multiplier"); + splitTop = size.y * WIDTHMULTIPLIER > size.x; + } const auto SPLITSIDE = !splitTop; @@ -992,4 +994,4 @@ void CHyprDwindleLayout::toggleSplit(CWindow* pWindow) { std::string CHyprDwindleLayout::getLayoutName() { return "dwindle"; -} \ No newline at end of file +} -- cgit v1.2.3 From 7d80327e7dc241599695cbb92b0cd7b80c8ebf0d Mon Sep 17 00:00:00 2001 From: Caleb Owens Date: Mon, 20 Jun 2022 17:11:59 +0100 Subject: fixed vertical swapping issue --- src/layout/DwindleLayout.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/layout') diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index 1a22bec0..84bc9450 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -31,13 +31,13 @@ void SDwindleNodeData::recalcSizePosRecursive() { const auto SPLITSIDE = !splitTop; if (SPLITSIDE) { - // split sidey + // split left/right children[0]->position = position; children[0]->size = Vector2D(size.x / 2.f * splitRatio, size.y); children[1]->position = Vector2D(position.x + size.x / 2.f * splitRatio, position.y); children[1]->size = Vector2D(size.x / 2.f * REVERSESPLITRATIO, size.y); } else { - // split toppy bottomy + // split top/bottom children[0]->position = position; children[0]->size = Vector2D(size.x, size.y / 2.f * splitRatio); children[1]->position = Vector2D(position.x, position.y + size.y / 2.f * splitRatio); @@ -237,16 +237,19 @@ void CHyprDwindleLayout::onWindowCreated(CWindow* pWindow) { NEWPARENT->pParent = OPENINGON->pParent; NEWPARENT->isNode = true; // it is a node + const auto WIDTHMULTIPLIER = g_pConfigManager->getFloat("dwindle:split_width_multiplier"); + // if cursor over first child, make it first, etc - const auto SIDEBYSIDE = NEWPARENT->size.x / NEWPARENT->size.y > 1.f; + const auto SIDEBYSIDE = NEWPARENT->size.x > NEWPARENT->size.y * WIDTHMULTIPLIER; NEWPARENT->splitTop = !SIDEBYSIDE; + const auto MOUSECOORDS = g_pInputManager->getMouseCoordsInternal(); const auto FORCESPLIT = g_pConfigManager->getInt("dwindle:force_split"); if (FORCESPLIT == 0) { - if ((SIDEBYSIDE && VECINRECT(MOUSECOORDS, NEWPARENT->position.x, NEWPARENT->position.y, NEWPARENT->position.x + NEWPARENT->size.x / 2.f, NEWPARENT->position.y + NEWPARENT->size.y)) - || (!SIDEBYSIDE && VECINRECT(MOUSECOORDS, NEWPARENT->position.x, NEWPARENT->position.y, NEWPARENT->position.x + NEWPARENT->size.x, NEWPARENT->position.y + NEWPARENT->size.y / 2.f))) { + 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))) { // we are hovering over the first node, make PNODE first. NEWPARENT->children[1] = OPENINGON; NEWPARENT->children[0] = PNODE; @@ -275,14 +278,16 @@ void CHyprDwindleLayout::onWindowCreated(CWindow* pWindow) { } // Update the children - if (NEWPARENT->size.x > NEWPARENT->size.y) { - // split sidey + + + if (NEWPARENT->size.x * WIDTHMULTIPLIER > NEWPARENT->size.y) { + // split left/right OPENINGON->position = NEWPARENT->position; OPENINGON->size = Vector2D(NEWPARENT->size.x / 2.f, NEWPARENT->size.y); PNODE->position = Vector2D(NEWPARENT->position.x + NEWPARENT->size.x / 2.f, NEWPARENT->position.y); PNODE->size = Vector2D(NEWPARENT->size.x / 2.f, NEWPARENT->size.y); } else { - // split toppy bottomy + // split top/bottom OPENINGON->position = NEWPARENT->position; OPENINGON->size = Vector2D(NEWPARENT->size.x, NEWPARENT->size.y / 2.f); PNODE->position = Vector2D(NEWPARENT->position.x, NEWPARENT->position.y + NEWPARENT->size.y / 2.f); -- cgit v1.2.3 From a229701f288a2815c70e40b071cdc90147fc2089 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sun, 3 Jul 2022 23:14:51 +0200 Subject: fix crash with null pmonitor in special nodes on dwindle --- src/layout/DwindleLayout.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/layout') diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index 33af48a3..46777847 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -93,17 +93,17 @@ SDwindleNodeData* CHyprDwindleLayout::getMasterNodeOnWorkspace(const int& id) { } void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode) { + // Don't set nodes, only windows. + if (pNode->isNode) + return; + const auto PMONITOR = g_pCompositor->getMonitorFromID(g_pCompositor->getWorkspaceByID(pNode->workspaceID)->m_iMonitorID); - if (!PMONITOR){ + if (!PMONITOR) { Debug::log(ERR, "Orphaned Node %x (workspace ID: %i)!!", pNode, pNode->workspaceID); return; } - // Don't set nodes, only windows. - if (pNode->isNode) - return; - // for gaps outer const bool DISPLAYLEFT = STICKS(pNode->position.x, PMONITOR->vecPosition.x + PMONITOR->vecReservedTopLeft.x); const bool DISPLAYRIGHT = STICKS(pNode->position.x + pNode->size.x, PMONITOR->vecPosition.x + PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x); -- cgit v1.2.3 From 69e179816b88658455d5210679259b6d5f446c43 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sun, 3 Jul 2022 23:16:42 +0200 Subject: oops last fix didnt fix --- src/layout/DwindleLayout.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/layout') diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index 46777847..560075d2 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -97,7 +97,18 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode) { if (pNode->isNode) return; - const auto PMONITOR = g_pCompositor->getMonitorFromID(g_pCompositor->getWorkspaceByID(pNode->workspaceID)->m_iMonitorID); + SMonitor* PMONITOR = nullptr; + + if (pNode->workspaceID != SPECIAL_WORKSPACE_ID) { + for (auto& m : g_pCompositor->m_vMonitors) { + if (m->specialWorkspaceOpen) { + PMONITOR = m.get(); + break; + } + } + } else { + PMONITOR = g_pCompositor->getMonitorFromID(g_pCompositor->getWorkspaceByID(pNode->workspaceID)->m_iMonitorID); + } if (!PMONITOR) { Debug::log(ERR, "Orphaned Node %x (workspace ID: %i)!!", pNode, pNode->workspaceID); -- cgit v1.2.3 From 3df126c675ce03aa3ce152671954d129a70cd892 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sun, 3 Jul 2022 23:17:12 +0200 Subject: oops --- src/layout/DwindleLayout.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/layout') diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index 560075d2..979b2136 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -99,7 +99,7 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode) { SMonitor* PMONITOR = nullptr; - if (pNode->workspaceID != SPECIAL_WORKSPACE_ID) { + if (pNode->workspaceID == SPECIAL_WORKSPACE_ID) { for (auto& m : g_pCompositor->m_vMonitors) { if (m->specialWorkspaceOpen) { PMONITOR = m.get(); -- cgit v1.2.3 From fc3957d5381ea7dad4f180bb1b0d25977fbb874e Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Mon, 4 Jul 2022 00:04:56 +0200 Subject: optimize workspace in applyNodeData --- src/layout/DwindleLayout.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/layout') diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index 979b2136..201b631d 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -171,9 +171,7 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode) { } } - const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID); - - if (PWORKSPACE->m_bIsSpecialWorkspace) { + if (PWINDOW->m_iWorkspaceID == SPECIAL_WORKSPACE_ID) { // if special, we adjust the coords a bit static auto *const PSCALEFACTOR = &g_pConfigManager->getConfigValuePtr("dwindle:special_scale_factor")->floatValue; -- cgit v1.2.3 From 5a22335b8d0d69cabf7038c4d6409d3905762479 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Wed, 6 Jul 2022 15:08:21 +0200 Subject: refocus after group toggles --- src/layout/DwindleLayout.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/layout') diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index 201b631d..7f94cd82 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -646,6 +646,8 @@ void CHyprDwindleLayout::toggleWindowGroup(CWindow* pWindow) { PPARENT->recalcSizePosRecursive(); } + + g_pInputManager->refocus(); } std::deque CHyprDwindleLayout::getGroupMembers(CWindow* pWindow) { -- cgit v1.2.3 From 491b99c61ea19f2e9048f215eace07e126af890b Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 8 Jul 2022 11:24:07 +0200 Subject: handle unmanaged X11 setGeometry --- src/layout/IHyprLayout.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/layout') diff --git a/src/layout/IHyprLayout.cpp b/src/layout/IHyprLayout.cpp index a7f2facf..73771e41 100644 --- a/src/layout/IHyprLayout.cpp +++ b/src/layout/IHyprLayout.cpp @@ -45,7 +45,7 @@ void IHyprLayout::onWindowCreatedFloating(CWindow* pWindow) { Vector2D middlePoint = Vector2D(desiredGeometry.x, desiredGeometry.y) + Vector2D(desiredGeometry.width, desiredGeometry.height) / 2.f; // TODO: detect a popup in a more consistent way. - if (!g_pCompositor->isPointOnAnyMonitor(middlePoint) || (desiredGeometry.x == 0 && desiredGeometry.y == 0)) { + if ((desiredGeometry.x == 0 && desiredGeometry.y == 0)) { // if it's not, fall back to the center placement pWindow->m_vRealPosition = PMONITOR->vecPosition + Vector2D((PMONITOR->vecSize.x - desiredGeometry.width) / 2.f, (PMONITOR->vecSize.y - desiredGeometry.height) / 2.f); } else { @@ -65,10 +65,12 @@ void IHyprLayout::onWindowCreatedFloating(CWindow* pWindow) { pWindow->m_vRealSize.setValue(pWindow->m_vRealSize.goalv()); } - g_pXWaylandManager->setWindowSize(pWindow, pWindow->m_vRealSize.goalv()); - g_pCompositor->fixXWaylandWindowsOnWorkspace(PMONITOR->activeWorkspace); + if (pWindow->m_iX11Type != 2) { + g_pXWaylandManager->setWindowSize(pWindow, pWindow->m_vRealSize.goalv()); + g_pCompositor->fixXWaylandWindowsOnWorkspace(PMONITOR->activeWorkspace); - g_pCompositor->moveWindowToTop(pWindow); + g_pCompositor->moveWindowToTop(pWindow); + } } void IHyprLayout::onBeginDragWindow() { -- cgit v1.2.3 From e6872bddf4c78ebaddbc3de2aa073afc948faf6b Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 8 Jul 2022 21:52:52 +0200 Subject: fix minor issues with floating windows and fullscreen --- src/layout/IHyprLayout.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/layout') diff --git a/src/layout/IHyprLayout.cpp b/src/layout/IHyprLayout.cpp index 73771e41..9f258b44 100644 --- a/src/layout/IHyprLayout.cpp +++ b/src/layout/IHyprLayout.cpp @@ -212,9 +212,23 @@ void IHyprLayout::changeWindowFloatingMode(CWindow* pWindow) { // fix pseudo leaving artifacts g_pHyprRenderer->damageMonitor(g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID)); } else { + pWindow->m_vSize = pWindow->m_vRealSize.vec(); + pWindow->m_vPosition = pWindow->m_vRealPosition.vec(); + onWindowRemovedTiling(pWindow); g_pCompositor->moveWindowToTop(pWindow); + + const auto POS = pWindow->m_vRealPosition.goalv(); + const auto SIZ = pWindow->m_vRealSize.goalv(); + + pWindow->m_vRealPosition.setValueAndWarp(POS + Vector2D(5, 5)); + pWindow->m_vRealSize.setValueAndWarp(SIZ - Vector2D(10, 10)); + + pWindow->m_vRealPosition = POS; + pWindow->m_vRealSize = SIZ; + + g_pHyprRenderer->damageMonitor(g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID)); } } -- cgit v1.2.3 From 2936368e8070fc53dd4095a786be4d92d20c4158 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Mon, 11 Jul 2022 14:13:15 +0200 Subject: minor event fixes --- src/layout/DwindleLayout.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/layout') diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index 7f94cd82..459e4c24 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -522,6 +522,8 @@ void CHyprDwindleLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscree pWindow->m_bIsFullscreen = on; PWORKSPACE->m_bHasFullscreenWindow = !PWORKSPACE->m_bHasFullscreenWindow; + g_pEventManager->postEvent(SHyprIPCEvent("fullscreen", std::to_string((int)on))); + if (!pWindow->m_bIsFullscreen) { // if it got its fullscreen disabled, set back its node if it had one const auto PNODE = getNodeFromWindow(pWindow); -- cgit v1.2.3 From 4c4c36096ba522a9462cd4dc17156879168a7b50 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Mon, 11 Jul 2022 15:40:41 +0200 Subject: fix config reload on fullscreen mode maximized --- src/layout/DwindleLayout.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'src/layout') diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index 459e4c24..c739fa1d 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -387,6 +387,8 @@ void CHyprDwindleLayout::recalculateMonitor(const int& monid) { if (!PWORKSPACE) return; + g_pHyprRenderer->damageMonitor(PMONITOR); + if (PMONITOR->specialWorkspaceOpen) { const auto TOPNODE = getMasterNodeOnWorkspace(SPECIAL_WORKSPACE_ID); @@ -397,9 +399,26 @@ void CHyprDwindleLayout::recalculateMonitor(const int& monid) { } } - // Ignore any recalc events if we have a fullscreen window. - if (PWORKSPACE->m_bHasFullscreenWindow) + // Ignore any recalc events if we have a fullscreen window, but process if fullscreen mode 2 + if (PWORKSPACE->m_bHasFullscreenWindow) { + if (PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL) + return; + + // massive hack from the fullscreen func + const auto PFULLWINDOW = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID); + + SDwindleNodeData fakeNode; + fakeNode.pWindow = PFULLWINDOW; + fakeNode.position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft; + fakeNode.size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight; + fakeNode.workspaceID = PWORKSPACE->m_iID; + PFULLWINDOW->m_vPosition = fakeNode.position; + PFULLWINDOW->m_vSize = fakeNode.size; + + applyNodeDataToWindow(&fakeNode); + return; + } const auto TOPNODE = getMasterNodeOnWorkspace(PMONITOR->activeWorkspace); @@ -573,6 +592,8 @@ void CHyprDwindleLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscree // we need to fix XWayland windows by sending them to NARNIA // because otherwise they'd still be recieving mouse events g_pCompositor->fixXWaylandWindowsOnWorkspace(PMONITOR->activeWorkspace); + + recalculateMonitor(PMONITOR->ID); } void CHyprDwindleLayout::recalculateWindow(CWindow* pWindow) { -- cgit v1.2.3 From 634970a284146f41ef8eae8b5b1d9a17cce05a4c Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 14 Jul 2022 22:49:49 +0200 Subject: update deco values on fullscreen --- src/layout/DwindleLayout.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/layout') diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index 3b1e4f4c..2d9eab0f 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -548,6 +548,8 @@ void CHyprDwindleLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscree pWindow->m_bIsFullscreen = on; PWORKSPACE->m_bHasFullscreenWindow = !PWORKSPACE->m_bHasFullscreenWindow; + g_pCompositor->updateWindowAnimatedDecorationValues(pWindow); + g_pEventManager->postEvent(SHyprIPCEvent("fullscreen", std::to_string((int)on))); if (!pWindow->m_bIsFullscreen) { -- cgit v1.2.3