feat(bspwm): Configurable scroll/click actions

This commit is contained in:
Michael Carlberg 2016-11-12 13:37:07 +01:00
parent 171e69bd30
commit 42bcfd9fa1
2 changed files with 26 additions and 9 deletions

View File

@ -70,6 +70,9 @@ namespace modules {
map<state_ws, label_t> m_statelabels; map<state_ws, label_t> m_statelabels;
label_t m_monitorlabel; label_t m_monitorlabel;
iconset_t m_icons; iconset_t m_icons;
bool m_click = true;
bool m_scroll = true;
bool m_pinworkspaces = true; bool m_pinworkspaces = true;
unsigned long m_hash; unsigned long m_hash;

View File

@ -11,6 +11,8 @@ namespace modules {
// Load configuration values // Load configuration values
GET_CONFIG_VALUE(name(), m_pinworkspaces, "pin-workspaces"); GET_CONFIG_VALUE(name(), m_pinworkspaces, "pin-workspaces");
GET_CONFIG_VALUE(name(), m_click, "enable-click");
GET_CONFIG_VALUE(name(), m_scroll, "enable-scroll");
// Add formats and create components // Add formats and create components
m_formatter->add(DEFAULT_FORMAT, TAG_LABEL_STATE, {TAG_LABEL_STATE}, {TAG_LABEL_MONITOR, TAG_LABEL_MODE}); m_formatter->add(DEFAULT_FORMAT, TAG_LABEL_STATE, {TAG_LABEL_STATE}, {TAG_LABEL_MONITOR, TAG_LABEL_MODE});
@ -283,16 +285,28 @@ 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); if (m_scroll) {
builder->cmd(mousebtn::SCROLL_UP, EVENT_SCROLL_UP); builder->cmd(mousebtn::SCROLL_DOWN, EVENT_SCROLL_DOWN);
if (ws.second.get()) { builder->cmd(mousebtn::SCROLL_UP, EVENT_SCROLL_UP);
string event{EVENT_CLICK}; }
event += to_string(m_index);
event += "+";
event += to_string(++workspace_n);
builder->cmd(mousebtn::LEFT, event); if (ws.second.get()) {
builder->node(ws.second); if (m_click) {
string event{EVENT_CLICK};
event += to_string(m_index);
event += "+";
event += to_string(++workspace_n);
builder->cmd(mousebtn::LEFT, event);
builder->node(ws.second);
builder->cmd_close(true);
} else {
builder->node(ws.second);
}
}
if (m_scroll) {
builder->cmd_close(true);
builder->cmd_close(true); builder->cmd_close(true);
} }
} }