Merge pull request #4272 from labruzese/master

fix: hyprland named persistent workspaces
This commit is contained in:
Alexis Rouillard
2025-07-13 09:07:26 +02:00
committed by GitHub

View File

@ -257,10 +257,8 @@ void Workspaces::loadPersistentWorkspacesFromConfig(Json::Value const &clientsJs
// value is an array => create defined workspaces for this monitor // value is an array => create defined workspaces for this monitor
if (canCreate) { if (canCreate) {
for (const Json::Value &workspace : value) { for (const Json::Value &workspace : value) {
if (workspace.isInt()) { spdlog::debug("Creating workspace {} on monitor {}", workspace, currentMonitor);
spdlog::debug("Creating workspace {} on monitor {}", workspace, currentMonitor); persistentWorkspacesToCreate.emplace_back(workspace.asString());
persistentWorkspacesToCreate.emplace_back(std::to_string(workspace.asInt()));
}
} }
} else { } else {
// key is the workspace and value is array of monitors to create on // key is the workspace and value is array of monitors to create on
@ -948,9 +946,17 @@ bool Workspaces::updateWindowsToCreate() {
void Workspaces::updateWorkspaceStates() { void Workspaces::updateWorkspaceStates() {
const std::vector<int> visibleWorkspaces = getVisibleWorkspaces(); const std::vector<int> visibleWorkspaces = getVisibleWorkspaces();
auto updatedWorkspaces = m_ipc.getSocket1JsonReply("workspaces"); auto updatedWorkspaces = m_ipc.getSocket1JsonReply("workspaces");
auto currentWorkspace = m_ipc.getSocket1JsonReply("activeworkspace");
std::string currentWorkspaceName =
currentWorkspace.isMember("name") ? currentWorkspace["name"].asString() : "";
for (auto &workspace : m_workspaces) { for (auto &workspace : m_workspaces) {
bool isActiveByName =
!currentWorkspaceName.empty() && workspace->name() == currentWorkspaceName;
workspace->setActive( workspace->setActive(
workspace->id() == m_activeWorkspaceId || workspace->id() == m_activeWorkspaceId || isActiveByName ||
(workspace->isSpecial() && workspace->name() == m_activeSpecialWorkspaceName)); (workspace->isSpecial() && workspace->name() == m_activeSpecialWorkspaceName));
if (workspace->isActive() && workspace->isUrgent()) { if (workspace->isActive() && workspace->isUrgent()) {
workspace->setUrgent(false); workspace->setUrgent(false);