mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-23 08:25:57 +01:00
Master: fix drop_at_cursor when there are only two windows (#3734)
* make drop_at_cursor work when dragging into a one-window workspace * fix drop_at_cursor when new_is_master is enabled
This commit is contained in:
parent
93a2ac9de4
commit
ed3d5053b2
1 changed files with 55 additions and 22 deletions
|
@ -133,13 +133,16 @@ void CHyprMasterLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection direc
|
||||||
const auto PWORKSPACEDATA = getMasterWorkspaceData(pWindow->m_iWorkspaceID);
|
const auto PWORKSPACEDATA = getMasterWorkspaceData(pWindow->m_iWorkspaceID);
|
||||||
eOrientation orientation = PWORKSPACEDATA->orientation;
|
eOrientation orientation = PWORKSPACEDATA->orientation;
|
||||||
const auto NODEIT = std::find(m_lMasterNodesData.begin(), m_lMasterNodesData.end(), *PNODE);
|
const auto NODEIT = std::find(m_lMasterNodesData.begin(), m_lMasterNodesData.end(), *PNODE);
|
||||||
if (*PDROPATCURSOR && g_pInputManager->dragMode == MBIND_MOVE) {
|
|
||||||
|
bool forceDropAsMaster = false;
|
||||||
// if dragging window to move, drop it at the cursor position instead of bottom/top of stack
|
// if dragging window to move, drop it at the cursor position instead of bottom/top of stack
|
||||||
|
if (*PDROPATCURSOR && g_pInputManager->dragMode == MBIND_MOVE) {
|
||||||
|
if (WINDOWSONWORKSPACE > 2) {
|
||||||
for (auto it = m_lMasterNodesData.begin(); it != m_lMasterNodesData.end(); ++it) {
|
for (auto it = m_lMasterNodesData.begin(); it != m_lMasterNodesData.end(); ++it) {
|
||||||
if (it->workspaceID != pWindow->m_iWorkspaceID)
|
if (it->workspaceID != pWindow->m_iWorkspaceID)
|
||||||
continue;
|
continue;
|
||||||
const wlr_box box = it->pWindow->getWindowIdealBoundingBoxIgnoreReserved();
|
const wlr_box box = it->pWindow->getWindowIdealBoundingBoxIgnoreReserved();
|
||||||
if (wlr_box_contains_point(&box, MOUSECOORDS.x, MOUSECOORDS.y)) { // TODO: Deny when not using mouse
|
if (wlr_box_contains_point(&box, MOUSECOORDS.x, MOUSECOORDS.y)) {
|
||||||
switch (orientation) {
|
switch (orientation) {
|
||||||
case ORIENTATION_LEFT:
|
case ORIENTATION_LEFT:
|
||||||
case ORIENTATION_RIGHT:
|
case ORIENTATION_RIGHT:
|
||||||
|
@ -158,9 +161,39 @@ void CHyprMasterLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection direc
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (WINDOWSONWORKSPACE == 2) {
|
||||||
|
// when dropping as the second tiled window in the workspace,
|
||||||
|
// make it the master only if the cursor is on the master side of the screen
|
||||||
|
for (auto& nd : m_lMasterNodesData) {
|
||||||
|
if (nd.isMaster && nd.workspaceID == PNODE->workspaceID) {
|
||||||
|
switch (orientation) {
|
||||||
|
case ORIENTATION_LEFT:
|
||||||
|
case ORIENTATION_CENTER:
|
||||||
|
if (MOUSECOORDS.x < nd.pWindow->middle().x)
|
||||||
|
forceDropAsMaster = true;
|
||||||
|
break;
|
||||||
|
case ORIENTATION_RIGHT:
|
||||||
|
if (MOUSECOORDS.x > nd.pWindow->middle().x)
|
||||||
|
forceDropAsMaster = true;
|
||||||
|
break;
|
||||||
|
case ORIENTATION_TOP:
|
||||||
|
if (MOUSECOORDS.y < nd.pWindow->middle().y)
|
||||||
|
forceDropAsMaster = true;
|
||||||
|
break;
|
||||||
|
case ORIENTATION_BOTTOM:
|
||||||
|
if (MOUSECOORDS.y > nd.pWindow->middle().y)
|
||||||
|
forceDropAsMaster = true;
|
||||||
|
break;
|
||||||
|
default: UNREACHABLE();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*PNEWISMASTER || WINDOWSONWORKSPACE == 1 || (!pWindow->m_bFirstMap && OPENINGON->isMaster)) {
|
if ((*PNEWISMASTER && g_pInputManager->dragMode != MBIND_MOVE) || WINDOWSONWORKSPACE == 1 || (WINDOWSONWORKSPACE > 2 && !pWindow->m_bFirstMap && OPENINGON->isMaster) ||
|
||||||
|
forceDropAsMaster) {
|
||||||
for (auto& nd : m_lMasterNodesData) {
|
for (auto& nd : m_lMasterNodesData) {
|
||||||
if (nd.isMaster && nd.workspaceID == PNODE->workspaceID) {
|
if (nd.isMaster && nd.workspaceID == PNODE->workspaceID) {
|
||||||
nd.isMaster = false;
|
nd.isMaster = false;
|
||||||
|
|
Loading…
Reference in a new issue