diff --git a/src/Compositor.cpp b/src/Compositor.cpp index eb51a1f4..ff0083d0 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -813,6 +813,24 @@ CWindow* CCompositor::windowFloatingFromCursor() { return nullptr; } +CWindow* CCompositor::windowFloatingFromCursorIgnore(CWindow* pWindow) { + for (auto& w : m_vWindows | std::views::reverse) { + wlr_box box = w->getWindowInputBox(); + if (wlr_box_contains_point(&box, m_sWLRCursor->x, m_sWLRCursor->y) && w->m_bIsMapped && w->m_bIsFloating && !w->isHidden() && w->m_bPinned && !w->m_bNoFocus && + w.get() != pWindow) + return w.get(); + } + + for (auto& w : m_vWindows | std::views::reverse) { + wlr_box box = w->getWindowInputBox(); + if (wlr_box_contains_point(&box, m_sWLRCursor->x, m_sWLRCursor->y) && w->m_bIsMapped && w->m_bIsFloating && isWorkspaceVisible(w->m_iWorkspaceID) && !w->isHidden() && + !w->m_bPinned && !w->m_bNoFocus && w.get() != pWindow) + return w.get(); + } + + return nullptr; +} + wlr_surface* CCompositor::vectorWindowToSurface(const Vector2D& pos, CWindow* pWindow, Vector2D& sl) { if (!windowValidMapped(pWindow)) diff --git a/src/Compositor.hpp b/src/Compositor.hpp index 86460211..0ac5ab89 100644 --- a/src/Compositor.hpp +++ b/src/Compositor.hpp @@ -29,8 +29,7 @@ #include "plugins/PluginSystem.hpp" #include "helpers/Watchdog.hpp" -enum eManagersInitStage -{ +enum eManagersInitStage { STAGE_PRIORITY = 0, STAGE_LATE }; @@ -145,6 +144,7 @@ class CCompositor { Vector2D vectorToSurfaceLocal(const Vector2D&, CWindow*, wlr_surface*); CWindow* windowFromCursor(); CWindow* windowFloatingFromCursor(); + CWindow* windowFloatingFromCursorIgnore(CWindow*); CMonitor* getMonitorFromOutput(wlr_output*); CWindow* getWindowForPopup(wlr_xdg_popup*); CWindow* getWindowFromSurface(wlr_surface*); diff --git a/src/layout/IHyprLayout.cpp b/src/layout/IHyprLayout.cpp index 61bc2266..4ecdf39a 100644 --- a/src/layout/IHyprLayout.cpp +++ b/src/layout/IHyprLayout.cpp @@ -260,10 +260,44 @@ void IHyprLayout::onEndDragWindow() { g_pInputManager->refocus(); changeWindowFloatingMode(DRAGGINGWINDOW); DRAGGINGWINDOW->m_vLastFloatingSize = m_vDraggingWindowOriginalFloatSize; + } else if (g_pInputManager->dragMode == MBIND_MOVE) { + CWindow* pWindow = g_pCompositor->windowFloatingFromCursorIgnore(DRAGGINGWINDOW); + g_pHyprRenderer->damageWindow(DRAGGINGWINDOW); + + if (pWindow && pWindow->m_sGroupData.pNextWindow && // target is group + !pWindow->getGroupHead()->m_sGroupData.locked && // target unlocked + !(DRAGGINGWINDOW->m_sGroupData.pNextWindow && DRAGGINGWINDOW->getGroupHead()->m_sGroupData.locked) && // source unlocked or isn't group + !g_pKeybindManager->m_bGroupsLocked) { + + const auto MOUSECOORDS = g_pInputManager->getMouseCoordsInternal(); + bool handled = true; + + for (auto& wd : pWindow->m_dWindowDecorations) { + if (!wd->allowsInput()) + continue; + + if (wd->getWindowDecorationRegion().containsPoint(MOUSECOORDS)) { + wd->dragWindowToDecoration(DRAGGINGWINDOW, MOUSECOORDS); + handled = false; + break; + } + } + + if (handled) { + static const auto* USECURRPOS = &g_pConfigManager->getConfigValuePtr("group:insert_after_current")->intValue; + (*USECURRPOS ? pWindow : pWindow->getGroupTail())->insertWindowToGroup(DRAGGINGWINDOW); + } + + pWindow->setGroupCurrent(DRAGGINGWINDOW); + DRAGGINGWINDOW->updateWindowDecos(); + recalculateWindow(DRAGGINGWINDOW); + + g_pCompositor->focusWindow(DRAGGINGWINDOW); + return; + } } g_pHyprRenderer->damageWindow(DRAGGINGWINDOW); - g_pCompositor->focusWindow(DRAGGINGWINDOW); }