actions: Switch all modules over to new system
All modules now expose their actions as public static constants Issues: The menu module no longer closes when an item is clicked (before it would intercept any executed command and look if it matches one of its exec commands)
This commit is contained in:
parent
816b73a95f
commit
ae2350167b
@ -48,11 +48,11 @@ class builder {
|
||||
void underline(const string& color = "");
|
||||
void underline_close();
|
||||
void control(controltag tag);
|
||||
void cmd(mousebtn index, string action);
|
||||
void cmd(mousebtn btn, const modules::input_handler& handler, string action);
|
||||
void cmd(mousebtn index, string action, const label_t& label);
|
||||
void cmd(mousebtn btn, const modules::input_handler& handler, string action, const label_t& label);
|
||||
void cmd_close();
|
||||
void action(mousebtn index, string action);
|
||||
void action(mousebtn btn, const modules::input_handler& handler, string action);
|
||||
void action(mousebtn index, string action, const label_t& label);
|
||||
void action(mousebtn btn, const modules::input_handler& handler, string action, const label_t& label);
|
||||
void action_close();
|
||||
|
||||
protected:
|
||||
string background_hex();
|
||||
|
@ -31,8 +31,12 @@ namespace modules {
|
||||
|
||||
static constexpr auto TYPE = "internal/alsa";
|
||||
|
||||
static constexpr auto EVENT_INC = "inc";
|
||||
static constexpr auto EVENT_DEC = "dec";
|
||||
static constexpr auto EVENT_TOGGLE = "toggle";
|
||||
|
||||
protected:
|
||||
bool input(string&& cmd);
|
||||
bool input(string&& action);
|
||||
|
||||
private:
|
||||
static constexpr auto FORMAT_VOLUME = "format-volume";
|
||||
@ -44,11 +48,6 @@ namespace modules {
|
||||
static constexpr auto TAG_LABEL_VOLUME = "<label-volume>";
|
||||
static constexpr auto TAG_LABEL_MUTED = "<label-muted>";
|
||||
|
||||
static constexpr auto EVENT_PREFIX = "vol";
|
||||
static constexpr auto EVENT_VOLUME_UP = "volup";
|
||||
static constexpr auto EVENT_VOLUME_DOWN = "voldown";
|
||||
static constexpr auto EVENT_TOGGLE_MUTE = "volmute";
|
||||
|
||||
progressbar_t m_bar_volume;
|
||||
ramp_t m_ramp_volume;
|
||||
ramp_t m_ramp_headphones;
|
||||
|
@ -28,6 +28,9 @@ namespace modules {
|
||||
|
||||
static constexpr auto TYPE = "internal/backlight";
|
||||
|
||||
static constexpr const char* EVENT_INC = "inc";
|
||||
static constexpr const char* EVENT_DEC = "dec";
|
||||
|
||||
protected:
|
||||
bool input(string&& cmd);
|
||||
|
||||
@ -36,9 +39,6 @@ namespace modules {
|
||||
static constexpr auto TAG_BAR = "<bar>";
|
||||
static constexpr auto TAG_RAMP = "<ramp>";
|
||||
|
||||
static constexpr const char* EVENT_SCROLLUP{"backlight+"};
|
||||
static constexpr const char* EVENT_SCROLLDOWN{"backlight-"};
|
||||
|
||||
ramp_t m_ramp;
|
||||
label_t m_label;
|
||||
progressbar_t m_progressbar;
|
||||
|
@ -49,8 +49,12 @@ namespace modules {
|
||||
|
||||
static constexpr auto TYPE = "internal/bspwm";
|
||||
|
||||
static constexpr auto EVENT_FOCUS = "focus";
|
||||
static constexpr auto EVENT_NEXT = "next";
|
||||
static constexpr auto EVENT_PREV = "prev";
|
||||
|
||||
protected:
|
||||
bool input(string&& cmd);
|
||||
bool input(string&& action);
|
||||
|
||||
private:
|
||||
bool handle_status(string& data);
|
||||
@ -63,11 +67,6 @@ namespace modules {
|
||||
static constexpr auto TAG_LABEL_STATE = "<label-state>";
|
||||
static constexpr auto TAG_LABEL_MODE = "<label-mode>";
|
||||
|
||||
static constexpr const char* EVENT_PREFIX{"bspwm-desk"};
|
||||
static constexpr const char* EVENT_CLICK{"bspwm-deskfocus"};
|
||||
static constexpr const char* EVENT_SCROLL_UP{"bspwm-desknext"};
|
||||
static constexpr const char* EVENT_SCROLL_DOWN{"bspwm-deskprev"};
|
||||
|
||||
bspwm_util::connection_t m_subscriber;
|
||||
|
||||
vector<unique_ptr<bspwm_monitor>> m_monitors;
|
||||
|
@ -18,12 +18,13 @@ namespace modules {
|
||||
|
||||
static constexpr auto TYPE = "internal/date";
|
||||
|
||||
static constexpr auto EVENT_TOGGLE = "toggle";
|
||||
|
||||
protected:
|
||||
bool input(string&& cmd);
|
||||
bool input(string&& action);
|
||||
|
||||
private:
|
||||
static constexpr auto TAG_LABEL = "<label>";
|
||||
static constexpr auto EVENT_TOGGLE = "datetoggle";
|
||||
|
||||
// \deprecated: Use <label>
|
||||
static constexpr auto TAG_DATE = "<date>";
|
||||
|
@ -53,8 +53,12 @@ namespace modules {
|
||||
|
||||
static constexpr auto TYPE = "internal/i3";
|
||||
|
||||
static constexpr auto EVENT_FOCUS = "focus";
|
||||
static constexpr auto EVENT_NEXT = "next";
|
||||
static constexpr auto EVENT_PREV = "prev";
|
||||
|
||||
protected:
|
||||
bool input(string&& cmd);
|
||||
bool input(string&& action);
|
||||
|
||||
private:
|
||||
static string make_workspace_command(const string& workspace);
|
||||
@ -67,11 +71,6 @@ namespace modules {
|
||||
static constexpr const char* TAG_LABEL_STATE{"<label-state>"};
|
||||
static constexpr const char* TAG_LABEL_MODE{"<label-mode>"};
|
||||
|
||||
static constexpr const char* EVENT_PREFIX{"i3wm"};
|
||||
static constexpr const char* EVENT_CLICK{"i3wm-wsfocus-"};
|
||||
static constexpr const char* EVENT_SCROLL_UP{"i3wm-wsnext"};
|
||||
static constexpr const char* EVENT_SCROLL_DOWN{"i3wm-wsprev"};
|
||||
|
||||
map<state, label_t> m_statelabels;
|
||||
vector<unique_ptr<workspace>> m_workspaces;
|
||||
iconset_t m_icons;
|
||||
|
@ -24,16 +24,16 @@ namespace modules {
|
||||
|
||||
static constexpr auto TYPE = "custom/menu";
|
||||
|
||||
static constexpr auto EVENT_OPEN = "open";
|
||||
static constexpr auto EVENT_CLOSE = "close";
|
||||
|
||||
protected:
|
||||
bool input(string&& cmd);
|
||||
bool input(string&& action);
|
||||
|
||||
private:
|
||||
static constexpr auto TAG_LABEL_TOGGLE = "<label-toggle>";
|
||||
static constexpr auto TAG_MENU = "<menu>";
|
||||
|
||||
static constexpr auto EVENT_MENU_OPEN = "menu-open-";
|
||||
static constexpr auto EVENT_MENU_CLOSE = "menu-close";
|
||||
|
||||
bool m_expand_right{true};
|
||||
|
||||
label_t m_labelopen;
|
||||
|
@ -137,7 +137,7 @@ namespace modules {
|
||||
void teardown();
|
||||
string contents();
|
||||
|
||||
bool input(string&& cmd);
|
||||
bool input(string&& action);
|
||||
string input_handler_name() const;
|
||||
|
||||
static constexpr auto TYPE = "";
|
||||
|
@ -17,8 +17,6 @@ namespace modules {
|
||||
|
||||
/**
|
||||
* The name of this input handler
|
||||
*
|
||||
* Actions of the form '#NAME#ACTION' can be sent to this handler if NAME is the name of this input handler.
|
||||
*/
|
||||
virtual string input_handler_name() const = 0;
|
||||
};
|
||||
|
@ -26,8 +26,19 @@ namespace modules {
|
||||
|
||||
static constexpr auto TYPE = "internal/mpd";
|
||||
|
||||
static constexpr const char* EVENT_PLAY = "play";
|
||||
static constexpr const char* EVENT_PAUSE = "pause";
|
||||
static constexpr const char* EVENT_STOP = "stop";
|
||||
static constexpr const char* EVENT_PREV = "prev";
|
||||
static constexpr const char* EVENT_NEXT = "next";
|
||||
static constexpr const char* EVENT_REPEAT = "repeat";
|
||||
static constexpr const char* EVENT_SINGLE = "single";
|
||||
static constexpr const char* EVENT_RANDOM = "random";
|
||||
static constexpr const char* EVENT_CONSUME = "consume";
|
||||
static constexpr const char* EVENT_SEEK = "seek";
|
||||
|
||||
protected:
|
||||
bool input(string&& cmd);
|
||||
bool input(string&& action);
|
||||
|
||||
private:
|
||||
static constexpr const char* FORMAT_ONLINE{"format-online"};
|
||||
@ -63,17 +74,6 @@ namespace modules {
|
||||
static constexpr const char* FORMAT_OFFLINE{"format-offline"};
|
||||
static constexpr const char* TAG_LABEL_OFFLINE{"<label-offline>"};
|
||||
|
||||
static constexpr const char* EVENT_PLAY{"mpdplay"};
|
||||
static constexpr const char* EVENT_PAUSE{"mpdpause"};
|
||||
static constexpr const char* EVENT_STOP{"mpdstop"};
|
||||
static constexpr const char* EVENT_PREV{"mpdprev"};
|
||||
static constexpr const char* EVENT_NEXT{"mpdnext"};
|
||||
static constexpr const char* EVENT_REPEAT{"mpdrepeat"};
|
||||
static constexpr const char* EVENT_SINGLE{"mpdsingle"};
|
||||
static constexpr const char* EVENT_RANDOM{"mpdrandom"};
|
||||
static constexpr const char* EVENT_CONSUME{"mpdconsume"};
|
||||
static constexpr const char* EVENT_SEEK{"mpdseek"};
|
||||
|
||||
unique_ptr<mpdconnection> m_mpd;
|
||||
|
||||
/*
|
||||
|
@ -24,8 +24,12 @@ namespace modules {
|
||||
|
||||
static constexpr auto TYPE = "internal/pulseaudio";
|
||||
|
||||
static constexpr auto EVENT_INC = "inc";
|
||||
static constexpr auto EVENT_DEC = "dec";
|
||||
static constexpr auto EVENT_TOGGLE = "toggle";
|
||||
|
||||
protected:
|
||||
bool input(string&& cmd);
|
||||
bool input(string&& action);
|
||||
|
||||
private:
|
||||
static constexpr auto FORMAT_VOLUME = "format-volume";
|
||||
@ -36,11 +40,6 @@ namespace modules {
|
||||
static constexpr auto TAG_LABEL_VOLUME = "<label-volume>";
|
||||
static constexpr auto TAG_LABEL_MUTED = "<label-muted>";
|
||||
|
||||
static constexpr auto EVENT_PREFIX = "pa_vol";
|
||||
static constexpr auto EVENT_VOLUME_UP = "pa_volup";
|
||||
static constexpr auto EVENT_VOLUME_DOWN = "pa_voldown";
|
||||
static constexpr auto EVENT_TOGGLE_MUTE = "pa_volmute";
|
||||
|
||||
progressbar_t m_bar_volume;
|
||||
ramp_t m_ramp_volume;
|
||||
label_t m_label_volume;
|
||||
|
@ -21,11 +21,12 @@ namespace modules {
|
||||
|
||||
static constexpr auto TYPE = "internal/systray";
|
||||
|
||||
static constexpr auto EVENT_TOGGLE = "toggle";
|
||||
|
||||
protected:
|
||||
bool input(string&& cmd);
|
||||
bool input(string&& action);
|
||||
|
||||
private:
|
||||
static constexpr const char* EVENT_TOGGLE{"systray-toggle"};
|
||||
|
||||
static constexpr const char* TAG_LABEL_TOGGLE{"<label-toggle>"};
|
||||
static constexpr const char* TAG_TRAY_CLIENTS{"<tray-clients>"};
|
||||
|
@ -32,18 +32,18 @@ namespace modules {
|
||||
|
||||
static constexpr auto TYPE = "internal/xbacklight";
|
||||
|
||||
static constexpr const char* EVENT_INC = "inc";
|
||||
static constexpr const char* EVENT_DEC = "dec";
|
||||
|
||||
protected:
|
||||
void handle(const evt::randr_notify& evt);
|
||||
bool input(string&& cmd);
|
||||
bool input(string&& action);
|
||||
|
||||
private:
|
||||
static constexpr const char* TAG_LABEL{"<label>"};
|
||||
static constexpr const char* TAG_BAR{"<bar>"};
|
||||
static constexpr const char* TAG_RAMP{"<ramp>"};
|
||||
|
||||
static constexpr const char* EVENT_SCROLLUP{"xbacklight+"};
|
||||
static constexpr const char* EVENT_SCROLLDOWN{"xbacklight-"};
|
||||
|
||||
connection& m_connection;
|
||||
monitor_t m_output;
|
||||
xcb_window_t m_proxy{};
|
||||
|
@ -28,6 +28,8 @@ namespace modules {
|
||||
|
||||
static constexpr auto TYPE = "internal/xkeyboard";
|
||||
|
||||
static constexpr const char* EVENT_SWITCH = "switch";
|
||||
|
||||
protected:
|
||||
bool query_keyboard();
|
||||
bool blacklisted(const string& indicator_name);
|
||||
@ -36,7 +38,7 @@ namespace modules {
|
||||
void handle(const evt::xkb_state_notify& evt);
|
||||
void handle(const evt::xkb_indicator_state_notify& evt);
|
||||
|
||||
bool input(string&& cmd);
|
||||
bool input(string&& action);
|
||||
|
||||
private:
|
||||
static constexpr const char* TAG_LABEL_LAYOUT{"<label-layout>"};
|
||||
@ -45,8 +47,6 @@ namespace modules {
|
||||
static constexpr const char* DEFAULT_LAYOUT_ICON{"layout-icon-default"};
|
||||
static constexpr const char* DEFAULT_INDICATOR_ICON{"indicator-icon-default"};
|
||||
|
||||
static constexpr const char* EVENT_SWITCH{"xkeyboard/switch"};
|
||||
|
||||
connection& m_connection;
|
||||
event_timer m_xkb_newkb_notify{};
|
||||
event_timer m_xkb_state_notify{};
|
||||
|
@ -60,6 +60,10 @@ namespace modules {
|
||||
|
||||
static constexpr auto TYPE = "internal/xworkspaces";
|
||||
|
||||
static constexpr auto EVENT_FOCUS = "focus";
|
||||
static constexpr auto EVENT_NEXT = "next";
|
||||
static constexpr auto EVENT_PREV = "prev";
|
||||
|
||||
protected:
|
||||
void handle(const evt::property_notify& evt);
|
||||
|
||||
@ -68,7 +72,7 @@ namespace modules {
|
||||
void rebuild_desktop_states();
|
||||
void set_desktop_urgent(xcb_window_t window);
|
||||
|
||||
bool input(string&& cmd);
|
||||
bool input(string&& action);
|
||||
|
||||
private:
|
||||
static vector<string> get_desktop_names();
|
||||
@ -80,11 +84,6 @@ namespace modules {
|
||||
static constexpr const char* TAG_LABEL_MONITOR{"<label-monitor>"};
|
||||
static constexpr const char* TAG_LABEL_STATE{"<label-state>"};
|
||||
|
||||
static constexpr const char* EVENT_PREFIX{"xworkspaces-"};
|
||||
static constexpr const char* EVENT_CLICK{"focus="};
|
||||
static constexpr const char* EVENT_SCROLL_UP{"next"};
|
||||
static constexpr const char* EVENT_SCROLL_DOWN{"prev"};
|
||||
|
||||
connection& m_connection;
|
||||
ewmh_connection_t m_ewmh;
|
||||
|
||||
|
@ -72,7 +72,7 @@ string builder::flush() {
|
||||
}
|
||||
|
||||
while (m_tags[syntaxtag::A]) {
|
||||
cmd_close();
|
||||
action_close();
|
||||
}
|
||||
|
||||
string output{m_output};
|
||||
@ -428,9 +428,11 @@ void builder::control(controltag tag) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Open command tag
|
||||
* Open action tag with the given action string
|
||||
*
|
||||
* The action string is escaped, if needed.
|
||||
*/
|
||||
void builder::cmd(mousebtn index, string action) {
|
||||
void builder::action(mousebtn index, string action) {
|
||||
if (!action.empty()) {
|
||||
action = string_util::replace_all(action, ":", "\\:");
|
||||
tag_open(syntaxtag::A, to_string(static_cast<int>(index)) + ":" + action + ":");
|
||||
@ -438,18 +440,18 @@ void builder::cmd(mousebtn index, string action) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Open an action tag for the given input handler and action
|
||||
* Open action tag for the action of the given input_handler
|
||||
*/
|
||||
void builder::cmd(mousebtn btn, const modules::input_handler& handler, string action) {
|
||||
cmd(btn, actions_util::get_action_string(handler, action));
|
||||
void builder::action(mousebtn btn, const modules::input_handler& handler, string action_name) {
|
||||
action(btn, actions_util::get_action_string(handler, action_name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap label in command block
|
||||
* Wrap label in action tag
|
||||
*/
|
||||
void builder::cmd(mousebtn index, string action, const label_t& label) {
|
||||
void builder::action(mousebtn index, string action_name, const label_t& label) {
|
||||
if (label && *label) {
|
||||
cmd(index, action);
|
||||
action(index, action_name);
|
||||
node(label);
|
||||
tag_close(syntaxtag::A);
|
||||
}
|
||||
@ -457,16 +459,16 @@ void builder::cmd(mousebtn index, string action, const label_t& label) {
|
||||
|
||||
|
||||
/**
|
||||
* Wrap label in module action
|
||||
* Wrap label in module action tag
|
||||
*/
|
||||
void builder::cmd(mousebtn btn, const modules::input_handler& handler, string action, const label_t& label) {
|
||||
cmd(btn, actions_util::get_action_string(handler, action), label);
|
||||
void builder::action(mousebtn btn, const modules::input_handler& handler, string action_name, const label_t& label) {
|
||||
action(btn, actions_util::get_action_string(handler, action_name), label);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close command tag
|
||||
*/
|
||||
void builder::cmd_close() {
|
||||
void builder::action_close() {
|
||||
tag_close(syntaxtag::A);
|
||||
}
|
||||
|
||||
|
@ -191,9 +191,9 @@ namespace modules {
|
||||
string output{module::get_output()};
|
||||
|
||||
if (m_handle_events) {
|
||||
m_builder->cmd(mousebtn::LEFT, EVENT_TOGGLE_MUTE);
|
||||
m_builder->cmd(mousebtn::SCROLL_UP, EVENT_VOLUME_UP);
|
||||
m_builder->cmd(mousebtn::SCROLL_DOWN, EVENT_VOLUME_DOWN);
|
||||
m_builder->action(mousebtn::LEFT, *this, EVENT_TOGGLE);
|
||||
m_builder->action(mousebtn::SCROLL_UP, *this, EVENT_INC);
|
||||
m_builder->action(mousebtn::SCROLL_DOWN, *this, EVENT_DEC);
|
||||
}
|
||||
|
||||
m_builder->append(output);
|
||||
@ -218,11 +218,9 @@ namespace modules {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool alsa_module::input(string&& cmd) {
|
||||
bool alsa_module::input(string&& action) {
|
||||
if (!m_handle_events) {
|
||||
return false;
|
||||
} else if (cmd.compare(0, 3, EVENT_PREFIX) != 0) {
|
||||
return false;
|
||||
} else if (!m_mixer[mixer::MASTER]) {
|
||||
return false;
|
||||
}
|
||||
@ -244,16 +242,16 @@ namespace modules {
|
||||
string{m_mixer[mixer::SPEAKER]->get_name()}, string{m_mixer[mixer::SPEAKER]->get_sound_card()}));
|
||||
}
|
||||
|
||||
if (cmd.compare(0, strlen(EVENT_TOGGLE_MUTE), EVENT_TOGGLE_MUTE) == 0) {
|
||||
if (action == EVENT_TOGGLE) {
|
||||
for (auto&& mixer : mixers) {
|
||||
mixer->set_mute(m_muted || mixers[0]->is_muted());
|
||||
}
|
||||
} else if (cmd.compare(0, strlen(EVENT_VOLUME_UP), EVENT_VOLUME_UP) == 0) {
|
||||
} else if (action == EVENT_INC) {
|
||||
for (auto&& mixer : mixers) {
|
||||
m_mapped ? mixer->set_normalized_volume(math_util::cap<float>(mixer->get_normalized_volume() + m_interval, 0, 100))
|
||||
: mixer->set_volume(math_util::cap<float>(mixer->get_volume() + m_interval, 0, 100));
|
||||
}
|
||||
} else if (cmd.compare(0, strlen(EVENT_VOLUME_DOWN), EVENT_VOLUME_DOWN) == 0) {
|
||||
} else if (action == EVENT_DEC) {
|
||||
for (auto&& mixer : mixers) {
|
||||
m_mapped ? mixer->set_normalized_volume(math_util::cap<float>(mixer->get_normalized_volume() - m_interval, 0, 100))
|
||||
: mixer->set_volume(math_util::cap<float>(mixer->get_volume() - m_interval, 0, 100));
|
||||
|
@ -88,14 +88,14 @@ namespace modules {
|
||||
string output{module::get_output()};
|
||||
|
||||
if (m_scroll) {
|
||||
m_builder->cmd(mousebtn::SCROLL_UP, EVENT_SCROLLUP);
|
||||
m_builder->cmd(mousebtn::SCROLL_DOWN, EVENT_SCROLLDOWN);
|
||||
m_builder->action(mousebtn::SCROLL_UP, *this, EVENT_INC);
|
||||
m_builder->action(mousebtn::SCROLL_DOWN, *this, EVENT_DEC);
|
||||
}
|
||||
|
||||
m_builder->append(std::move(output));
|
||||
|
||||
m_builder->cmd_close();
|
||||
m_builder->cmd_close();
|
||||
m_builder->action_close();
|
||||
m_builder->action_close();
|
||||
|
||||
return m_builder->flush();
|
||||
}
|
||||
@ -116,9 +116,9 @@ namespace modules {
|
||||
bool backlight_module::input(string&& cmd) {
|
||||
double value_mod{0.0};
|
||||
|
||||
if (cmd == EVENT_SCROLLUP) {
|
||||
if (cmd == EVENT_INC) {
|
||||
value_mod = 5.0;
|
||||
} else if (cmd == EVENT_SCROLLDOWN) {
|
||||
} else if (cmd == EVENT_DEC) {
|
||||
value_mod = -5.0;
|
||||
} else {
|
||||
return false;
|
||||
|
@ -396,8 +396,8 @@ namespace modules {
|
||||
size_t workspace_n{0U};
|
||||
|
||||
if (m_scroll) {
|
||||
builder->cmd(mousebtn::SCROLL_DOWN, EVENT_SCROLL_DOWN);
|
||||
builder->cmd(mousebtn::SCROLL_UP, EVENT_SCROLL_UP);
|
||||
builder->action(mousebtn::SCROLL_DOWN, *this, EVENT_PREV);
|
||||
builder->action(mousebtn::SCROLL_UP, *this, EVENT_NEXT);
|
||||
}
|
||||
|
||||
for (auto&& ws : m_monitors[m_index]->workspaces) {
|
||||
@ -409,7 +409,7 @@ namespace modules {
|
||||
workspace_n++;
|
||||
|
||||
if (m_click) {
|
||||
builder->cmd(mousebtn::LEFT, sstream() << EVENT_CLICK << m_index << "+" << workspace_n, ws.second);
|
||||
builder->action(mousebtn::LEFT, *this, sstream() << EVENT_FOCUS << m_index << "+" << workspace_n, ws.second);
|
||||
} else {
|
||||
builder->node(ws.second);
|
||||
}
|
||||
@ -423,8 +423,8 @@ namespace modules {
|
||||
}
|
||||
|
||||
if (m_scroll) {
|
||||
builder->cmd_close();
|
||||
builder->cmd_close();
|
||||
builder->action_close();
|
||||
builder->action_close();
|
||||
}
|
||||
|
||||
return workspace_n > 0;
|
||||
@ -445,11 +445,7 @@ namespace modules {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bspwm_module::input(string&& cmd) {
|
||||
if (cmd.find(EVENT_PREFIX) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bspwm_module::input(string&& action) {
|
||||
auto send_command = [this](string payload_cmd, string log_info) {
|
||||
try {
|
||||
auto ipc = bspwm_util::make_connection();
|
||||
@ -462,18 +458,18 @@ namespace modules {
|
||||
}
|
||||
};
|
||||
|
||||
if (cmd.compare(0, strlen(EVENT_CLICK), EVENT_CLICK) == 0) {
|
||||
cmd.erase(0, strlen(EVENT_CLICK));
|
||||
if (action.compare(0, strlen(EVENT_FOCUS), EVENT_FOCUS) == 0) {
|
||||
action.erase(0, strlen(EVENT_FOCUS));
|
||||
|
||||
size_t separator{string_util::find_nth(cmd, 0, "+", 1)};
|
||||
size_t monitor_n{std::strtoul(cmd.substr(0, separator).c_str(), nullptr, 10)};
|
||||
string workspace_n{cmd.substr(separator + 1)};
|
||||
size_t separator{string_util::find_nth(action, 0, "+", 1)};
|
||||
size_t monitor_n{std::strtoul(action.substr(0, separator).c_str(), nullptr, 10)};
|
||||
string workspace_n{action.substr(separator + 1)};
|
||||
|
||||
if (monitor_n < m_monitors.size()) {
|
||||
send_command("desktop -f " + m_monitors[monitor_n]->name + ":^" + workspace_n,
|
||||
"Sending desktop focus command to ipc handler");
|
||||
} else {
|
||||
m_log.err("%s: Invalid monitor index in command: %s", name(), cmd);
|
||||
m_log.err("%s: Invalid monitor index in command: %s", name(), action);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -481,9 +477,9 @@ namespace modules {
|
||||
|
||||
string scrolldir;
|
||||
|
||||
if (cmd.compare(0, strlen(EVENT_SCROLL_UP), EVENT_SCROLL_UP) == 0) {
|
||||
if (action == EVENT_NEXT) {
|
||||
scrolldir = m_revscroll ? "prev" : "next";
|
||||
} else if (cmd.compare(0, strlen(EVENT_SCROLL_DOWN), EVENT_SCROLL_DOWN) == 0) {
|
||||
} else if (action == EVENT_PREV) {
|
||||
scrolldir = m_revscroll ? "next" : "prev";
|
||||
} else {
|
||||
return false;
|
||||
|
@ -72,9 +72,7 @@ namespace modules {
|
||||
bool date_module::build(builder* builder, const string& tag) const {
|
||||
if (tag == TAG_LABEL) {
|
||||
if (!m_dateformat_alt.empty() || !m_timeformat_alt.empty()) {
|
||||
builder->cmd(mousebtn::LEFT, EVENT_TOGGLE);
|
||||
builder->node(m_label);
|
||||
builder->cmd_close();
|
||||
builder->action(mousebtn::LEFT, *this, EVENT_TOGGLE, m_label);
|
||||
} else {
|
||||
builder->node(m_label);
|
||||
}
|
||||
@ -85,8 +83,8 @@ namespace modules {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool date_module::input(string&& cmd) {
|
||||
if (cmd != EVENT_TOGGLE) {
|
||||
bool date_module::input(string&& action) {
|
||||
if (action != EVENT_TOGGLE) {
|
||||
return false;
|
||||
}
|
||||
m_toggled = !m_toggled;
|
||||
|
@ -183,8 +183,8 @@ namespace modules {
|
||||
builder->node(m_modelabel);
|
||||
} else if (tag == TAG_LABEL_STATE && !m_workspaces.empty()) {
|
||||
if (m_scroll) {
|
||||
builder->cmd(mousebtn::SCROLL_DOWN, EVENT_SCROLL_DOWN);
|
||||
builder->cmd(mousebtn::SCROLL_UP, EVENT_SCROLL_UP);
|
||||
builder->action(mousebtn::SCROLL_DOWN, *this, EVENT_PREV);
|
||||
builder->action(mousebtn::SCROLL_UP, *this, EVENT_NEXT);
|
||||
}
|
||||
|
||||
bool first = true;
|
||||
@ -201,17 +201,15 @@ namespace modules {
|
||||
}
|
||||
|
||||
if (m_click) {
|
||||
builder->cmd(mousebtn::LEFT, string{EVENT_CLICK} + ws->name);
|
||||
builder->node(ws->label);
|
||||
builder->cmd_close();
|
||||
builder->action(mousebtn::LEFT, *this, string{EVENT_FOCUS} + ws->name, ws->label);
|
||||
} else {
|
||||
builder->node(ws->label);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_scroll) {
|
||||
builder->cmd_close();
|
||||
builder->cmd_close();
|
||||
builder->action_close();
|
||||
builder->action_close();
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
@ -220,26 +218,22 @@ namespace modules {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool i3_module::input(string&& cmd) {
|
||||
if (cmd.find(EVENT_PREFIX) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool i3_module::input(string&& action) {
|
||||
try {
|
||||
const i3_util::connection_t conn{};
|
||||
|
||||
if (cmd.compare(0, strlen(EVENT_CLICK), EVENT_CLICK) == 0) {
|
||||
cmd.erase(0, strlen(EVENT_CLICK));
|
||||
if (action.compare(0, strlen(EVENT_FOCUS), EVENT_FOCUS) == 0) {
|
||||
action.erase(0, strlen(EVENT_FOCUS));
|
||||
m_log.info("%s: Sending workspace focus command to ipc handler", name());
|
||||
conn.send_command(make_workspace_command(cmd));
|
||||
conn.send_command(make_workspace_command(action));
|
||||
return true;
|
||||
}
|
||||
|
||||
string scrolldir;
|
||||
|
||||
if (cmd.compare(0, strlen(EVENT_SCROLL_UP), EVENT_SCROLL_UP) == 0) {
|
||||
if (action == EVENT_NEXT) {
|
||||
scrolldir = m_revscroll ? "prev" : "next";
|
||||
} else if (cmd.compare(0, strlen(EVENT_SCROLL_DOWN), EVENT_SCROLL_DOWN) == 0) {
|
||||
} else if (action == EVENT_PREV) {
|
||||
scrolldir = m_revscroll ? "next" : "prev";
|
||||
} else {
|
||||
return false;
|
||||
|
@ -78,7 +78,7 @@ namespace modules {
|
||||
|
||||
for (auto&& action : m_actions) {
|
||||
if (!action.second.empty()) {
|
||||
m_builder->cmd(action.first, action.second);
|
||||
m_builder->action(action.first, action.second);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "drawtypes/label.hpp"
|
||||
#include "utils/factory.hpp"
|
||||
#include "utils/scope.hpp"
|
||||
#include "utils/actions.hpp"
|
||||
|
||||
#include "modules/meta/base.inl"
|
||||
|
||||
@ -57,7 +58,7 @@ namespace modules {
|
||||
m_log.trace("%s: Creating menu level item %i", name(), m_levels.back()->items.size());
|
||||
auto item = factory_util::unique<menu_tree_item>();
|
||||
item->label = load_label(m_conf, name(), item_param);
|
||||
item->exec = m_conf.get(name(), item_param + "-exec", string{EVENT_MENU_CLOSE});
|
||||
item->exec = m_conf.get(name(), item_param + "-exec", actions_util::get_action_string(*this, EVENT_CLOSE));
|
||||
m_levels.back()->items.emplace_back(move(item));
|
||||
}
|
||||
}
|
||||
@ -65,13 +66,9 @@ namespace modules {
|
||||
|
||||
bool menu_module::build(builder* builder, const string& tag) const {
|
||||
if (tag == TAG_LABEL_TOGGLE && m_level == -1) {
|
||||
builder->cmd(mousebtn::LEFT, string(EVENT_MENU_OPEN) + "0");
|
||||
builder->node(m_labelopen);
|
||||
builder->cmd_close();
|
||||
builder->action(mousebtn::LEFT, *this, string(EVENT_OPEN) + "0", m_labelopen);
|
||||
} else if (tag == TAG_LABEL_TOGGLE && m_level > -1) {
|
||||
builder->cmd(mousebtn::LEFT, EVENT_MENU_CLOSE);
|
||||
builder->node(m_labelclose);
|
||||
builder->cmd_close();
|
||||
builder->action(mousebtn::LEFT, *this, EVENT_CLOSE, m_labelclose);
|
||||
} else if (tag == TAG_MENU && m_level > -1) {
|
||||
auto spacing = m_formatter->get(get_format())->spacing;
|
||||
//Insert separator after menu-toggle and before menu-items for expand-right=true
|
||||
@ -80,9 +77,7 @@ namespace modules {
|
||||
builder->space(spacing);
|
||||
}
|
||||
for (auto&& item : m_levels[m_level]->items) {
|
||||
builder->cmd(mousebtn::LEFT, item->exec);
|
||||
builder->node(item->label);
|
||||
builder->cmd_close();
|
||||
builder->action(mousebtn::LEFT, item->exec, item->label);
|
||||
if (item != m_levels[m_level]->items.back()) {
|
||||
builder->space(spacing);
|
||||
if (*m_labelseparator) {
|
||||
@ -101,10 +96,11 @@ namespace modules {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool menu_module::input(string&& cmd) {
|
||||
if (cmd.compare(0, 4, "menu") != 0 && m_level > -1) {
|
||||
bool menu_module::input(string&& action) {
|
||||
// TODO Figure out how to close menu when command is executed (maybe exec-N action)
|
||||
if (action.compare(0, 4, "menu") != 0 && m_level > -1) {
|
||||
for (auto&& item : m_levels[m_level]->items) {
|
||||
if (item->exec == cmd) {
|
||||
if (item->exec == action) {
|
||||
m_level = -1;
|
||||
break;
|
||||
}
|
||||
@ -113,8 +109,8 @@ namespace modules {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cmd.compare(0, strlen(EVENT_MENU_OPEN), EVENT_MENU_OPEN) == 0) {
|
||||
auto level = cmd.substr(strlen(EVENT_MENU_OPEN));
|
||||
if (action.compare(0, strlen(EVENT_OPEN), EVENT_OPEN) == 0) {
|
||||
auto level = action.substr(strlen(EVENT_OPEN));
|
||||
|
||||
if (level.empty()) {
|
||||
level = "0";
|
||||
@ -126,7 +122,7 @@ namespace modules {
|
||||
m_log.warn("%s: Cannot open unexisting menu level '%i'", name(), level);
|
||||
m_level = -1;
|
||||
}
|
||||
} else if (cmd == EVENT_MENU_CLOSE) {
|
||||
} else if (action == EVENT_CLOSE) {
|
||||
m_log.info("%s: Closing menu tree", name());
|
||||
m_level = -1;
|
||||
} else {
|
||||
|
@ -325,27 +325,27 @@ namespace modules {
|
||||
} else if (tag == TAG_LABEL_OFFLINE) {
|
||||
builder->node(m_label_offline);
|
||||
} else if (tag == TAG_ICON_RANDOM) {
|
||||
builder->cmd(mousebtn::LEFT, EVENT_RANDOM, m_icons->get("random"));
|
||||
builder->action(mousebtn::LEFT, *this, EVENT_RANDOM, m_icons->get("random"));
|
||||
} else if (tag == TAG_ICON_REPEAT) {
|
||||
builder->cmd(mousebtn::LEFT, EVENT_REPEAT, m_icons->get("repeat"));
|
||||
builder->action(mousebtn::LEFT, *this, EVENT_REPEAT, m_icons->get("repeat"));
|
||||
} else if (tag == TAG_ICON_REPEAT_ONE || tag == TAG_ICON_SINGLE) {
|
||||
builder->cmd(mousebtn::LEFT, EVENT_SINGLE, m_icons->get("single"));
|
||||
builder->action(mousebtn::LEFT, *this, EVENT_SINGLE, m_icons->get("single"));
|
||||
} else if (tag == TAG_ICON_CONSUME) {
|
||||
builder->cmd(mousebtn::LEFT, EVENT_CONSUME, m_icons->get("consume"));
|
||||
builder->action(mousebtn::LEFT, *this, EVENT_CONSUME, m_icons->get("consume"));
|
||||
} else if (tag == TAG_ICON_PREV) {
|
||||
builder->cmd(mousebtn::LEFT, EVENT_PREV, m_icons->get("prev"));
|
||||
builder->action(mousebtn::LEFT, *this, EVENT_PREV, m_icons->get("prev"));
|
||||
} else if ((tag == TAG_ICON_STOP || tag == TAG_TOGGLE_STOP) && (is_playing || is_paused)) {
|
||||
builder->cmd(mousebtn::LEFT, EVENT_STOP, m_icons->get("stop"));
|
||||
builder->action(mousebtn::LEFT, *this, EVENT_STOP, m_icons->get("stop"));
|
||||
} else if ((tag == TAG_ICON_PAUSE || tag == TAG_TOGGLE) && is_playing) {
|
||||
builder->cmd(mousebtn::LEFT, EVENT_PAUSE, m_icons->get("pause"));
|
||||
builder->action(mousebtn::LEFT, *this, EVENT_PAUSE, m_icons->get("pause"));
|
||||
} else if ((tag == TAG_ICON_PLAY || tag == TAG_TOGGLE || tag == TAG_TOGGLE_STOP) && !is_playing) {
|
||||
builder->cmd(mousebtn::LEFT, EVENT_PLAY, m_icons->get("play"));
|
||||
builder->action(mousebtn::LEFT, *this, EVENT_PLAY, m_icons->get("play"));
|
||||
} else if (tag == TAG_ICON_NEXT) {
|
||||
builder->cmd(mousebtn::LEFT, EVENT_NEXT, m_icons->get("next"));
|
||||
builder->action(mousebtn::LEFT, *this, EVENT_NEXT, m_icons->get("next"));
|
||||
} else if (tag == TAG_ICON_SEEKB) {
|
||||
builder->cmd(mousebtn::LEFT, EVENT_SEEK + "-5"s, m_icons->get("seekb"));
|
||||
builder->action(mousebtn::LEFT, *this, EVENT_SEEK + "-5"s, m_icons->get("seekb"));
|
||||
} else if (tag == TAG_ICON_SEEKF) {
|
||||
builder->cmd(mousebtn::LEFT, EVENT_SEEK + "+5"s, m_icons->get("seekf"));
|
||||
builder->action(mousebtn::LEFT, *this, EVENT_SEEK + "+5"s, m_icons->get("seekf"));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@ -353,12 +353,8 @@ namespace modules {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool mpd_module::input(string&& cmd) {
|
||||
if (cmd.compare(0, 3, "mpd") != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_log.info("%s: event: %s", name(), cmd);
|
||||
bool mpd_module::input(string&& action) {
|
||||
m_log.info("%s: event: %s", name(), action);
|
||||
|
||||
try {
|
||||
auto mpd = factory_util::unique<mpdconnection>(m_log, m_host, m_port, m_pass);
|
||||
@ -370,26 +366,26 @@ namespace modules {
|
||||
bool is_paused = status->match_state(mpdstate::PAUSED);
|
||||
bool is_stopped = status->match_state(mpdstate::STOPPED);
|
||||
|
||||
if (cmd == EVENT_PLAY && !is_playing) {
|
||||
if (action == EVENT_PLAY && !is_playing) {
|
||||
mpd->play();
|
||||
} else if (cmd == EVENT_PAUSE && !is_paused) {
|
||||
} else if (action == EVENT_PAUSE && !is_paused) {
|
||||
mpd->pause(true);
|
||||
} else if (cmd == EVENT_STOP && !is_stopped) {
|
||||
} else if (action == EVENT_STOP && !is_stopped) {
|
||||
mpd->stop();
|
||||
} else if (cmd == EVENT_PREV && !is_stopped) {
|
||||
} else if (action == EVENT_PREV && !is_stopped) {
|
||||
mpd->prev();
|
||||
} else if (cmd == EVENT_NEXT && !is_stopped) {
|
||||
} else if (action == EVENT_NEXT && !is_stopped) {
|
||||
mpd->next();
|
||||
} else if (cmd == EVENT_SINGLE) {
|
||||
} else if (action == EVENT_SINGLE) {
|
||||
mpd->set_single(!status->single());
|
||||
} else if (cmd == EVENT_REPEAT) {
|
||||
} else if (action == EVENT_REPEAT) {
|
||||
mpd->set_repeat(!status->repeat());
|
||||
} else if (cmd == EVENT_RANDOM) {
|
||||
} else if (action == EVENT_RANDOM) {
|
||||
mpd->set_random(!status->random());
|
||||
} else if (cmd == EVENT_CONSUME) {
|
||||
} else if (action == EVENT_CONSUME) {
|
||||
mpd->set_consume(!status->consume());
|
||||
} else if (cmd.compare(0, strlen(EVENT_SEEK), EVENT_SEEK) == 0) {
|
||||
auto s = cmd.substr(strlen(EVENT_SEEK));
|
||||
} else if (action.compare(0, strlen(EVENT_SEEK), EVENT_SEEK) == 0) {
|
||||
auto s = action.substr(strlen(EVENT_SEEK));
|
||||
int percentage = 0;
|
||||
if (s.empty()) {
|
||||
return false;
|
||||
|
@ -110,16 +110,16 @@ namespace modules {
|
||||
auto click_right = m_conf.get(name(), "click-right", ""s);
|
||||
|
||||
if (!click_middle.empty()) {
|
||||
m_builder->cmd(mousebtn::MIDDLE, click_middle);
|
||||
m_builder->action(mousebtn::MIDDLE, click_middle);
|
||||
}
|
||||
|
||||
if (!click_right.empty()) {
|
||||
m_builder->cmd(mousebtn::RIGHT, click_right);
|
||||
m_builder->action(mousebtn::RIGHT, click_right);
|
||||
}
|
||||
|
||||
m_builder->cmd(mousebtn::LEFT, EVENT_TOGGLE_MUTE);
|
||||
m_builder->cmd(mousebtn::SCROLL_UP, EVENT_VOLUME_UP);
|
||||
m_builder->cmd(mousebtn::SCROLL_DOWN, EVENT_VOLUME_DOWN);
|
||||
m_builder->action(mousebtn::LEFT, *this, EVENT_TOGGLE);
|
||||
m_builder->action(mousebtn::SCROLL_UP, *this, EVENT_INC);
|
||||
m_builder->action(mousebtn::SCROLL_DOWN, *this, EVENT_DEC);
|
||||
}
|
||||
|
||||
m_builder->append(output);
|
||||
@ -142,21 +142,19 @@ namespace modules {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pulseaudio_module::input(string&& cmd) {
|
||||
bool pulseaudio_module::input(string&& action) {
|
||||
if (!m_handle_events) {
|
||||
return false;
|
||||
} else if (cmd.compare(0, strlen(EVENT_PREFIX), EVENT_PREFIX) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
if (m_pulseaudio && !m_pulseaudio->get_name().empty()) {
|
||||
if (cmd.compare(0, strlen(EVENT_TOGGLE_MUTE), EVENT_TOGGLE_MUTE) == 0) {
|
||||
if (action == EVENT_TOGGLE) {
|
||||
m_pulseaudio->toggle_mute();
|
||||
} else if (cmd.compare(0, strlen(EVENT_VOLUME_UP), EVENT_VOLUME_UP) == 0) {
|
||||
} else if (action == EVENT_INC) {
|
||||
// cap above 100 (~150)?
|
||||
m_pulseaudio->inc_volume(m_interval);
|
||||
} else if (cmd.compare(0, strlen(EVENT_VOLUME_DOWN), EVENT_VOLUME_DOWN) == 0) {
|
||||
} else if (action == EVENT_DEC) {
|
||||
m_pulseaudio->inc_volume(-m_interval);
|
||||
} else {
|
||||
return false;
|
||||
|
@ -194,7 +194,7 @@ namespace modules {
|
||||
if(m_tail && m_command && m_command->is_running()) {
|
||||
action_replaced = string_util::replace_all(action_replaced, "%pid%", to_string(m_command->get_pid()));
|
||||
}
|
||||
m_builder->cmd(btn, action_replaced);
|
||||
m_builder->action(btn, action_replaced);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,9 +41,7 @@ namespace modules {
|
||||
*/
|
||||
bool systray_module::build(builder* builder, const string& tag) const {
|
||||
if (tag == TAG_LABEL_TOGGLE) {
|
||||
builder->cmd(mousebtn::LEFT, EVENT_TOGGLE);
|
||||
builder->node(m_label);
|
||||
builder->cmd_close();
|
||||
builder->action(mousebtn::LEFT, *this, EVENT_TOGGLE, m_label);
|
||||
} else if (tag == TAG_TRAY_CLIENTS && !m_hidden) {
|
||||
builder->append(TRAY_PLACEHOLDER);
|
||||
} else {
|
||||
@ -55,8 +53,8 @@ namespace modules {
|
||||
/**
|
||||
* Handle input event
|
||||
*/
|
||||
bool systray_module::input(string&& cmd) {
|
||||
if (cmd.find(EVENT_TOGGLE) != 0) {
|
||||
bool systray_module::input(string&& action) {
|
||||
if (action.find(EVENT_TOGGLE) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -32,19 +32,19 @@ namespace modules {
|
||||
auto scroll_down = m_conf.get(name(), "scroll-down", ""s);
|
||||
|
||||
if (!click_left.empty()) {
|
||||
m_builder->cmd(mousebtn::LEFT, click_left);
|
||||
m_builder->action(mousebtn::LEFT, click_left);
|
||||
}
|
||||
if (!click_middle.empty()) {
|
||||
m_builder->cmd(mousebtn::MIDDLE, click_middle);
|
||||
m_builder->action(mousebtn::MIDDLE, click_middle);
|
||||
}
|
||||
if (!click_right.empty()) {
|
||||
m_builder->cmd(mousebtn::RIGHT, click_right);
|
||||
m_builder->action(mousebtn::RIGHT, click_right);
|
||||
}
|
||||
if (!scroll_up.empty()) {
|
||||
m_builder->cmd(mousebtn::SCROLL_UP, scroll_up);
|
||||
m_builder->action(mousebtn::SCROLL_UP, scroll_up);
|
||||
}
|
||||
if (!scroll_down.empty()) {
|
||||
m_builder->cmd(mousebtn::SCROLL_DOWN, scroll_down);
|
||||
m_builder->action(mousebtn::SCROLL_DOWN, scroll_down);
|
||||
}
|
||||
|
||||
m_builder->append(output);
|
||||
|
@ -116,14 +116,14 @@ namespace modules {
|
||||
string output{module::get_output()};
|
||||
|
||||
if (m_scroll) {
|
||||
m_builder->cmd(mousebtn::SCROLL_UP, EVENT_SCROLLUP);
|
||||
m_builder->cmd(mousebtn::SCROLL_DOWN, EVENT_SCROLLDOWN);
|
||||
m_builder->action(mousebtn::SCROLL_UP, *this, EVENT_INC);
|
||||
m_builder->action(mousebtn::SCROLL_DOWN, *this, EVENT_DEC);
|
||||
}
|
||||
|
||||
m_builder->append(output);
|
||||
|
||||
m_builder->cmd_close();
|
||||
m_builder->cmd_close();
|
||||
m_builder->action_close();
|
||||
m_builder->action_close();
|
||||
|
||||
return m_builder->flush();
|
||||
}
|
||||
@ -147,13 +147,13 @@ namespace modules {
|
||||
/**
|
||||
* Process scroll events by changing backlight value
|
||||
*/
|
||||
bool xbacklight_module::input(string&& cmd) {
|
||||
bool xbacklight_module::input(string&& action) {
|
||||
double value_mod{0.0};
|
||||
|
||||
if (cmd == EVENT_SCROLLUP) {
|
||||
if (action == EVENT_INC) {
|
||||
value_mod = 5.0;
|
||||
m_log.info("%s: Increasing value by %i%", name(), value_mod);
|
||||
} else if (cmd == EVENT_SCROLLDOWN) {
|
||||
} else if (action == EVENT_DEC) {
|
||||
value_mod = -5.0;
|
||||
m_log.info("%s: Decreasing value by %i%", name(), -value_mod);
|
||||
} else {
|
||||
|
@ -172,9 +172,9 @@ namespace modules {
|
||||
string output{module::get_output()};
|
||||
|
||||
if (m_keyboard && m_keyboard->size() > 1) {
|
||||
m_builder->cmd(mousebtn::LEFT, EVENT_SWITCH);
|
||||
m_builder->action(mousebtn::LEFT, *this, EVENT_SWITCH);
|
||||
m_builder->append(output);
|
||||
m_builder->cmd_close();
|
||||
m_builder->action_close();
|
||||
} else {
|
||||
m_builder->append(output);
|
||||
}
|
||||
@ -207,8 +207,8 @@ namespace modules {
|
||||
/**
|
||||
* Handle input command
|
||||
*/
|
||||
bool xkeyboard_module::input(string&& cmd) {
|
||||
if (cmd.compare(0, strlen(EVENT_SWITCH), EVENT_SWITCH) != 0) {
|
||||
bool xkeyboard_module::input(string&& action) {
|
||||
if (action != EVENT_SWITCH) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -324,14 +324,14 @@ namespace modules {
|
||||
}
|
||||
|
||||
if (m_scroll) {
|
||||
m_builder->cmd(mousebtn::SCROLL_DOWN, string{EVENT_PREFIX} + string{EVENT_SCROLL_DOWN});
|
||||
m_builder->cmd(mousebtn::SCROLL_UP, string{EVENT_PREFIX} + string{EVENT_SCROLL_UP});
|
||||
m_builder->action(mousebtn::SCROLL_DOWN, *this, string{EVENT_PREV});
|
||||
m_builder->action(mousebtn::SCROLL_UP, *this, string{EVENT_NEXT});
|
||||
}
|
||||
|
||||
m_builder->append(output);
|
||||
|
||||
m_builder->cmd_close();
|
||||
m_builder->cmd_close();
|
||||
m_builder->action_close();
|
||||
m_builder->action_close();
|
||||
|
||||
return m_builder->flush();
|
||||
}
|
||||
@ -352,9 +352,7 @@ namespace modules {
|
||||
for (auto&& desktop : m_viewports[m_index]->desktops) {
|
||||
if (desktop->label.get()) {
|
||||
if (m_click && desktop->state != desktop_state::ACTIVE) {
|
||||
builder->cmd(mousebtn::LEFT, string{EVENT_PREFIX} + string{EVENT_CLICK} + to_string(desktop->index));
|
||||
builder->node(desktop->label);
|
||||
builder->cmd_close();
|
||||
builder->action(mousebtn::LEFT, *this, string{EVENT_FOCUS} + to_string(desktop->index), desktop->label);
|
||||
} else {
|
||||
builder->node(desktop->label);
|
||||
}
|
||||
@ -370,15 +368,9 @@ namespace modules {
|
||||
/**
|
||||
* Handle user input event
|
||||
*/
|
||||
bool xworkspaces_module::input(string&& cmd) {
|
||||
bool xworkspaces_module::input(string&& action) {
|
||||
std::lock_guard<std::mutex> lock(m_workspace_mutex);
|
||||
|
||||
size_t len{strlen(EVENT_PREFIX)};
|
||||
if (cmd.compare(0, len, EVENT_PREFIX) != 0) {
|
||||
return false;
|
||||
}
|
||||
cmd.erase(0, len);
|
||||
|
||||
vector<unsigned int> indexes;
|
||||
for (auto&& viewport : m_viewports) {
|
||||
for (auto&& desktop : viewport->desktops) {
|
||||
@ -391,12 +383,14 @@ namespace modules {
|
||||
unsigned int new_desktop{0};
|
||||
unsigned int current_desktop{ewmh_util::get_current_desktop()};
|
||||
|
||||
if ((len = strlen(EVENT_CLICK)) && cmd.compare(0, len, EVENT_CLICK) == 0) {
|
||||
new_desktop = std::strtoul(cmd.substr(len).c_str(), nullptr, 10);
|
||||
} else if ((len = strlen(EVENT_SCROLL_UP)) && cmd.compare(0, len, EVENT_SCROLL_UP) == 0) {
|
||||
size_t len;
|
||||
|
||||
if ((len = strlen(EVENT_FOCUS)) && action.compare(0, len, EVENT_FOCUS) == 0) {
|
||||
new_desktop = std::strtoul(action.substr(len).c_str(), nullptr, 10);
|
||||
} else if ((len = strlen(EVENT_NEXT)) && action.compare(0, len, EVENT_NEXT) == 0) {
|
||||
new_desktop = math_util::min<unsigned int>(indexes.back(), current_desktop + 1);
|
||||
new_desktop = new_desktop == current_desktop ? indexes.front() : new_desktop;
|
||||
} else if ((len = strlen(EVENT_SCROLL_DOWN)) && cmd.compare(0, len, EVENT_SCROLL_DOWN) == 0) {
|
||||
} else if ((len = strlen(EVENT_PREV)) && action.compare(0, len, EVENT_PREV) == 0) {
|
||||
new_desktop = math_util::max<unsigned int>(indexes.front(), current_desktop - 1);
|
||||
new_desktop = new_desktop == current_desktop ? indexes.back() : new_desktop;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user