swallowing: improved naming coherency

This commit is contained in:
Tom Benham 2026-01-15 11:51:11 +01:00
parent fb644d12e3
commit dee93186f0
5 changed files with 38 additions and 38 deletions

View file

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

View file

@ -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 {};

View file

@ -418,7 +418,7 @@ std::string CHyprCtl::getWindowData(PHLWINDOW w, eHyprCtlOutputFormat format) {
(sc<int>(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<int>(w->m_isX11) == 1 ? "true" : "false"), (w->m_pinned ? "true" : "false"),
sc<uint8_t>(w->m_fullscreenState.internal), sc<uint8_t>(w->m_fullscreenState.client), (w->m_createdOverFullscreen ? "true" : "false"), getGroupedData(w, format),
getTagsData(w, format), rc<uintptr_t>(w->m_swallowed.get()), getFocusHistoryID(w), (g_pInputManager->isWindowInhibiting(w, false) ? "true" : "false"),
getTagsData(w, format), rc<uintptr_t>(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<int>(w->m_realPosition->goal().x), sc<int>(w->m_realPosition->goal().y), sc<int>(w->m_realSize->goal().x), sc<int>(w->m_realSize->goal().y),
w->m_workspace ? w->workspaceID() : WORKSPACE_INVALID, (!w->m_workspace ? "" : w->m_workspace->m_name), sc<int>(w->m_isFloating), w->monitorID(), w->m_class,
w->m_title, w->m_initialClass, w->m_initialTitle, w->getPID(), sc<int>(w->m_isX11), sc<int>(w->m_pinned), sc<uint8_t>(w->m_fullscreenState.internal),
sc<uint8_t>(w->m_fullscreenState.client), sc<int>(w->m_createdOverFullscreen), getGroupedData(w, format), getTagsData(w, format), rc<uintptr_t>(w->m_swallowed.get()),
sc<uint8_t>(w->m_fullscreenState.client), sc<int>(w->m_createdOverFullscreen), getGroupedData(w, format), getTagsData(w, format), rc<uintptr_t>(w->m_swallowee.get()),
getFocusHistoryID(w), sc<int>(g_pInputManager->isWindowInhibiting(w, false)), w->xdgTag().value_or(""), w->xdgDescription().value_or(""),
NContentType::toString(w->getContentType()), w->m_stableID);
}

View file

@ -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<std::string>("misc:swallow_regex");
static auto PSWALLOWEXREGEX = CConfigValue<std::string>("misc:swallow_exception_regex");
static auto PSWALLOW = CConfigValue<Config::INTEGER>("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;

View file

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