mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-05 07:26:00 +01:00
dwindle: autodetect first/second node on open
This commit is contained in:
parent
277b899e0e
commit
32597bd8cb
1 changed files with 16 additions and 2 deletions
|
@ -202,14 +202,28 @@ void CHyprDwindleLayout::onWindowCreated(CWindow* pWindow) {
|
||||||
const auto NEWPARENT = &m_lDwindleNodesData.back();
|
const auto NEWPARENT = &m_lDwindleNodesData.back();
|
||||||
|
|
||||||
// make the parent have the OPENINGON's stats
|
// make the parent have the OPENINGON's stats
|
||||||
NEWPARENT->children[0] = OPENINGON;
|
|
||||||
NEWPARENT->children[1] = PNODE;
|
|
||||||
NEWPARENT->position = OPENINGON->position;
|
NEWPARENT->position = OPENINGON->position;
|
||||||
NEWPARENT->size = OPENINGON->size;
|
NEWPARENT->size = OPENINGON->size;
|
||||||
NEWPARENT->workspaceID = OPENINGON->workspaceID;
|
NEWPARENT->workspaceID = OPENINGON->workspaceID;
|
||||||
NEWPARENT->pParent = OPENINGON->pParent;
|
NEWPARENT->pParent = OPENINGON->pParent;
|
||||||
NEWPARENT->isNode = true; // it is a node
|
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
|
// and update the previous parent if it exists
|
||||||
if (OPENINGON->pParent) {
|
if (OPENINGON->pParent) {
|
||||||
if (OPENINGON->pParent->children[0] == OPENINGON) {
|
if (OPENINGON->pParent->children[0] == OPENINGON) {
|
||||||
|
|
Loading…
Reference in a new issue