aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJeremy Huang <[email protected]>2023-10-03 14:16:57 -0700
committerGitHub <[email protected]>2023-10-03 22:16:57 +0100
commitd61e4f9ad75d51f15eac6bced13439899d66a950 (patch)
treefc2519839d02ccc2c42858bf73559c30ce2048f9
parentb784931e678f907b1f1e41d04485fefd8a1faaf8 (diff)
downloadHyprland-d61e4f9ad75d51f15eac6bced13439899d66a950.tar.gz
Hyprland-d61e4f9ad75d51f15eac6bced13439899d66a950.zip
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
-rw-r--r--src/config/ConfigManager.cpp1
-rw-r--r--src/layout/MasterLayout.cpp29
2 files changed, 30 insertions, 0 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index d639df0c..42611be3 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -188,6 +188,7 @@ void CConfigManager::setDefaultVars() {
configValues["master:inherit_fullscreen"].intValue = 1;
configValues["master:allow_small_split"].intValue = 0;
configValues["master:smart_resizing"].intValue = 1;
+ configValues["master:drop_at_cursor"].intValue = 1;
configValues["animations:enabled"].intValue = 1;
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) {