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:the workspace data is null in a small probability #2764

Closed
wants to merge 1 commit into from
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
6 changes: 6 additions & 0 deletions src/modules/hyprland/workspaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@
#include <algorithm>
#include <charconv>
#include <memory>
#include <shared_mutex>
#include <string>
#include <thread>
#include <utility>
#include <variant>

#include "util/regex_collection.hpp"

namespace waybar::modules::hyprland {

std::shared_mutex workspaceCreateSmtx;

int Workspaces::windowRewritePriorityFunction(std::string const &window_rule) {
// Rules that match against title are prioritized
// Rules that don't specify if they're matching against either title or class are deprioritized
Expand Down Expand Up @@ -161,6 +165,7 @@ auto Workspaces::update() -> void {
}

// add workspaces that wait to be created
std::shared_lock<std::shared_mutex> workspaceCreateShareLock(workspaceCreateSmtx);
unsigned int currentCreateWorkspaceNum = 0;
for (Json::Value const &workspaceToCreate : m_workspacesToCreate) {
createWorkspace(workspaceToCreate);
Expand Down Expand Up @@ -300,6 +305,7 @@ void Workspaces::onWorkspaceCreated(std::string const &payload) {
if (name == payload &&
(allOutputs() || m_bar.output->name == workspaceJson["monitor"].asString()) &&
(showSpecial() || !name.starts_with("special")) && !isDoubleSpecial(payload)) {
std::unique_lock<std::shared_mutex> workspaceCreateUniqueLock(workspaceCreateSmtx);
m_workspacesToCreate.push_back(workspaceJson);
break;
}
Expand Down
Loading