mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
Fix deadlock on workspace scrolling
Make the mutex guard lifecycle finish before the send ipc command by adding scope around the code. Fixes #395 .
This commit is contained in:
parent
67ad0e69ce
commit
a6c0bc5a52
@ -218,6 +218,8 @@ bool Workspaces::handleScroll(GdkEventScroll *e) {
|
|||||||
if (dir == SCROLL_DIR::NONE) {
|
if (dir == SCROLL_DIR::NONE) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
std::string name;
|
||||||
|
{
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
std::lock_guard<std::mutex> lock(mutex_);
|
||||||
auto it = std::find_if(workspaces_.begin(), workspaces_.end(), [](const auto &workspace) {
|
auto it = std::find_if(workspaces_.begin(), workspaces_.end(), [](const auto &workspace) {
|
||||||
return workspace["focused"].asBool();
|
return workspace["focused"].asBool();
|
||||||
@ -225,7 +227,6 @@ bool Workspaces::handleScroll(GdkEventScroll *e) {
|
|||||||
if (it == workspaces_.end()) {
|
if (it == workspaces_.end()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
std::string name;
|
|
||||||
if (dir == SCROLL_DIR::DOWN || dir == SCROLL_DIR::RIGHT) {
|
if (dir == SCROLL_DIR::DOWN || dir == SCROLL_DIR::RIGHT) {
|
||||||
name = getCycleWorkspace(it, false);
|
name = getCycleWorkspace(it, false);
|
||||||
} else if (dir == SCROLL_DIR::UP || dir == SCROLL_DIR::LEFT) {
|
} else if (dir == SCROLL_DIR::UP || dir == SCROLL_DIR::LEFT) {
|
||||||
@ -236,6 +237,7 @@ bool Workspaces::handleScroll(GdkEventScroll *e) {
|
|||||||
if (name == (*it)["name"].asString()) {
|
if (name == (*it)["name"].asString()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
ipc_.sendCmd(IPC_COMMAND, fmt::format("workspace \"{}\"", name));
|
ipc_.sendCmd(IPC_COMMAND, fmt::format("workspace \"{}\"", name));
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user