summaryrefslogtreecommitdiff
path: root/src/layout/DwindleLayout.cpp
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-04-13 16:24:31 +0200
committervaxerski <43317083+vaxerski@users.noreply.github.com>2022-04-13 16:24:31 +0200
commit32597bd8cb7a47c006becd218cb32e99a6c95b06 (patch)
tree9570321d46697c561d0018807fd30f27a35b904d /src/layout/DwindleLayout.cpp
parent277b899e0e6a619a3d20a7bde2ad4c6a5ae43989 (diff)
dwindle: autodetect first/second node on open
Diffstat (limited to 'src/layout/DwindleLayout.cpp')
-rw-r--r--src/layout/DwindleLayout.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp
index 6faf6538..aeddbb8f 100644
--- a/src/layout/DwindleLayout.cpp
+++ b/src/layout/DwindleLayout.cpp
@@ -202,14 +202,28 @@ void CHyprDwindleLayout::onWindowCreated(CWindow* pWindow) {
const auto NEWPARENT = &m_lDwindleNodesData.back();
// make the parent have the OPENINGON's stats
- NEWPARENT->children[0] = OPENINGON;
- NEWPARENT->children[1] = PNODE;
NEWPARENT->position = OPENINGON->position;
NEWPARENT->size = OPENINGON->size;
NEWPARENT->workspaceID = OPENINGON->workspaceID;
NEWPARENT->pParent = OPENINGON->pParent;
NEWPARENT->isNode = true; // it is a node
+ // if cursor over first child, make it first, etc
+ const auto SIDEBYSIDE = NEWPARENT->size.x / NEWPARENT->size.y > 1.f;
+ const auto MOUSECOORDS = g_pInputManager->getMouseCoordsInternal();
+ 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))) {
+
+ // we are hovering over the first node, make PNODE first.
+ NEWPARENT->children[1] = OPENINGON;
+ NEWPARENT->children[0] = PNODE;
+ } else {
+ // we are hovering over the second node, make PNODE second.
+ NEWPARENT->children[0] = OPENINGON;
+ NEWPARENT->children[1] = PNODE;
+ }
+
+
// and update the previous parent if it exists
if (OPENINGON->pParent) {
if (OPENINGON->pParent->children[0] == OPENINGON) {