diff options
| author | MightyPlaza <123664421+MightyPlaza@users.noreply.github.com> | 2023-10-29 20:14:47 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-29 20:14:47 +0000 |
| commit | 9abfa9efc627df0765652f862887626af02b5ae1 (patch) | |
| tree | 31258fc1d4fe3fbf5a34d8a6bd5670b0f0e398bc /src/layout | |
| parent | 7a5234a0cca2508b7a5ede1fc60dc3ae8b72a51c (diff) | |
input: handle mouse on decorations (#3560)
Diffstat (limited to 'src/layout')
| -rw-r--r-- | src/layout/DwindleLayout.cpp | 27 | ||||
| -rw-r--r-- | src/layout/IHyprLayout.cpp | 3 | ||||
| -rw-r--r-- | src/layout/MasterLayout.cpp | 27 |
3 files changed, 33 insertions, 24 deletions
diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index b034557e..984db38d 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -312,6 +312,19 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection dire return; } + if (!m_vOverrideFocalPoint && g_pInputManager->m_bWasDraggingWindow) { + for (auto& wd : OPENINGON->pWindow->m_dWindowDecorations) { + if (!wd->allowsInput()) + continue; + + if (wd->getWindowDecorationRegion().containsPoint(MOUSECOORDS)) { + if (!wd->onEndWindowDragOnDeco(pWindow, MOUSECOORDS)) + return; + break; + } + } + } + // if it's a group, add the window if (OPENINGON->pWindow->m_sGroupData.pNextWindow // target is group && !g_pKeybindManager->m_bGroupsLocked // global group lock disengaged @@ -327,18 +340,8 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection dire m_lDwindleNodesData.remove(*PNODE); - const wlr_box box = OPENINGON->pWindow->getDecorationByType(DECORATION_GROUPBAR)->getWindowDecorationRegion().getExtents(); - if (wlr_box_contains_point(&box, MOUSECOORDS.x, MOUSECOORDS.y)) { // TODO: Deny when not using mouse - const int SIZE = OPENINGON->pWindow->getGroupSize(); - const int INDEX = (int)((MOUSECOORDS.x - box.x) * 2 * SIZE / box.width + 1) / 2 - 1; - CWindow* pWindowInsertAfter = OPENINGON->pWindow->getGroupWindowByIndex(INDEX); - pWindowInsertAfter->insertWindowToGroup(pWindow); - if (INDEX == -1) - std::swap(pWindow->m_sGroupData.pNextWindow->m_sGroupData.head, pWindow->m_sGroupData.head); - } else { - static const auto* USECURRPOS = &g_pConfigManager->getConfigValuePtr("group:insert_after_current")->intValue; - (*USECURRPOS ? OPENINGON->pWindow : OPENINGON->pWindow->getGroupTail())->insertWindowToGroup(pWindow); - } + static const auto* USECURRPOS = &g_pConfigManager->getConfigValuePtr("group:insert_after_current")->intValue; + (*USECURRPOS ? OPENINGON->pWindow : OPENINGON->pWindow->getGroupTail())->insertWindowToGroup(pWindow); OPENINGON->pWindow->setGroupCurrent(pWindow); pWindow->applyGroupRules(); diff --git a/src/layout/IHyprLayout.cpp b/src/layout/IHyprLayout.cpp index 61bc2266..2bbda858 100644 --- a/src/layout/IHyprLayout.cpp +++ b/src/layout/IHyprLayout.cpp @@ -254,6 +254,7 @@ void IHyprLayout::onEndDragWindow() { g_pInputManager->unsetCursorImage(); g_pInputManager->currentlyDraggedWindow = nullptr; + g_pInputManager->m_bWasDraggingWindow = true; if (DRAGGINGWINDOW->m_bDraggingTiled) { DRAGGINGWINDOW->m_bIsFloating = false; @@ -265,6 +266,8 @@ void IHyprLayout::onEndDragWindow() { g_pHyprRenderer->damageWindow(DRAGGINGWINDOW); g_pCompositor->focusWindow(DRAGGINGWINDOW); + + g_pInputManager->m_bWasDraggingWindow = false; } void IHyprLayout::onMouseMove(const Vector2D& mousePos) { diff --git a/src/layout/MasterLayout.cpp b/src/layout/MasterLayout.cpp index ebbcc805..6ee88512 100644 --- a/src/layout/MasterLayout.cpp +++ b/src/layout/MasterLayout.cpp @@ -94,6 +94,19 @@ void CHyprMasterLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection direc const auto MOUSECOORDS = g_pInputManager->getMouseCoordsInternal(); + if (g_pInputManager->m_bWasDraggingWindow) { + for (auto& wd : OPENINGON->pWindow->m_dWindowDecorations) { + if (!wd->allowsInput()) + continue; + + if (wd->getWindowDecorationRegion().containsPoint(MOUSECOORDS)) { + if (!wd->onEndWindowDragOnDeco(pWindow, MOUSECOORDS)) + return; + break; + } + } + } + // if it's a group, add the window if (OPENINGON && OPENINGON != PNODE && OPENINGON->pWindow->m_sGroupData.pNextWindow // target is group && !g_pKeybindManager->m_bGroupsLocked // global group lock disengaged @@ -109,18 +122,8 @@ void CHyprMasterLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection direc m_lMasterNodesData.remove(*PNODE); - const wlr_box box = OPENINGON->pWindow->getDecorationByType(DECORATION_GROUPBAR)->getWindowDecorationRegion().getExtents(); - if (wlr_box_contains_point(&box, MOUSECOORDS.x, MOUSECOORDS.y)) { // TODO: Deny when not using mouse - const int SIZE = OPENINGON->pWindow->getGroupSize(); - const int INDEX = (int)((MOUSECOORDS.x - box.x) * 2 * SIZE / box.width + 1) / 2 - 1; - CWindow* pWindowInsertAfter = OPENINGON->pWindow->getGroupWindowByIndex(INDEX); - pWindowInsertAfter->insertWindowToGroup(pWindow); - if (INDEX == -1) - std::swap(pWindow->m_sGroupData.pNextWindow->m_sGroupData.head, pWindow->m_sGroupData.head); - } else { - static const auto* USECURRPOS = &g_pConfigManager->getConfigValuePtr("group:insert_after_current")->intValue; - (*USECURRPOS ? OPENINGON->pWindow : OPENINGON->pWindow->getGroupTail())->insertWindowToGroup(pWindow); - } + static const auto* USECURRPOS = &g_pConfigManager->getConfigValuePtr("group:insert_after_current")->intValue; + (*USECURRPOS ? OPENINGON->pWindow : OPENINGON->pWindow->getGroupTail())->insertWindowToGroup(pWindow); OPENINGON->pWindow->setGroupCurrent(pWindow); pWindow->applyGroupRules(); |
