Skip to content
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

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

Closed

Conversation

zjeffer
Copy link
Contributor

@zjeffer zjeffer commented Feb 20, 2024

If a user has a persistent workspace waybar config, and then switches to an empty workspace that is configured as persistent in the config, that empty workspace will be recreated with persistency disabled.

This PR fixes this by not updating the persistency. In hindsight this line was never really needed in the first place.

Comment on lines 601 to 603
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;
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.

@zjeffer
Copy link
Contributor Author

zjeffer commented Feb 25, 2024

Closing in favour of #2967

@zjeffer zjeffer closed this Feb 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants