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
This commit is contained in:
nyx 2025-04-01 18:45:51 -04:00 committed by GitHub
parent 1f0fd79b91
commit 3a47c73f34
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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);