From 963c5cf818cb233f2d2df05cccc49b3a474a56d0 Mon Sep 17 00:00:00 2001 From: erStarr <253168930+erstarr@users.noreply.github.com> Date: Mon, 10 Aug 2026 16:36:14 +0200 Subject: [PATCH] config/actions: fix center not saving the new pos of a floating window (#15810) --- hyprtester/src/tests/main/dwindle.cpp | 43 +++++++++++++++++++++ src/config/shared/actions/ConfigActions.cpp | 6 ++- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/hyprtester/src/tests/main/dwindle.cpp b/hyprtester/src/tests/main/dwindle.cpp index 1d79292f1..5a57790f6 100644 --- a/hyprtester/src/tests/main/dwindle.cpp +++ b/hyprtester/src/tests/main/dwindle.cpp @@ -1180,3 +1180,46 @@ TEST_CASE(defaultHandledFsfocusInDirection) { EXPECT_CONTAINS(str, "fullscreenClient: 0"); } } + +TEST_CASE(dwindleFullsreenCenterDispatchSavesPos) { + /* + This test serves as a test for all layouts that use deafult FS behaviour + + Also tests hl.dsp.window.center() incidentally + + */ + + SPAWN_KITTY("kot"); + OK(getFromSocket("/dispatch hl.dsp.window.float({ action = 'set', window = 'class:kot' })")); + + OK(getFromSocket("/dispatch hl.dsp.window.move({ x =100 , y =100 , relative = false, window = 'class:kot' })")); + + { + auto str = getFromSocket("/activewindow"); + EXPECT_CONTAINS(str, "class: kot"); + EXPECT_CONTAINS(str, "at: 100,100"); + EXPECT_CONTAINS(str, "fullscreen: 0"); + EXPECT_CONTAINS(str, "fullscreenClient: 0"); + } + + OK(getFromSocket("/dispatch hl.dsp.window.center({ window = 'class:kot' })")); + + { + auto str = getFromSocket("/activewindow"); + EXPECT_CONTAINS(str, "class: kot"); + EXPECT_CONTAINS(str, "at: 0,0"); + EXPECT_CONTAINS(str, "fullscreen: 0"); + EXPECT_CONTAINS(str, "fullscreenClient: 0"); + } + + OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'fullscreen', action = 'set', window = 'class:kot' })")); + OK(getFromSocket("/dispatch hl.dsp.window.fullscreen({ mode = 'fullscreen', action = 'unset', window = 'class:kot' })")); + + { + auto str = getFromSocket("/activewindow"); + EXPECT_CONTAINS(str, "class: kot"); + EXPECT_CONTAINS(str, "at: 0,0"); + EXPECT_CONTAINS(str, "fullscreen: 0"); + EXPECT_CONTAINS(str, "fullscreenClient: 0"); + } +} \ No newline at end of file diff --git a/src/config/shared/actions/ConfigActions.cpp b/src/config/shared/actions/ConfigActions.cpp index d017c7abc..d07c04d26 100644 --- a/src/config/shared/actions/ConfigActions.cpp +++ b/src/config/shared/actions/ConfigActions.cpp @@ -567,8 +567,10 @@ ActionResult Actions::center(std::optional w) { const auto PMONITOR = window->m_monitor.lock(); - window->layoutTarget()->setPositionGlobal( - CBox{PMONITOR->logicalBoxMinusReserved().middle() - window->size(Desktop::View::IGeometric::GEOMETRIC_GOAL) / 2.F, window->layoutTarget()->position().size()}); + if (window->m_isFloating) + g_layoutManager->setTargetGeom( + CBox{PMONITOR->logicalBoxMinusReserved().middle() - window->size(Desktop::View::IGeometric::GEOMETRIC_GOAL) / 2.F, window->layoutTarget()->position().size()}, + window->m_target); return {}; }