fix: added active workspace matching by name as fallback

fixes bug where persistent workspaces would not be marked as active
because their id is based on creation time by hyprland and thus we can't
consistently match the id's without constantly changing them (this would
also cause issues with workspace sorting).
This commit is contained in:
Skylar Abruzese
2025-07-03 18:48:04 -04:00
parent 9ef6dc7380
commit 6d3b93bbf7

View File

@ -942,9 +942,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);