add button single click check to hyprland workspaces

pull/2701/head
Jeremy Huang 2023-11-27 16:20:05 -08:00
parent 1fe4a4ee9d
commit 0162dbd485
1 changed files with 15 additions and 13 deletions

View File

@ -311,7 +311,7 @@ void Workspaces::on_workspace_created(std::string const &payload) {
void Workspaces::on_workspace_moved(std::string const &payload) { void Workspaces::on_workspace_moved(std::string const &payload) {
std::string workspace = payload.substr(0, payload.find(',')); std::string workspace = payload.substr(0, payload.find(','));
std::string new_output = payload.substr(payload.find(',') + 1); std::string new_output = payload.substr(payload.find(',') + 1);
bool should_show = show_special() || ! workspace.starts_with("special"); bool should_show = show_special() || !workspace.starts_with("special");
if (should_show && bar_.output->name == new_output) { // TODO: implement this better if (should_show && bar_.output->name == new_output) { // TODO: implement this better
const Json::Value workspaces_json = gIPC->getSocket1JsonReply("workspaces"); const Json::Value workspaces_json = gIPC->getSocket1JsonReply("workspaces");
for (Json::Value workspace_json : workspaces_json) { for (Json::Value workspace_json : workspaces_json) {
@ -849,6 +849,7 @@ std::string &Workspace::select_icon(std::map<std::string, std::string> &icons_ma
} }
bool Workspace::handle_clicked(GdkEventButton *bt) const { bool Workspace::handle_clicked(GdkEventButton *bt) const {
if (bt->type == GDK_BUTTON_PRESS) {
try { try {
if (id() > 0) { // normal or numbered persistent if (id() > 0) { // normal or numbered persistent
gIPC->getSocket1Reply("dispatch workspace " + std::to_string(id())); gIPC->getSocket1Reply("dispatch workspace " + std::to_string(id()));
@ -863,6 +864,7 @@ bool Workspace::handle_clicked(GdkEventButton *bt) const {
} catch (const std::exception &e) { } catch (const std::exception &e) {
spdlog::error("Failed to dispatch workspace: {}", e.what()); spdlog::error("Failed to dispatch workspace: {}", e.what());
} }
}
return false; return false;
} }