From dee93186f0cd4647904a6eda50fa3c5460a7bfe9 Mon Sep 17 00:00:00 2001 From: Tom Benham Date: Thu, 15 Jan 2026 11:51:11 +0100 Subject: [PATCH] swallowing: improved naming coherency --- src/config/lua/objects/LuaWindow.cpp | 6 +-- src/config/shared/actions/ConfigActions.cpp | 16 +++---- src/debug/HyprCtl.cpp | 4 +- src/desktop/view/Window.cpp | 46 ++++++++++----------- src/desktop/view/Window.hpp | 4 +- 5 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/config/lua/objects/LuaWindow.cpp b/src/config/lua/objects/LuaWindow.cpp index 7fe87334d..c07b83761 100644 --- a/src/config/lua/objects/LuaWindow.cpp +++ b/src/config/lua/objects/LuaWindow.cpp @@ -137,9 +137,9 @@ static int windowIndex(lua_State* L) { lua_rawseti(L, -2, i++); } } else if (key == "swallowing") { - const auto swallowed = w->m_swallowed.lock(); - if (swallowed) - Objects::CLuaWindow::push(L, swallowed); + const auto swallowee = w->m_swallowee.lock(); + if (swallowee) + Objects::CLuaWindow::push(L, swallowee); else lua_pushnil(L); } else if (key == "focus_history_id") diff --git a/src/config/shared/actions/ConfigActions.cpp b/src/config/shared/actions/ConfigActions.cpp index 1664df181..8761a05d5 100644 --- a/src/config/shared/actions/ConfigActions.cpp +++ b/src/config/shared/actions/ConfigActions.cpp @@ -1155,17 +1155,17 @@ ActionResult Actions::forceRendererReload() { ActionResult Actions::toggleSwallow() { PHLWINDOWREF pWindow = Desktop::focusState()->window(); - if (!valid(pWindow) || !valid(pWindow->m_swallowed)) + if (!valid(pWindow) || !valid(pWindow->m_swallowee)) return {}; - if (pWindow->m_swallowed->m_currentlySwallowed) { - pWindow->m_swallowed->m_currentlySwallowed = false; - pWindow->m_swallowed->setHidden(false); - g_layoutManager->newTarget(pWindow->m_swallowed->layoutTarget(), pWindow->m_workspace->m_space); + if (pWindow->m_swallowee->m_currentlySwallowed) { + pWindow->m_swallowee->m_currentlySwallowed = false; + pWindow->m_swallowee->setHidden(false); + g_layoutManager->newTarget(pWindow->m_swallowee->layoutTarget(), pWindow->m_workspace->m_space); } else { - pWindow->m_swallowed->m_currentlySwallowed = true; - pWindow->m_swallowed->setHidden(true); - g_layoutManager->removeTarget(pWindow->m_swallowed->layoutTarget()); + pWindow->m_swallowee->m_currentlySwallowed = true; + pWindow->m_swallowee->setHidden(true); + g_layoutManager->removeTarget(pWindow->m_swallowee->layoutTarget()); } return {}; diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index b334a26e3..94a597f82 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -418,7 +418,7 @@ std::string CHyprCtl::getWindowData(PHLWINDOW w, eHyprCtlOutputFormat format) { (sc(w->m_isFloating) == 1 ? "true" : "false"), w->monitorID(), escapeJSONStrings(w->m_class), escapeJSONStrings(w->m_title), escapeJSONStrings(w->m_initialClass), escapeJSONStrings(w->m_initialTitle), w->getPID(), (sc(w->m_isX11) == 1 ? "true" : "false"), (w->m_pinned ? "true" : "false"), sc(w->m_fullscreenState.internal), sc(w->m_fullscreenState.client), (w->m_createdOverFullscreen ? "true" : "false"), getGroupedData(w, format), - getTagsData(w, format), rc(w->m_swallowed.get()), getFocusHistoryID(w), (g_pInputManager->isWindowInhibiting(w, false) ? "true" : "false"), + getTagsData(w, format), rc(w->m_swallowee.get()), getFocusHistoryID(w), (g_pInputManager->isWindowInhibiting(w, false) ? "true" : "false"), escapeJSONStrings(w->xdgTag().value_or("")), escapeJSONStrings(w->xdgDescription().value_or("")), escapeJSONStrings(NContentType::toString(w->getContentType())), w->m_stableID); } else { @@ -434,7 +434,7 @@ std::string CHyprCtl::getWindowData(PHLWINDOW w, eHyprCtlOutputFormat format) { sc(w->m_realPosition->goal().x), sc(w->m_realPosition->goal().y), sc(w->m_realSize->goal().x), sc(w->m_realSize->goal().y), w->m_workspace ? w->workspaceID() : WORKSPACE_INVALID, (!w->m_workspace ? "" : w->m_workspace->m_name), sc(w->m_isFloating), w->monitorID(), w->m_class, w->m_title, w->m_initialClass, w->m_initialTitle, w->getPID(), sc(w->m_isX11), sc(w->m_pinned), sc(w->m_fullscreenState.internal), - sc(w->m_fullscreenState.client), sc(w->m_createdOverFullscreen), getGroupedData(w, format), getTagsData(w, format), rc(w->m_swallowed.get()), + sc(w->m_fullscreenState.client), sc(w->m_createdOverFullscreen), getGroupedData(w, format), getTagsData(w, format), rc(w->m_swallowee.get()), getFocusHistoryID(w), sc(g_pInputManager->isWindowInhibiting(w, false)), w->xdgTag().value_or(""), w->xdgDescription().value_or(""), NContentType::toString(w->getContentType()), w->m_stableID); } diff --git a/src/desktop/view/Window.cpp b/src/desktop/view/Window.cpp index 298129d7a..2c52d9a7d 100644 --- a/src/desktop/view/Window.cpp +++ b/src/desktop/view/Window.cpp @@ -525,10 +525,10 @@ void CWindow::moveToWorkspace(PHLWORKSPACE pWorkspace) { Event::bus()->m_events.window.moveToWorkspace.emit(m_self.lock(), pWorkspace); } - if (const auto SWALLOWED = m_swallowed.lock()) { - if (SWALLOWED->m_currentlySwallowed) { - SWALLOWED->moveToWorkspace(pWorkspace); - SWALLOWED->m_monitor = m_monitor; + if (const auto SWALLOWEE = m_swallowee.lock()) { + if (SWALLOWEE->m_currentlySwallowed) { + SWALLOWEE->moveToWorkspace(pWorkspace); + SWALLOWEE->m_monitor = m_monitor; } } @@ -1405,7 +1405,7 @@ void CWindow::warpCursor(bool force) { g_pCompositor->warpCursorTo(middle(), force); } -PHLWINDOW CWindow::getSwallower() { +PHLWINDOW CWindow::getSwallowee() { static auto PSWALLOWREGEX = CConfigValue("misc:swallow_regex"); static auto PSWALLOWEXREGEX = CConfigValue("misc:swallow_exception_regex"); static auto PSWALLOW = CConfigValue("misc:enable_swallow"); @@ -2088,13 +2088,13 @@ void CWindow::mapWindow() { Log::logger->log(Log::DEBUG, "Requested monitor, applying to {:mw}", m_self.lock()); } - // Verify window swallowing. Get the swallower before calling onWindowCreated(m_self.lock()) because getSwallower() wouldn't get it after if m_self.lock() gets auto grouped. - const auto SWALLOWER = getSwallower(); + // Verify window swallowing. Get the swallowee before calling onWindowCreated(m_self.lock()) because getSwallowee() wouldn't get it after if m_self.lock() gets auto grouped. + const auto SWALLOWEE = getSwallowee(); // m_hasSwallower prevents secondary windows to swallow the parent when it's been unswallowed with `toggleswallow`. - if (SWALLOWER && !SWALLOWER->m_hasSwallower) { - SWALLOWER->m_currentlySwallowed = true; - SWALLOWER->m_hasSwallower = true; - m_swallowed = SWALLOWER; + if (SWALLOWEE && !SWALLOWEE->m_hasSwallower) { + SWALLOWEE->m_currentlySwallowed = true; + SWALLOWEE->m_hasSwallower = true; + m_swallowee = SWALLOWEE; } // emit the IPC event before the layout might focus the window to avoid a focus event first @@ -2226,9 +2226,9 @@ void CWindow::mapWindow() { } // swallow - if (m_swallowed) { - g_layoutManager->removeTarget(SWALLOWER->layoutTarget()); - SWALLOWER->setHidden(true); + if (m_swallowee) { + g_layoutManager->removeTarget(SWALLOWEE->layoutTarget()); + SWALLOWEE->setHidden(true); } m_firstMap = false; @@ -2312,20 +2312,20 @@ void CWindow::unmapWindow() { g_pHyprRenderer->makeSnapshot(m_self.lock()); // swallowing - if (valid(m_swallowed)) { - if (m_swallowed->m_currentlySwallowed) { - m_swallowed->m_currentlySwallowed = false; - m_swallowed->setHidden(false); + if (const auto SWALLOWEE = m_swallowee.lock()) { + if (SWALLOWEE->m_currentlySwallowed) { + SWALLOWEE->m_currentlySwallowed = false; + SWALLOWEE->setHidden(false); if (m_group) - m_swallowed->m_groupSwallowed = true; // flag for the swallowed window to be created into the group where it belongs when auto_group = false. + SWALLOWEE->m_groupSwallowed = true; // flag for the swallowed window to be created into the group where it belongs when auto_group = false. - g_layoutManager->newTarget(m_swallowed->layoutTarget(), m_workspace->m_space); + g_layoutManager->newTarget(SWALLOWEE->layoutTarget(), m_workspace->m_space); } - m_swallowed->m_groupSwallowed = false; - m_swallowed->m_hasSwallower = false; - m_swallowed.reset(); + SWALLOWEE->m_groupSwallowed = false; + SWALLOWEE->m_hasSwallower = false; + m_swallowee.reset(); } bool wasLastWindow = false; diff --git a/src/desktop/view/Window.hpp b/src/desktop/view/Window.hpp index 0e139ae13..cc861c1bf 100644 --- a/src/desktop/view/Window.hpp +++ b/src/desktop/view/Window.hpp @@ -257,7 +257,7 @@ namespace Desktop::View { int m_monitorMovedFrom = -1; // -1 means not moving // swallowing - PHLWINDOWREF m_swallowed; + PHLWINDOWREF m_swallowee; bool m_currentlySwallowed = false; bool m_groupSwallowed = false; bool m_hasSwallower = false; @@ -372,7 +372,7 @@ namespace Desktop::View { std::string fetchTitle(); std::string fetchClass(); void warpCursor(bool force = false); - PHLWINDOW getSwallower(); + PHLWINDOW getSwallowee(); bool isX11OverrideRedirect(); bool isModal(); Vector2D realToReportSize();