summaryrefslogtreecommitdiff
path: root/src/layout/MasterLayout.cpp
diff options
context:
space:
mode:
authorJeremy Huang <66577496+thejch@users.noreply.github.com>2023-10-03 14:16:57 -0700
committerGitHub <noreply@github.com>2023-10-03 22:16:57 +0100
commitd61e4f9ad75d51f15eac6bced13439899d66a950 (patch)
treefc2519839d02ccc2c42858bf73559c30ce2048f9 /src/layout/MasterLayout.cpp
parentb784931e678f907b1f1e41d04485fefd8a1faaf8 (diff)
master: add option to drag and drop windows at cursor position (#3465)
* add option to drag and drop a window at cursor position * use getWindowIdealBoundingBoxIgnoreReserved
Diffstat (limited to 'src/layout/MasterLayout.cpp')
-rw-r--r--src/layout/MasterLayout.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/layout/MasterLayout.cpp b/src/layout/MasterLayout.cpp
index 624ded2a..6fa168c4 100644
--- a/src/layout/MasterLayout.cpp
+++ b/src/layout/MasterLayout.cpp
@@ -132,6 +132,35 @@ void CHyprMasterLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection direc
pWindow->applyGroupRules();
+ static auto* const PDROPATCURSOR = &g_pConfigManager->getConfigValuePtr("master:drop_at_cursor")->intValue;
+ const auto PWORKSPACEDATA = getMasterWorkspaceData(pWindow->m_iWorkspaceID);
+ eOrientation orientation = PWORKSPACEDATA->orientation;
+ const auto NODEIT = std::find(m_lMasterNodesData.begin(), m_lMasterNodesData.end(), *PNODE);
+ if (*PDROPATCURSOR && g_pInputManager->dragMode == MBIND_MOVE) {
+ // if dragging window to move, drop it at the cursor position instead of bottom/top of stack
+ for (auto it = m_lMasterNodesData.begin(); it != m_lMasterNodesData.end(); ++it) {
+ const wlr_box box = it->pWindow->getWindowIdealBoundingBoxIgnoreReserved();
+ if (wlr_box_contains_point(&box, MOUSECOORDS.x, MOUSECOORDS.y)) { // TODO: Deny when not using mouse
+ switch (orientation) {
+ case ORIENTATION_LEFT:
+ case ORIENTATION_RIGHT:
+ if (MOUSECOORDS.y > it->pWindow->middle().y)
+ ++it;
+ break;
+ case ORIENTATION_TOP:
+ case ORIENTATION_BOTTOM:
+ if (MOUSECOORDS.x > it->pWindow->middle().x)
+ ++it;
+ break;
+ case ORIENTATION_CENTER: break;
+ default: UNREACHABLE();
+ }
+ m_lMasterNodesData.splice(it, m_lMasterNodesData, NODEIT);
+ break;
+ }
+ }
+ }
+
if (*PNEWISMASTER || WINDOWSONWORKSPACE == 1 || (!pWindow->m_bFirstMap && OPENINGON->isMaster)) {
for (auto& nd : m_lMasterNodesData) {
if (nd.isMaster && nd.workspaceID == PNODE->workspaceID) {