Merge pull request #5248 from daher13/fix/refresh-on-changeid

fix(hyprland/workspaces): handle workspace ID changes
This commit is contained in:
Alexis Rouillard
2026-08-13 10:17:16 +02:00
committed by GitHub
3 changed files with 40 additions and 5 deletions
+32
View File
@@ -312,6 +312,8 @@ void Workspaces::onEvent(const std::string& ev) {
onSpecialWorkspaceActivated(payload);
} else if (eventName == "destroyworkspacev2") {
onWorkspaceDestroyed(payload);
} else if (eventName == "changeworkspaceid") {
onWorkspaceIdChanged(payload);
} else if (eventName == "createworkspacev2") {
onWorkspaceCreated(payload);
} else if (eventName == "focusedmonv2") {
@@ -449,6 +451,35 @@ void Workspaces::onWorkspaceRenamed(std::string const& payload) {
sortWorkspaces();
}
void Workspaces::onWorkspaceIdChanged(std::string const& payload) {
spdlog::debug("Workspace ID changed: {}", payload);
const auto [oldIdStr, newIdStr] = splitDoublePayload(payload);
const auto oldId = parseWorkspaceId(oldIdStr);
const auto newId = parseWorkspaceId(newIdStr);
if (!oldId.has_value() || !newId.has_value()) {
spdlog::warn("Invalid workspace ID change payload: {}", payload);
return;
}
for (auto& workspace : m_workspaces) {
if (workspace->id() == *oldId) {
spdlog::debug("Changing workspace ID from {} to {}", *oldId, *newId);
workspace->setId(*newId);
break;
}
}
if (m_activeWorkspaceId == *oldId) {
m_activeWorkspaceId = *newId;
}
sortWorkspaces();
updateWindowCount();
}
void Workspaces::onMonitorFocused(std::string const& payload) {
spdlog::trace("Monitor focused: {}", payload);
@@ -827,6 +858,7 @@ auto Workspaces::registerIpc() -> void {
m_ipc.registerForIPC("createworkspacev2", this);
m_ipc.registerForIPC("destroyworkspacev2", this);
m_ipc.registerForIPC("focusedmonv2", this);
m_ipc.registerForIPC("changeworkspaceid", this);
m_ipc.registerForIPC("moveworkspacev2", this);
m_ipc.registerForIPC("renameworkspace", this);
m_ipc.registerForIPC("openwindow", this);