mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-10-15 06:25:59 +00:00
workspaces: update persistence on workspace rename (#9368)
This commit is contained in:
@@ -3043,34 +3043,53 @@ bool CCompositor::shouldChangePreferredImageDescription() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCompositor::ensurePersistentWorkspacesPresent(const std::vector<SWorkspaceRule>& rules) {
|
void CCompositor::ensurePersistentWorkspacesPresent(const std::vector<SWorkspaceRule>& rules, PHLWORKSPACE pWorkspace) {
|
||||||
|
|
||||||
for (const auto& rule : rules) {
|
for (const auto& rule : rules) {
|
||||||
if (!rule.isPersistent)
|
if (!rule.isPersistent)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
PHLWORKSPACE PWORKSPACE = nullptr;
|
||||||
|
if (pWorkspace) {
|
||||||
|
if (pWorkspace->matchesStaticSelector(rule.workspaceString))
|
||||||
|
PWORKSPACE = pWorkspace;
|
||||||
|
else
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const auto PMONITOR = getMonitorFromString(rule.monitor);
|
const auto PMONITOR = getMonitorFromString(rule.monitor);
|
||||||
|
|
||||||
|
if (!PWORKSPACE) {
|
||||||
|
WORKSPACEID id = rule.workspaceId;
|
||||||
|
std::string wsname = rule.workspaceName;
|
||||||
|
|
||||||
|
if (id == WORKSPACE_INVALID) {
|
||||||
|
const auto R = getWorkspaceIDNameFromString(rule.workspaceString);
|
||||||
|
id = R.id;
|
||||||
|
wsname = R.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (id == WORKSPACE_INVALID) {
|
||||||
|
Debug::log(ERR, "ensurePersistentWorkspacesPresent: couldn't resolve id for workspace {}", rule.workspaceString);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
PWORKSPACE = getWorkspaceByID(id);
|
||||||
|
if (!PWORKSPACE)
|
||||||
|
createNewWorkspace(id, PMONITOR ? PMONITOR : m_pLastMonitor.lock(), wsname, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PWORKSPACE)
|
||||||
|
PWORKSPACE->m_bPersistent = true;
|
||||||
|
|
||||||
if (!PMONITOR) {
|
if (!PMONITOR) {
|
||||||
Debug::log(ERR, "ensurePersistentWorkspacesPresent: couldn't resolve monitor for {}, skipping", rule.monitor);
|
Debug::log(ERR, "ensurePersistentWorkspacesPresent: couldn't resolve monitor for {}, skipping", rule.monitor);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
WORKSPACEID id = rule.workspaceId;
|
if (PWORKSPACE) {
|
||||||
std::string wsname = rule.workspaceName;
|
|
||||||
if (id == WORKSPACE_INVALID) {
|
|
||||||
const auto R = getWorkspaceIDNameFromString(rule.workspaceString);
|
|
||||||
id = R.id;
|
|
||||||
wsname = R.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (id == WORKSPACE_INVALID) {
|
|
||||||
Debug::log(ERR, "ensurePersistentWorkspacesPresent: couldn't resolve id for workspace {}", rule.workspaceString);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (const auto PWORKSPACE = getWorkspaceByID(id); PWORKSPACE) {
|
|
||||||
if (PWORKSPACE->m_pMonitor == PMONITOR) {
|
if (PWORKSPACE->m_pMonitor == PMONITOR) {
|
||||||
Debug::log(LOG, "ensurePersistentWorkspacesPresent: workspace persistent {} already on {}", rule.workspaceString, PMONITOR->szName);
|
Debug::log(LOG, "ensurePersistentWorkspacesPresent: workspace persistent {} already on {}", rule.workspaceString, PMONITOR->szName);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3078,8 +3097,6 @@ void CCompositor::ensurePersistentWorkspacesPresent(const std::vector<SWorkspace
|
|||||||
moveWorkspaceToMonitor(PWORKSPACE, PMONITOR);
|
moveWorkspaceToMonitor(PWORKSPACE, PMONITOR);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
createNewWorkspace(id, PMONITOR ? PMONITOR : m_pLastMonitor.lock(), wsname, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// cleanup old
|
// cleanup old
|
||||||
|
@@ -147,7 +147,7 @@ class CCompositor {
|
|||||||
void setPreferredTransformForSurface(SP<CWLSurfaceResource> pSurface, wl_output_transform transform);
|
void setPreferredTransformForSurface(SP<CWLSurfaceResource> pSurface, wl_output_transform transform);
|
||||||
void updateSuspendedStates();
|
void updateSuspendedStates();
|
||||||
void onNewMonitor(SP<Aquamarine::IOutput> output);
|
void onNewMonitor(SP<Aquamarine::IOutput> output);
|
||||||
void ensurePersistentWorkspacesPresent(const std::vector<SWorkspaceRule>& rules);
|
void ensurePersistentWorkspacesPresent(const std::vector<SWorkspaceRule>& rules, PHLWORKSPACE pWorkspace = nullptr);
|
||||||
|
|
||||||
SImageDescription getPreferredImageDescription();
|
SImageDescription getPreferredImageDescription();
|
||||||
bool shouldChangePreferredImageDescription();
|
bool shouldChangePreferredImageDescription();
|
||||||
|
@@ -319,15 +319,17 @@ std::string CHyprCtl::getWorkspaceData(PHLWORKSPACE w, eHyprCtlOutputFormat form
|
|||||||
"windows": {},
|
"windows": {},
|
||||||
"hasfullscreen": {},
|
"hasfullscreen": {},
|
||||||
"lastwindow": "0x{:x}",
|
"lastwindow": "0x{:x}",
|
||||||
"lastwindowtitle": "{}"
|
"lastwindowtitle": "{}",
|
||||||
|
"ispersistent": {}
|
||||||
}})#",
|
}})#",
|
||||||
w->m_iID, escapeJSONStrings(w->m_szName), escapeJSONStrings(PMONITOR ? PMONITOR->szName : "?"),
|
w->m_iID, escapeJSONStrings(w->m_szName), escapeJSONStrings(PMONITOR ? PMONITOR->szName : "?"),
|
||||||
escapeJSONStrings(PMONITOR ? std::to_string(PMONITOR->ID) : "null"), w->getWindows(), ((int)w->m_bHasFullscreenWindow == 1 ? "true" : "false"),
|
escapeJSONStrings(PMONITOR ? std::to_string(PMONITOR->ID) : "null"), w->getWindows(), w->m_bHasFullscreenWindow ? "true" : "false",
|
||||||
(uintptr_t)PLASTW.get(), PLASTW ? escapeJSONStrings(PLASTW->m_szTitle) : "");
|
(uintptr_t)PLASTW.get(), PLASTW ? escapeJSONStrings(PLASTW->m_szTitle) : "", w->m_bPersistent ? "true" : "false");
|
||||||
} else {
|
} else {
|
||||||
return std::format("workspace ID {} ({}) on monitor {}:\n\tmonitorID: {}\n\twindows: {}\n\thasfullscreen: {}\n\tlastwindow: 0x{:x}\n\tlastwindowtitle: {}\n\n", w->m_iID,
|
return std::format(
|
||||||
w->m_szName, PMONITOR ? PMONITOR->szName : "?", PMONITOR ? std::to_string(PMONITOR->ID) : "null", w->getWindows(), (int)w->m_bHasFullscreenWindow,
|
"workspace ID {} ({}) on monitor {}:\n\tmonitorID: {}\n\twindows: {}\n\thasfullscreen: {}\n\tlastwindow: 0x{:x}\n\tlastwindowtitle: {}\n\tispersistent: {}\n\n",
|
||||||
(uintptr_t)PLASTW.get(), PLASTW ? PLASTW->m_szTitle : "");
|
w->m_iID, w->m_szName, PMONITOR ? PMONITOR->szName : "?", PMONITOR ? std::to_string(PMONITOR->ID) : "null", w->getWindows(), (int)w->m_bHasFullscreenWindow,
|
||||||
|
(uintptr_t)PLASTW.get(), PLASTW ? PLASTW->m_szTitle : "", (int)w->m_bPersistent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -648,6 +648,12 @@ void CWorkspace::rename(const std::string& name) {
|
|||||||
Debug::log(LOG, "CWorkspace::rename: Renaming workspace {} to '{}'", m_iID, name);
|
Debug::log(LOG, "CWorkspace::rename: Renaming workspace {} to '{}'", m_iID, name);
|
||||||
m_szName = name;
|
m_szName = name;
|
||||||
|
|
||||||
|
const auto WORKSPACERULE = g_pConfigManager->getWorkspaceRuleFor(m_pSelf.lock());
|
||||||
|
m_bPersistent = WORKSPACERULE.isPersistent;
|
||||||
|
|
||||||
|
if (WORKSPACERULE.isPersistent)
|
||||||
|
g_pCompositor->ensurePersistentWorkspacesPresent(std::vector<SWorkspaceRule>{WORKSPACERULE}, m_pSelf.lock());
|
||||||
|
|
||||||
g_pEventManager->postEvent({"renameworkspace", std::to_string(m_iID) + "," + m_szName});
|
g_pEventManager->postEvent({"renameworkspace", std::to_string(m_iID) + "," + m_szName});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user