mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
feat: create new workspace on the wanted output
This commit is contained in:
parent
a00f812cd1
commit
7c4d75d428
@ -68,6 +68,7 @@ void Workspaces::onCmd(const struct Ipc::ipc_response &res) {
|
||||
if (output.asString() == bar_.output->name) {
|
||||
Json::Value v;
|
||||
v["name"] = p_w_name;
|
||||
v["target_output"] = bar_.output->name;
|
||||
workspaces_.emplace_back(std::move(v));
|
||||
break;
|
||||
}
|
||||
@ -202,9 +203,18 @@ Gtk::Button &Workspaces::addButton(const Json::Value &node) {
|
||||
auto &button = pair.first->second;
|
||||
box_.pack_start(button, false, false, 0);
|
||||
button.set_relief(Gtk::RELIEF_NONE);
|
||||
button.signal_clicked().connect([this, pair] {
|
||||
button.signal_clicked().connect([this, node] {
|
||||
try {
|
||||
ipc_.sendCmd(IPC_COMMAND, fmt::format("workspace \"{}\"", pair.first->first));
|
||||
if (node["target_output"].isString()) {
|
||||
ipc_.sendCmd(
|
||||
IPC_COMMAND,
|
||||
fmt::format("workspace \"{}\"; move workspace to output \"{}\"; workspace \"{}\"",
|
||||
node["name"].asString(),
|
||||
node["target_output"].asString(),
|
||||
node["name"].asString()));
|
||||
} else {
|
||||
ipc_.sendCmd(IPC_COMMAND, fmt::format("workspace \"{}\""));
|
||||
}
|
||||
} catch (const std::exception &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user