Merge pull request #817 from pedrocr/sway-workspaces-disable-click

Add option for no workspace switch on click
pull/819/head
Alex 2020-08-12 20:45:04 +02:00 committed by GitHub
commit 4c4691dc2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 15 deletions

View File

@ -31,6 +31,11 @@ Addressed by *sway/workspaces*
default: false ++ default: false ++
If set to false, you can scroll to cycle through workspaces. If set to true this behaviour is disabled. If set to false, you can scroll to cycle through workspaces. If set to true this behaviour is disabled.
*disable-click*: ++
typeof: bool ++
default: false ++
If set to false, you can click to change workspace. If set to true this behaviour is disabled.
*smooth-scrolling-threshold*: ++ *smooth-scrolling-threshold*: ++
typeof: double ++ typeof: double ++
Threshold to be used when scrolling. Threshold to be used when scrolling.

View File

@ -249,22 +249,24 @@ Gtk::Button &Workspaces::addButton(const Json::Value &node) {
auto &&button = pair.first->second; auto &&button = pair.first->second;
box_.pack_start(button, false, false, 0); box_.pack_start(button, false, false, 0);
button.set_relief(Gtk::RELIEF_NONE); button.set_relief(Gtk::RELIEF_NONE);
button.signal_pressed().connect([this, node] { if (!config_["disable-click"].asBool()) {
try { button.signal_pressed().connect([this, node] {
if (node["target_output"].isString()) { try {
ipc_.sendCmd( if (node["target_output"].isString()) {
IPC_COMMAND, ipc_.sendCmd(
fmt::format(workspace_switch_cmd_ + "; move workspace to output \"{}\"; " + workspace_switch_cmd_, IPC_COMMAND,
node["name"].asString(), fmt::format(workspace_switch_cmd_ + "; move workspace to output \"{}\"; " + workspace_switch_cmd_,
node["target_output"].asString(), node["name"].asString(),
node["name"].asString())); node["target_output"].asString(),
} else { node["name"].asString()));
ipc_.sendCmd(IPC_COMMAND, fmt::format(workspace_switch_cmd_, node["name"].asString())); } else {
ipc_.sendCmd(IPC_COMMAND, fmt::format(workspace_switch_cmd_, node["name"].asString()));
}
} catch (const std::exception &e) {
spdlog::error("Workspaces: {}", e.what());
} }
} catch (const std::exception &e) { });
spdlog::error("Workspaces: {}", e.what()); }
}
});
return button; return button;
} }