diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 5f444fe8..8dd5c561 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -242,8 +242,7 @@ bool CCompositor::windowExists(CWindow* pWindow) { CWindow* CCompositor::vectorToWindow(const Vector2D& pos) { const auto PMONITOR = getMonitorFromVector(pos); - // first loop over floating cuz they're above - // TODO: make an actual Z-system + // first loop over floating cuz they're above, m_lWindows should be sorted bottom->top, for tiled it doesn't matter. for (auto& w : m_lWindows) { wlr_box box = {w.m_vRealPosition.x, w.m_vRealPosition.y, w.m_vRealSize.x, w.m_vRealSize.y}; if (wlr_box_contains_point(&box, pos.x, pos.y) && w.m_bIsMapped && w.m_bIsFloating && isWorkspaceVisible(w.m_iWorkspaceID)) @@ -272,8 +271,7 @@ CWindow* CCompositor::vectorToWindowTiled(const Vector2D& pos) { CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos) { const auto PMONITOR = getMonitorFromVector(pos); - // first loop over floating cuz they're above - // TODO: make an actual Z-system + // first loop over floating cuz they're above, m_lWindows should be sorted bottom->top, for tiled it doesn't matter. for (auto& w : m_lWindows) { wlr_box box = {w.m_vRealPosition.x, w.m_vRealPosition.y, w.m_vRealSize.x, w.m_vRealSize.y}; if (w.m_bIsFloating && w.m_bIsMapped && wlr_box_contains_point(&box, m_sWLRCursor->x, m_sWLRCursor->y) && isWorkspaceVisible(w.m_iWorkspaceID)) @@ -292,8 +290,7 @@ CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos) { CWindow* CCompositor::windowFromCursor() { const auto PMONITOR = getMonitorFromCursor(); - // first loop over floating cuz they're above - // TODO: make an actual Z-system + // first loop over floating cuz they're above, m_lWindows should be sorted bottom->top, for tiled it doesn't matter. for (auto& w : m_lWindows) { wlr_box box = {w.m_vRealPosition.x, w.m_vRealPosition.y, w.m_vRealSize.x, w.m_vRealSize.y}; if (wlr_box_contains_point(&box, m_sWLRCursor->x, m_sWLRCursor->y) && w.m_bIsMapped && w.m_bIsFloating && isWorkspaceVisible(w.m_iWorkspaceID)) @@ -532,4 +529,16 @@ bool CCompositor::isWindowActive(CWindow* pWindow) { const auto PSURFACE = g_pXWaylandManager->getWindowSurface(pWindow); return PSURFACE == m_pLastFocus || pWindow == m_pLastWindow; +} + +void CCompositor::moveWindowToTop(CWindow* pWindow) { + if (!windowValidMapped(pWindow)) + return; + + for (auto it = m_lWindows.begin(); it != m_lWindows.end(); ++it) { + if (&(*it) == pWindow) { + m_lWindows.splice(m_lWindows.end(), m_lWindows, it); + break; + } + } } \ No newline at end of file diff --git a/src/Compositor.hpp b/src/Compositor.hpp index 4bf5d85b..06daa6f9 100644 --- a/src/Compositor.hpp +++ b/src/Compositor.hpp @@ -94,6 +94,7 @@ public: CWindow* getFullscreenWindowOnWorkspace(const int&); bool doesSeatAcceptInput(wlr_surface*); bool isWindowActive(CWindow*); + void moveWindowToTop(CWindow*); private: void initAllSignals(); diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index 5e4be345..4e12fc49 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -304,6 +304,8 @@ void CHyprDwindleLayout::changeWindowFloatingMode(CWindow* pWindow) { pWindow->m_vRealSize = PSAVEDSIZE; } else { onWindowRemoved(pWindow); + + g_pCompositor->moveWindowToTop(pWindow); } } @@ -327,6 +329,7 @@ void CHyprDwindleLayout::onBeginDragWindow() { if (!DRAGGINGWINDOW->m_bIsFloating) { DRAGGINGWINDOW->m_bDraggingTiled = true; changeWindowFloatingMode(DRAGGINGWINDOW); + DRAGGINGWINDOW->m_bIsFloating = true; } else { DRAGGINGWINDOW->m_bDraggingTiled = false; } @@ -339,8 +342,11 @@ void CHyprDwindleLayout::onBeginDragWindow() { void CHyprDwindleLayout::onEndDragWindow() { const auto DRAGGINGWINDOW = g_pInputManager->currentlyDraggedWindow; - if (DRAGGINGWINDOW->m_bDraggingTiled) + if (DRAGGINGWINDOW->m_bDraggingTiled) { + DRAGGINGWINDOW->m_bIsFloating = false; changeWindowFloatingMode(DRAGGINGWINDOW); + } + } void CHyprDwindleLayout::onMouseMove(const Vector2D& mousePos) { @@ -419,6 +425,8 @@ void CHyprDwindleLayout::onWindowCreatedFloating(CWindow* pWindow) { g_pXWaylandManager->setWindowSize(pWindow, pWindow->m_vRealSize); g_pCompositor->fixXWaylandWindowsOnWorkspace(PMONITOR->activeWorkspace); + + g_pCompositor->moveWindowToTop(pWindow); } void CHyprDwindleLayout::fullscreenRequestForWindow(CWindow* pWindow) { @@ -466,6 +474,8 @@ void CHyprDwindleLayout::fullscreenRequestForWindow(CWindow* pWindow) { g_pXWaylandManager->setWindowSize(pWindow, pWindow->m_vRealSize); } + g_pCompositor->moveWindowToTop(pWindow); + // we need to fix XWayland windows by sending them to NARNIA // because otherwise they'd still be recieving mouse events g_pCompositor->fixXWaylandWindowsOnWorkspace(PMONITOR->activeWorkspace);