From 399a797b455c8e63da4fea1d41330ee66c8090f0 Mon Sep 17 00:00:00 2001 From: Mihir Lad Date: Mon, 20 Jul 2020 00:13:10 -0400 Subject: [PATCH] dwm: Fix input handling The command strings were not updated since the event variable formats changed. Also, the EVENT_PREFIX already contained a dash, so an extra character would be erased when adding 1. Don't move the cmd string into the check_send_cmd function since if the first event doesn't match, the cmd string would have been modified when passed to the function again to check if the second event matches. --- include/modules/dwm.hpp | 2 +- src/modules/dwm.cpp | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/modules/dwm.hpp b/include/modules/dwm.hpp index aeb46efd..df28fc77 100644 --- a/include/modules/dwm.hpp +++ b/include/modules/dwm.hpp @@ -63,7 +63,7 @@ namespace modules { void update_title_label(unsigned int client_id); auto get_state(tag_mask_t bit_mask) const -> state_t; - auto check_send_cmd(string&& cmd, const string& ev_name) -> bool; + auto check_send_cmd(string cmd, const string& ev_name) -> bool; auto reconnect_dwm() -> bool; bool m_click{true}; diff --git a/src/modules/dwm.cpp b/src/modules/dwm.cpp index 66379863..fb7b27ad 100644 --- a/src/modules/dwm.cpp +++ b/src/modules/dwm.cpp @@ -152,8 +152,8 @@ namespace modules { } if (m_click) { - builder->cmd(mousebtn::LEFT, string{EVENT_LCLICK} + to_string(tag.bit_mask)); - builder->cmd(mousebtn::RIGHT, string{EVENT_RCLICK} + to_string(tag.bit_mask)); + builder->cmd(mousebtn::LEFT, EVENT_PREFIX + string{EVENT_LCLICK} + "-" + to_string(tag.bit_mask)); + builder->cmd(mousebtn::RIGHT, EVENT_PREFIX + string{EVENT_RCLICK} + "-" + to_string(tag.bit_mask)); builder->node(tag.label); builder->cmd_close(); builder->cmd_close(); @@ -168,16 +168,16 @@ namespace modules { return true; } - auto dwm_module::check_send_cmd(string&& cmd, const string& ev_name) -> bool { - // cmd = -- - // +1 : Erase '-' - cmd.erase(0, strlen(EVENT_PREFIX) + 1); + auto dwm_module::check_send_cmd(string cmd, const string& ev_name) -> bool { + std::cerr << cmd << std::endl; + // cmd = - + cmd.erase(0, strlen(EVENT_PREFIX)); // cmd = - if (cmd.compare(0, ev_name.size(), ev_name) == 0) { // Erase '-' cmd.erase(0, ev_name.size() + 1); - m_log.info("%s: Sending workspace view command to ipc handler", name()); + m_log.info("%s: Sending workspace %s command to ipc handler", ev_name, name()); try { m_ipc->run_command(ev_name, stoul(cmd)); @@ -194,7 +194,7 @@ namespace modules { return false; } - return check_send_cmd(move(cmd), EVENT_LCLICK) || check_send_cmd(move(cmd), EVENT_RCLICK); + return check_send_cmd(cmd, EVENT_LCLICK) || check_send_cmd(cmd, EVENT_RCLICK); } auto dwm_module::get_state(tag_mask_t bit_mask) const -> state_t {