Skip to content

Commit 9477792

Browse files
authored
Merge pull request #4272 from labruzese/master
fix: hyprland named persistent workspaces
2 parents ee9dc6a + 6d3b93b commit 9477792

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/modules/hyprland/workspaces.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,8 @@ void Workspaces::loadPersistentWorkspacesFromConfig(Json::Value const &clientsJs
257257
// value is an array => create defined workspaces for this monitor
258258
if (canCreate) {
259259
for (const Json::Value &workspace : value) {
260-
if (workspace.isInt()) {
261-
spdlog::debug("Creating workspace {} on monitor {}", workspace, currentMonitor);
262-
persistentWorkspacesToCreate.emplace_back(std::to_string(workspace.asInt()));
263-
}
260+
spdlog::debug("Creating workspace {} on monitor {}", workspace, currentMonitor);
261+
persistentWorkspacesToCreate.emplace_back(workspace.asString());
264262
}
265263
} else {
266264
// key is the workspace and value is array of monitors to create on
@@ -948,9 +946,17 @@ bool Workspaces::updateWindowsToCreate() {
948946
void Workspaces::updateWorkspaceStates() {
949947
const std::vector<int> visibleWorkspaces = getVisibleWorkspaces();
950948
auto updatedWorkspaces = m_ipc.getSocket1JsonReply("workspaces");
949+
950+
auto currentWorkspace = m_ipc.getSocket1JsonReply("activeworkspace");
951+
std::string currentWorkspaceName =
952+
currentWorkspace.isMember("name") ? currentWorkspace["name"].asString() : "";
953+
951954
for (auto &workspace : m_workspaces) {
955+
bool isActiveByName =
956+
!currentWorkspaceName.empty() && workspace->name() == currentWorkspaceName;
957+
952958
workspace->setActive(
953-
workspace->id() == m_activeWorkspaceId ||
959+
workspace->id() == m_activeWorkspaceId || isActiveByName ||
954960
(workspace->isSpecial() && workspace->name() == m_activeSpecialWorkspaceName));
955961
if (workspace->isActive() && workspace->isUrgent()) {
956962
workspace->setUrgent(false);

0 commit comments

Comments
 (0)