Skip to content

Fix #2945: Persistent workspace disappear after being active #2946

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/modules/hyprland/workspaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -599,8 +599,7 @@ void Workspaces::createWorkspace(Json::Value const &workspace_data,
});

if (workspace != m_workspaces.end()) {
// don't recreate workspace, but update persistency if necessary
(*workspace)->setPersistent(workspace_data["persistent"].asBool());
// don't recreate workspace if it already exists
return;
Comment on lines 601 to 603
Copy link
Contributor

@aruhier aruhier Feb 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you might prefer this:

  if (workspace != m_workspaces.end()) {
    // don't recreate workspace, but update persistency if necessary
    //
    // An update is necessary only when the persistency was false and is now true. The update
    // of the persistency in Hyprland should not trigger a workspace creation.
    // Without this check, the persistency set in the waybar config will be overridden by the one
    // set in Hyprland when Hyprland creates the workspace.
    if (!(*workspace)->isPersistent()) {
      (*workspace)->setPersistent(workspace_data["persistent"].asBool());
    }
    return;
  }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated my comment as it was misleading. Hyprland doesn't send any event for the creation/update of a rule of a workspace, therefore updating persistent in Hyprland will not trigger anything in Waybar. It'll however trigger the removal of the workspace if it's persistency is updated to false and the workspace is empty.

Therefore, I think it's good for now to support only updating from non persistent to persistent, which would work in most cases.

I proposed an in my opinion better option in #2603 (comment), but it will be maybe a bit longer to implement.

}

Expand Down