mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 15:45:58 +01:00
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
This commit is contained in:
parent
b784931e67
commit
d61e4f9ad7
2 changed files with 30 additions and 0 deletions
|
@ -188,6 +188,7 @@ void CConfigManager::setDefaultVars() {
|
||||||
configValues["master:inherit_fullscreen"].intValue = 1;
|
configValues["master:inherit_fullscreen"].intValue = 1;
|
||||||
configValues["master:allow_small_split"].intValue = 0;
|
configValues["master:allow_small_split"].intValue = 0;
|
||||||
configValues["master:smart_resizing"].intValue = 1;
|
configValues["master:smart_resizing"].intValue = 1;
|
||||||
|
configValues["master:drop_at_cursor"].intValue = 1;
|
||||||
|
|
||||||
configValues["animations:enabled"].intValue = 1;
|
configValues["animations:enabled"].intValue = 1;
|
||||||
|
|
||||||
|
|
|
@ -132,6 +132,35 @@ void CHyprMasterLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection direc
|
||||||
|
|
||||||
pWindow->applyGroupRules();
|
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)) {
|
if (*PNEWISMASTER || WINDOWSONWORKSPACE == 1 || (!pWindow->m_bFirstMap && OPENINGON->isMaster)) {
|
||||||
for (auto& nd : m_lMasterNodesData) {
|
for (auto& nd : m_lMasterNodesData) {
|
||||||
if (nd.isMaster && nd.workspaceID == PNODE->workspaceID) {
|
if (nd.isMaster && nd.workspaceID == PNODE->workspaceID) {
|
||||||
|
|
Loading…
Reference in a new issue