From 3a47c73f34d358c55e97927b0682dbdda19e24c1 Mon Sep 17 00:00:00 2001 From: nyx Date: Tue, 1 Apr 2025 18:45:51 -0400 Subject: [PATCH] layout: center floating window at cursor when picked up from fullscreen (#9780) * layout: center floating window at cursor when picked up from fullscreen when picking up a floating window after it had been fullscreened before it would return to its previous position which looked ugly because the cursor could be no where near the windows original position, this patch makes it so that the window is returned to the users current cursor position * E --- src/layout/IHyprLayout.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/layout/IHyprLayout.cpp b/src/layout/IHyprLayout.cpp index dc6de9e3a..b353a50cf 100644 --- a/src/layout/IHyprLayout.cpp +++ b/src/layout/IHyprLayout.cpp @@ -240,7 +240,8 @@ void IHyprLayout::onBeginDragWindow() { return; } - if (DRAGGINGWINDOW->isFullscreen()) { + const bool WAS_FULLSCREEN = DRAGGINGWINDOW->isFullscreen(); + if (WAS_FULLSCREEN) { Debug::log(LOG, "Dragging a fullscreen window"); g_pCompositor->setWindowFullscreenInternal(DRAGGINGWINDOW, FSMODE_NONE); } @@ -257,7 +258,10 @@ void IHyprLayout::onBeginDragWindow() { m_vDraggingWindowOriginalFloatSize = DRAGGINGWINDOW->m_vLastFloatingSize; - if (!DRAGGINGWINDOW->m_bIsFloating) { + if (WAS_FULLSCREEN && DRAGGINGWINDOW->m_bIsFloating) { + const auto MOUSECOORDS = g_pInputManager->getMouseCoordsInternal(); + *DRAGGINGWINDOW->m_vRealPosition = MOUSECOORDS - DRAGGINGWINDOW->m_vRealSize->goal() / 2.f; + } else if (!DRAGGINGWINDOW->m_bIsFloating) { if (g_pInputManager->dragMode == MBIND_MOVE) { DRAGGINGWINDOW->m_vLastFloatingSize = (DRAGGINGWINDOW->m_vRealSize->goal() * 0.8489).clamp(Vector2D{5, 5}, Vector2D{}).floor(); changeWindowFloatingMode(DRAGGINGWINDOW);