Merge pull request #736 from Xyene/sway-workspaces-no-auto-back-and-forth

This commit is contained in:
Alex 2020-06-11 10:31:26 +02:00 committed by GitHub
commit 181fde254f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -20,6 +20,8 @@ class Workspaces : public AModule, public sigc::trackable {
auto update() -> void; auto update() -> void;
private: private:
static inline const std::string workspace_switch_cmd_ = "workspace --no-auto-back-and-forth \"{}\"";
void onCmd(const struct Ipc::ipc_response&); void onCmd(const struct Ipc::ipc_response&);
void onEvent(const struct Ipc::ipc_response&); void onEvent(const struct Ipc::ipc_response&);
bool filterButtons(); bool filterButtons();

View File

@ -219,12 +219,12 @@ Gtk::Button &Workspaces::addButton(const Json::Value &node) {
if (node["target_output"].isString()) { if (node["target_output"].isString()) {
ipc_.sendCmd( ipc_.sendCmd(
IPC_COMMAND, IPC_COMMAND,
fmt::format("workspace \"{}\"; move workspace to output \"{}\"; workspace \"{}\"", fmt::format(workspace_switch_cmd_ + "; move workspace to output \"{}\"; " + workspace_switch_cmd_,
node["name"].asString(), node["name"].asString(),
node["target_output"].asString(), node["target_output"].asString(),
node["name"].asString())); node["name"].asString()));
} else { } else {
ipc_.sendCmd(IPC_COMMAND, fmt::format("workspace \"{}\"", node["name"].asString())); ipc_.sendCmd(IPC_COMMAND, fmt::format(workspace_switch_cmd_, node["name"].asString()));
} }
} catch (const std::exception &e) { } catch (const std::exception &e) {
spdlog::error("Workspaces: {}", e.what()); spdlog::error("Workspaces: {}", e.what());
@ -276,7 +276,7 @@ bool Workspaces::handleScroll(GdkEventScroll *e) {
} }
} }
try { try {
ipc_.sendCmd(IPC_COMMAND, fmt::format("workspace \"{}\"", name)); ipc_.sendCmd(IPC_COMMAND, fmt::format(workspace_switch_cmd_, name));
} catch (const std::exception &e) { } catch (const std::exception &e) {
spdlog::error("Workspaces: {}", e.what()); spdlog::error("Workspaces: {}", e.what());
} }