Incorporate reviews

This commit is contained in:
patrick96 2020-05-31 21:11:36 +02:00 committed by Patrick Ziegler
parent 5ddb6fc0c5
commit 9fb75779f3
30 changed files with 37 additions and 37 deletions

View File

@ -75,7 +75,7 @@ class controller
private: private:
size_t setup_modules(alignment align); size_t setup_modules(alignment align);
bool try_forward_legacy_action(const string cmd); bool try_forward_legacy_action(const string& cmd);
connection& m_connection; connection& m_connection;
signal_emitter& m_sig; signal_emitter& m_sig;

View File

@ -36,7 +36,7 @@ namespace modules {
static constexpr auto EVENT_TOGGLE = "toggle"; static constexpr auto EVENT_TOGGLE = "toggle";
protected: protected:
bool input(string&& action, string&& data); bool input(const string& action, const string& data);
private: private:
static constexpr auto FORMAT_VOLUME = "format-volume"; static constexpr auto FORMAT_VOLUME = "format-volume";

View File

@ -32,7 +32,7 @@ namespace modules {
static constexpr const char* EVENT_DEC = "dec"; static constexpr const char* EVENT_DEC = "dec";
protected: protected:
bool input(string&& cmd, string&& data); bool input(const string& action, const string& data);
private: private:
static constexpr auto TAG_LABEL = "<label>"; static constexpr auto TAG_LABEL = "<label>";

View File

@ -54,7 +54,7 @@ namespace modules {
static constexpr auto EVENT_PREV = "prev"; static constexpr auto EVENT_PREV = "prev";
protected: protected:
bool input(string&& action, string&& data); bool input(const string& action, const string& data);
private: private:
bool handle_status(string& data); bool handle_status(string& data);

View File

@ -21,7 +21,7 @@ namespace modules {
static constexpr auto EVENT_TOGGLE = "toggle"; static constexpr auto EVENT_TOGGLE = "toggle";
protected: protected:
bool input(string&& action, string&& data); bool input(const string& action, const string& data);
private: private:
static constexpr auto TAG_LABEL = "<label>"; static constexpr auto TAG_LABEL = "<label>";

View File

@ -58,7 +58,7 @@ namespace modules {
static constexpr auto EVENT_PREV = "prev"; static constexpr auto EVENT_PREV = "prev";
protected: protected:
bool input(string&& action, string&& data); bool input(const string& action, const string& data);
private: private:
static string make_workspace_command(const string& workspace); static string make_workspace_command(const string& workspace);

View File

@ -29,7 +29,7 @@ namespace modules {
static constexpr auto EVENT_EXEC = "exec"; static constexpr auto EVENT_EXEC = "exec";
protected: protected:
bool input(string&& action, string&& data); bool input(const string& action, const string& data);
private: private:
static constexpr auto TAG_LABEL_TOGGLE = "<label-toggle>"; static constexpr auto TAG_LABEL_TOGGLE = "<label-toggle>";

View File

@ -137,7 +137,7 @@ namespace modules {
void teardown(); void teardown();
string contents(); string contents();
bool input(string&& action, string&& data); bool input(const string& action, const string& data);
string input_handler_name() const; string input_handler_name() const;
static constexpr auto TYPE = ""; static constexpr auto TYPE = "";

View File

@ -104,7 +104,7 @@ namespace modules {
} }
template <typename Impl> template <typename Impl>
bool module<Impl>::input(string&&, string&&) { bool module<Impl>::input(const string&, const string&) {
// By default a module doesn't support inputs // By default a module doesn't support inputs
return false; return false;
} }

View File

@ -16,7 +16,7 @@ namespace modules {
* *
* \returns true if the action is supported and false otherwise * \returns true if the action is supported and false otherwise
*/ */
virtual bool input(string&& action, string&& data) = 0; virtual bool input(const string& action, const string& data) = 0;
/** /**
* The name of this input handler * The name of this input handler

View File

@ -38,7 +38,7 @@ namespace modules {
static constexpr const char* EVENT_SEEK = "seek"; static constexpr const char* EVENT_SEEK = "seek";
protected: protected:
bool input(string&& action, string&& data); bool input(const string& action, const string& data);
private: private:
static constexpr const char* FORMAT_ONLINE{"format-online"}; static constexpr const char* FORMAT_ONLINE{"format-online"};

View File

@ -29,7 +29,7 @@ namespace modules {
static constexpr auto EVENT_TOGGLE = "toggle"; static constexpr auto EVENT_TOGGLE = "toggle";
protected: protected:
bool input(string&& action, string&& data); bool input(const string& action, const string& data);
private: private:
static constexpr auto FORMAT_VOLUME = "format-volume"; static constexpr auto FORMAT_VOLUME = "format-volume";

View File

@ -24,7 +24,7 @@ namespace modules {
static constexpr auto EVENT_TOGGLE = "toggle"; static constexpr auto EVENT_TOGGLE = "toggle";
protected: protected:
bool input(string&& action, string&& data); bool input(const string& action, const string& data);
private: private:

View File

@ -36,7 +36,7 @@ namespace modules {
string input_handler_name() const { \ string input_handler_name() const { \
return ""; \ return ""; \
} \ } \
bool input(string&&, string&&) { \ bool input(const string&, const string&) { \
return false; \ return false; \
} \ } \
} }

View File

@ -37,7 +37,7 @@ namespace modules {
protected: protected:
void handle(const evt::randr_notify& evt); void handle(const evt::randr_notify& evt);
bool input(string&& action, string&& data); bool input(const string& action, const string& data);
private: private:
static constexpr const char* TAG_LABEL{"<label>"}; static constexpr const char* TAG_LABEL{"<label>"};

View File

@ -38,7 +38,7 @@ namespace modules {
void handle(const evt::xkb_state_notify& evt); void handle(const evt::xkb_state_notify& evt);
void handle(const evt::xkb_indicator_state_notify& evt); void handle(const evt::xkb_indicator_state_notify& evt);
bool input(string&& action, string&& data); bool input(const string& action, const string& data);
private: private:
static constexpr const char* TAG_LABEL_LAYOUT{"<label-layout>"}; static constexpr const char* TAG_LABEL_LAYOUT{"<label-layout>"};

View File

@ -72,7 +72,7 @@ namespace modules {
void rebuild_desktop_states(); void rebuild_desktop_states();
void set_desktop_urgent(xcb_window_t window); void set_desktop_urgent(xcb_window_t window);
bool input(string&& action, string&& data); bool input(const string& action, const string& data);
private: private:
static vector<string> get_desktop_names(); static vector<string> get_desktop_names();

View File

@ -397,7 +397,7 @@ void controller::process_eventqueue() {
* \returns true iff the given command matches a legacy action string and was * \returns true iff the given command matches a legacy action string and was
* successfully forwarded to a module * successfully forwarded to a module
*/ */
bool controller::try_forward_legacy_action(const string cmd) { bool controller::try_forward_legacy_action(const string& cmd) {
/* /*
* Maps legacy action names to a module type and the new action name in that module. * Maps legacy action names to a module type and the new action name in that module.
* *
@ -412,7 +412,7 @@ bool controller::try_forward_legacy_action(const string cmd) {
// clang-format off // clang-format off
#define A_MAP(old, module_name, event) {old, {string(module_name::TYPE), string(module_name::event)}} #define A_MAP(old, module_name, event) {old, {string(module_name::TYPE), string(module_name::event)}}
const std::map<string, std::pair<string, const string>> legacy_actions{ static const std::map<string, std::pair<string, const string>> legacy_actions{
A_MAP("datetoggle", date_module, EVENT_TOGGLE), A_MAP("datetoggle", date_module, EVENT_TOGGLE),
#if ENABLE_ALSA #if ENABLE_ALSA
A_MAP("volup", alsa_module, EVENT_INC), A_MAP("volup", alsa_module, EVENT_INC),
@ -487,7 +487,7 @@ bool controller::try_forward_legacy_action(const string cmd) {
} }
m_log.info( m_log.info(
"Forwarding legacy action '%s' to module '%s' as '%s' with data '%s'", cmd, handler_name, action, data); "Forwarding legacy action '%s' to module '%s' as '%s' with data '%s'", cmd, handler_name, action, data);
if (!handler_ptr->input(std::forward<string>(action), std::forward<string>(data))) { if (!handler_ptr->input(action, data)) {
m_log.err("Failed to forward deprecated action to %s module", type); m_log.err("Failed to forward deprecated action to %s module", type);
// Forward to shell if the module cannot accept the action to not break existing behavior. // Forward to shell if the module cannot accept the action to not break existing behavior.
return false; return false;
@ -514,8 +514,8 @@ void controller::process_inputdata() {
return; return;
} }
const string cmd = m_inputdata; const string cmd = std::move(m_inputdata);
m_inputdata.clear(); m_inputdata = string{};
m_log.trace("controller: Processing inputdata: %s", cmd); m_log.trace("controller: Processing inputdata: %s", cmd);
@ -543,7 +543,7 @@ void controller::process_inputdata() {
// Forwards the action to all input handlers that match the name // Forwards the action to all input handlers that match the name
for (auto&& handler : m_inputhandlers) { for (auto&& handler : m_inputhandlers) {
if (handler->input_handler_name() == handler_name) { if (handler->input_handler_name() == handler_name) {
if (!handler->input(std::forward<string>(action), std::forward<string>(data))) { if (!handler->input(action, data)) {
m_log.err("The '%s' module does not support the '%s' action.", handler_name, action); m_log.err("The '%s' module does not support the '%s' action.", handler_name, action);
} }

View File

@ -218,7 +218,7 @@ namespace modules {
return true; return true;
} }
bool alsa_module::input(string&& action , string&&) { bool alsa_module::input(const string& action, const string&) {
if (!m_handle_events) { if (!m_handle_events) {
return false; return false;
} else if (!m_mixer[mixer::MASTER]) { } else if (!m_mixer[mixer::MASTER]) {

View File

@ -113,12 +113,12 @@ namespace modules {
return true; return true;
} }
bool backlight_module::input(string&& cmd, string&&) { bool backlight_module::input(const string& action, const string&) {
double value_mod{0.0}; double value_mod{0.0};
if (cmd == EVENT_INC) { if (action == EVENT_INC) {
value_mod = 5.0; value_mod = 5.0;
} else if (cmd == EVENT_DEC) { } else if (action == EVENT_DEC) {
value_mod = -5.0; value_mod = -5.0;
} else { } else {
return false; return false;

View File

@ -445,7 +445,7 @@ namespace modules {
return false; return false;
} }
bool bspwm_module::input(string&& action, string&& data) { bool bspwm_module::input(const string& action, const string& data) {
auto send_command = [this](string payload_cmd, string log_info) { auto send_command = [this](string payload_cmd, string log_info) {
try { try {
auto ipc = bspwm_util::make_connection(); auto ipc = bspwm_util::make_connection();

View File

@ -83,7 +83,7 @@ namespace modules {
return true; return true;
} }
bool date_module::input(string&& action, string&&) { bool date_module::input(const string& action, const string&) {
if (action != EVENT_TOGGLE) { if (action != EVENT_TOGGLE) {
return false; return false;
} }

View File

@ -218,7 +218,7 @@ namespace modules {
return true; return true;
} }
bool i3_module::input(string&& action, string&& data) { bool i3_module::input(const string& action, const string& data) {
try { try {
const i3_util::connection_t conn{}; const i3_util::connection_t conn{};

View File

@ -99,7 +99,7 @@ namespace modules {
return true; return true;
} }
bool menu_module::input(string&& action, string&& data) { bool menu_module::input(const string& action, const string& data) {
if (action == EVENT_EXEC) { if (action == EVENT_EXEC) {
auto sep = data.find("-"); auto sep = data.find("-");

View File

@ -353,7 +353,7 @@ namespace modules {
return true; return true;
} }
bool mpd_module::input(string&& action, string&& data) { bool mpd_module::input(const string& action, const string& data) {
m_log.info("%s: event: %s", name(), action); m_log.info("%s: event: %s", name(), action);
try { try {

View File

@ -142,7 +142,7 @@ namespace modules {
return true; return true;
} }
bool pulseaudio_module::input(string&& action, string&&) { bool pulseaudio_module::input(const string& action, const string&) {
if (!m_handle_events) { if (!m_handle_events) {
return false; return false;
} }

View File

@ -53,7 +53,7 @@ namespace modules {
/** /**
* Handle input event * Handle input event
*/ */
bool systray_module::input(string&& action, string&&) { bool systray_module::input(const string& action, const string&) {
if (action.find(EVENT_TOGGLE) != 0) { if (action.find(EVENT_TOGGLE) != 0) {
return false; return false;
} }

View File

@ -147,7 +147,7 @@ namespace modules {
/** /**
* Process scroll events by changing backlight value * Process scroll events by changing backlight value
*/ */
bool xbacklight_module::input(string&& action, string&&) { bool xbacklight_module::input(const string& action, const string&) {
double value_mod{0.0}; double value_mod{0.0};
if (action == EVENT_INC) { if (action == EVENT_INC) {

View File

@ -207,7 +207,7 @@ namespace modules {
/** /**
* Handle input command * Handle input command
*/ */
bool xkeyboard_module::input(string&& action, string&&) { bool xkeyboard_module::input(const string& action, const string&) {
if (action != EVENT_SWITCH) { if (action != EVENT_SWITCH) {
return false; return false;
} }

View File

@ -368,7 +368,7 @@ namespace modules {
/** /**
* Handle user input event * Handle user input event
*/ */
bool xworkspaces_module::input(string&& action, string&& data) { bool xworkspaces_module::input(const string& action, const string& data) {
std::lock_guard<std::mutex> lock(m_workspace_mutex); std::lock_guard<std::mutex> lock(m_workspace_mutex);
vector<unsigned int> indexes; vector<unsigned int> indexes;