feat(bspwm): added scrolling
This commit is contained in:
parent
dc2d33ceba
commit
fbd957bf33
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,5 +4,6 @@ tags
|
|||||||
*.bak
|
*.bak
|
||||||
*.pyc
|
*.pyc
|
||||||
*.tmp
|
*.tmp
|
||||||
|
*.swp
|
||||||
include/config.hpp
|
include/config.hpp
|
||||||
.tags
|
.tags
|
||||||
|
@ -55,7 +55,10 @@ namespace modules {
|
|||||||
static constexpr auto TAG_LABEL_MONITOR = "<label-monitor>";
|
static constexpr auto TAG_LABEL_MONITOR = "<label-monitor>";
|
||||||
static constexpr auto TAG_LABEL_STATE = "<label-state>";
|
static constexpr auto TAG_LABEL_STATE = "<label-state>";
|
||||||
static constexpr auto TAG_LABEL_MODE = "<label-mode>";
|
static constexpr auto TAG_LABEL_MODE = "<label-mode>";
|
||||||
static constexpr auto EVENT_CLICK = "bwm";
|
static constexpr auto EVENT_PREFIX = "bwm";
|
||||||
|
static constexpr auto EVENT_CLICK = "bwmf";
|
||||||
|
static constexpr auto EVENT_SCROLL_UP = "bwmn";
|
||||||
|
static constexpr auto EVENT_SCROLL_DOWN = "bwmp";
|
||||||
|
|
||||||
bspwm_util::connection_t m_subscriber;
|
bspwm_util::connection_t m_subscriber;
|
||||||
|
|
||||||
|
@ -289,6 +289,8 @@ namespace modules {
|
|||||||
int workspace_n = 0;
|
int workspace_n = 0;
|
||||||
|
|
||||||
for (auto&& ws : m_monitors[m_index]->workspaces) {
|
for (auto&& ws : m_monitors[m_index]->workspaces) {
|
||||||
|
builder->cmd(mousebtn::SCROLL_DOWN, EVENT_SCROLL_DOWN);
|
||||||
|
builder->cmd(mousebtn::SCROLL_UP, EVENT_SCROLL_UP);
|
||||||
if (ws.second.get()) {
|
if (ws.second.get()) {
|
||||||
string event{EVENT_CLICK};
|
string event{EVENT_CLICK};
|
||||||
event += to_string(m_index);
|
event += to_string(m_index);
|
||||||
@ -319,11 +321,19 @@ namespace modules {
|
|||||||
} // }}}
|
} // }}}
|
||||||
|
|
||||||
bool bspwm_module::handle_event(string cmd) { // {{{
|
bool bspwm_module::handle_event(string cmd) { // {{{
|
||||||
if (cmd.find(EVENT_CLICK) != 0) {
|
if (cmd.find(EVENT_PREFIX) != 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
auto send_command = [this](string payload_cmd, string log_info) {
|
||||||
|
auto ipc = bspwm_util::make_connection();
|
||||||
|
auto payload = bspwm_util::make_payload(payload_cmd);
|
||||||
|
m_log.info("%s: %s", name(), log_info);
|
||||||
|
ipc->send(payload->data, payload->len, 0);
|
||||||
|
ipc->disconnect();
|
||||||
|
};
|
||||||
|
if (cmd.compare(0, strlen(EVENT_CLICK), EVENT_CLICK) == 0) {
|
||||||
cmd.erase(0, strlen(EVENT_CLICK));
|
cmd.erase(0, strlen(EVENT_CLICK));
|
||||||
|
|
||||||
size_t separator = string_util::find_nth(cmd, 0, "+", 1);
|
size_t separator = string_util::find_nth(cmd, 0, "+", 1);
|
||||||
@ -331,17 +341,18 @@ namespace modules {
|
|||||||
string workspace_n = cmd.substr(separator + 1);
|
string workspace_n = cmd.substr(separator + 1);
|
||||||
|
|
||||||
if (monitor_n < m_monitors.size()) {
|
if (monitor_n < m_monitors.size()) {
|
||||||
auto ipc = bspwm_util::make_connection();
|
send_command("desktop -f " + m_monitors[monitor_n]->name + ":^" + workspace_n,
|
||||||
auto payload = bspwm_util::make_payload(
|
"Sending desktop focus command to ipc handler");
|
||||||
"desktop -f " + m_monitors[monitor_n]->name + ":^" + workspace_n);
|
|
||||||
|
|
||||||
m_log.info("%s: Sending desktop focus command to ipc handler", name());
|
|
||||||
|
|
||||||
ipc->send(payload->data, payload->len, 0);
|
|
||||||
ipc->disconnect();
|
|
||||||
} else {
|
} else {
|
||||||
m_log.err("%s: Invalid monitor index in command: %s", name(), cmd);
|
m_log.err("%s: Invalid monitor index in command: %s", name(), cmd);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else if (cmd.compare(0, strlen(EVENT_SCROLL_UP), EVENT_SCROLL_UP) == 0) {
|
||||||
|
send_command("desktop -f next", "Sending desktop next command to ipc handler");
|
||||||
|
}
|
||||||
|
else if (cmd.compare(0, strlen(EVENT_SCROLL_DOWN), EVENT_SCROLL_DOWN) == 0) {
|
||||||
|
send_command("desktop -f prev", "Sending desktop prev command to ipc handler");
|
||||||
|
}
|
||||||
} catch (const system_error& err) {
|
} catch (const system_error& err) {
|
||||||
m_log.err("%s: %s", name(), err.what());
|
m_log.err("%s: %s", name(), err.what());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user