diff options
| author | nyx <nnyyxxxx@protonmail.com> | 2025-04-01 18:45:51 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-02 00:45:51 +0200 |
| commit | 3a47c73f34d358c55e97927b0682dbdda19e24c1 (patch) | |
| tree | 926f6b32d3ebc4bcec53e22e56c4afe33c8b3324 /src/layout/IHyprLayout.cpp | |
| parent | 1f0fd79b910b798e650d6f0c546273bc83422526 (diff) | |
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
Diffstat (limited to 'src/layout/IHyprLayout.cpp')
| -rw-r--r-- | src/layout/IHyprLayout.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/layout/IHyprLayout.cpp b/src/layout/IHyprLayout.cpp index dc6de9e3..b353a50c 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); |
