Fix deadlock on workspace scrolling (#403)

Fix deadlock on workspace scrolling
This commit is contained in:
Alex 2019-07-06 10:30:57 +02:00 committed by GitHub
commit d607a4e33f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 16 deletions

View File

@ -218,6 +218,8 @@ bool Workspaces::handleScroll(GdkEventScroll *e) {
if (dir == SCROLL_DIR::NONE) {
return true;
}
std::string name;
{
std::lock_guard<std::mutex> lock(mutex_);
auto it = std::find_if(workspaces_.begin(), workspaces_.end(), [](const auto &workspace) {
return workspace["focused"].asBool();
@ -225,7 +227,6 @@ bool Workspaces::handleScroll(GdkEventScroll *e) {
if (it == workspaces_.end()) {
return true;
}
std::string name;
if (dir == SCROLL_DIR::DOWN || dir == SCROLL_DIR::RIGHT) {
name = getCycleWorkspace(it, false);
} else if (dir == SCROLL_DIR::UP || dir == SCROLL_DIR::LEFT) {
@ -236,6 +237,7 @@ bool Workspaces::handleScroll(GdkEventScroll *e) {
if (name == (*it)["name"].asString()) {
return true;
}
}
try {
ipc_.sendCmd(IPC_COMMAND, fmt::format("workspace \"{}\"", name));
} catch (const std::exception &e) {