From 8fe1cec87ce4a0dc580a36be31fe198d375c21fa Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Tue, 22 Mar 2022 17:14:07 +0100 Subject: [PATCH] fixed floating window dragging and rendering --- README.md | 1 - src/Compositor.cpp | 16 ++++++++++++---- src/render/Renderer.cpp | 21 ++++++++++++++++++++- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a1644a8a..33e5e5bc 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,6 @@ Nevertheless, REPORT any you find! Make an issue! - Fadein/out - Window rules - Fix electron rendering issues - - Fix sloppy dragging of windows - Optimization - Fix weird scroll on XWayland - Become sane diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 4fe3b91f..f1609620 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -210,9 +210,17 @@ 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 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_iWorkspaceID == PMONITOR->activeWorkspace) + if (wlr_box_contains_point(&box, pos.x, pos.y) && w.m_bIsFloating && isWorkspaceVisible(w.m_iWorkspaceID)) + return &w; + } + + 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_bIsFloating && PMONITOR->activeWorkspace == w.m_iWorkspaceID) return &w; } @@ -236,7 +244,7 @@ CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos) { // TODO: make an actual Z-system 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_bIsFloating && w.m_iWorkspaceID == PMONITOR->activeWorkspace) + if (wlr_box_contains_point(&box, m_sWLRCursor->x, m_sWLRCursor->y) && w.m_bIsFloating && isWorkspaceVisible(w.m_iWorkspaceID)) return &w; } @@ -256,7 +264,7 @@ CWindow* CCompositor::windowFromCursor() { // TODO: make an actual Z-system 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_bIsFloating && w.m_iWorkspaceID == PMONITOR->activeWorkspace) + if (wlr_box_contains_point(&box, m_sWLRCursor->x, m_sWLRCursor->y) && w.m_bIsFloating && isWorkspaceVisible(w.m_iWorkspaceID)) return &w; } @@ -273,7 +281,7 @@ CWindow* CCompositor::windowFloatingFromCursor() { const auto PMONITOR = getMonitorFromCursor(); 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_bIsFloating && w.m_iWorkspaceID == PMONITOR->activeWorkspace) + if (wlr_box_contains_point(&box, m_sWLRCursor->x, m_sWLRCursor->y) && w.m_bIsFloating && isWorkspaceVisible(w.m_iWorkspaceID)) return &w; } diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 6239c3c5..1c0f4ad2 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -109,15 +109,34 @@ void CHyprRenderer::renderAllClientsForMonitor(const int& ID, timespec* time) { return; } + // Non-floating for (auto& w : g_pCompositor->m_lWindows) { if (!g_pCompositor->windowValidMapped(&w)) continue; + if (w.m_bIsFloating) + continue; // floating are in second pass + + if (!shouldRenderWindow(&w, PMONITOR)) + continue; + + // render the bad boy + renderWindow(&w, PMONITOR, time, true); + } + + // floating on top + for (auto& w : g_pCompositor->m_lWindows) { + if (!g_pCompositor->windowValidMapped(&w)) + continue; + + if (!w.m_bIsFloating) + continue; + if (!shouldRenderWindow(&w, PMONITOR)) continue; // render the bad boy - renderWindow(&w, PMONITOR, time, true); + renderWindow(&w, PMONITOR, time, true); } // Render surfaces above windows for monitor