Do not use reverse-scroll for prev/next actions
The next action should always select the next workspace, the same for prev. reverse-scroll should be directly used when setting the scroll actions. This changes the behavior of `prev` and `next` actions in the i3 and bspwm module. But I don't think the impact will be significant and the old behavior was misleading anyway.
This commit is contained in:
parent
5e64361ed8
commit
658ed6974d
@ -1,14 +1,14 @@
|
|||||||
|
#include "modules/bspwm.hpp"
|
||||||
|
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
|
||||||
#include "drawtypes/iconset.hpp"
|
#include "drawtypes/iconset.hpp"
|
||||||
#include "drawtypes/label.hpp"
|
#include "drawtypes/label.hpp"
|
||||||
#include "modules/bspwm.hpp"
|
#include "modules/meta/base.inl"
|
||||||
#include "utils/factory.hpp"
|
#include "utils/factory.hpp"
|
||||||
#include "utils/file.hpp"
|
#include "utils/file.hpp"
|
||||||
#include "utils/string.hpp"
|
#include "utils/string.hpp"
|
||||||
|
|
||||||
#include "modules/meta/base.inl"
|
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -35,7 +35,7 @@ namespace {
|
|||||||
}
|
}
|
||||||
return (base & mask) == mask;
|
return (base & mask) == mask;
|
||||||
}
|
}
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
namespace modules {
|
namespace modules {
|
||||||
template class module<bspwm_module>;
|
template class module<bspwm_module>;
|
||||||
@ -396,8 +396,8 @@ namespace modules {
|
|||||||
size_t workspace_n{0U};
|
size_t workspace_n{0U};
|
||||||
|
|
||||||
if (m_scroll) {
|
if (m_scroll) {
|
||||||
builder->action(mousebtn::SCROLL_DOWN, *this, EVENT_PREV, "");
|
builder->action(mousebtn::SCROLL_DOWN, *this, m_revscroll ? EVENT_NEXT : EVENT_PREV, "");
|
||||||
builder->action(mousebtn::SCROLL_UP, *this, EVENT_NEXT, "");
|
builder->action(mousebtn::SCROLL_UP, *this, m_revscroll ? EVENT_PREV : EVENT_NEXT, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto&& ws : m_monitors[m_index]->workspaces) {
|
for (auto&& ws : m_monitors[m_index]->workspaces) {
|
||||||
@ -476,9 +476,9 @@ namespace modules {
|
|||||||
string scrolldir;
|
string scrolldir;
|
||||||
|
|
||||||
if (action == EVENT_NEXT) {
|
if (action == EVENT_NEXT) {
|
||||||
scrolldir = m_revscroll ? "prev" : "next";
|
scrolldir = "next";
|
||||||
} else if (action == EVENT_PREV) {
|
} else if (action == EVENT_PREV) {
|
||||||
scrolldir = m_revscroll ? "next" : "prev";
|
scrolldir = "prev";
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -495,11 +495,10 @@ namespace modules {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
send_command("desktop -f " + scrolldir + modifier, "Sending desktop " + scrolldir + " command to ipc handler");
|
send_command("desktop -f " + scrolldir + modifier, "Sending desktop " + scrolldir + " command to ipc handler");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
} // namespace modules
|
||||||
|
|
||||||
POLYBAR_NS_END
|
POLYBAR_NS_END
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
|
#include "modules/i3.hpp"
|
||||||
|
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
|
||||||
#include "drawtypes/iconset.hpp"
|
#include "drawtypes/iconset.hpp"
|
||||||
#include "drawtypes/label.hpp"
|
#include "drawtypes/label.hpp"
|
||||||
#include "modules/i3.hpp"
|
#include "modules/meta/base.inl"
|
||||||
#include "utils/factory.hpp"
|
#include "utils/factory.hpp"
|
||||||
#include "utils/file.hpp"
|
#include "utils/file.hpp"
|
||||||
|
|
||||||
#include "modules/meta/base.inl"
|
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
namespace modules {
|
namespace modules {
|
||||||
@ -183,8 +183,8 @@ namespace modules {
|
|||||||
builder->node(m_modelabel);
|
builder->node(m_modelabel);
|
||||||
} else if (tag == TAG_LABEL_STATE && !m_workspaces.empty()) {
|
} else if (tag == TAG_LABEL_STATE && !m_workspaces.empty()) {
|
||||||
if (m_scroll) {
|
if (m_scroll) {
|
||||||
builder->action(mousebtn::SCROLL_DOWN, *this, EVENT_PREV, "");
|
builder->action(mousebtn::SCROLL_DOWN, *this, m_revscroll ? EVENT_NEXT : EVENT_PREV, "");
|
||||||
builder->action(mousebtn::SCROLL_UP, *this, EVENT_NEXT, "");
|
builder->action(mousebtn::SCROLL_UP, *this, m_revscroll ? EVENT_PREV : EVENT_NEXT, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool first = true;
|
bool first = true;
|
||||||
@ -195,8 +195,7 @@ namespace modules {
|
|||||||
*/
|
*/
|
||||||
if (first) {
|
if (first) {
|
||||||
first = false;
|
first = false;
|
||||||
}
|
} else if (*m_labelseparator) {
|
||||||
else if (*m_labelseparator) {
|
|
||||||
builder->node(m_labelseparator);
|
builder->node(m_labelseparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,33 +227,28 @@ namespace modules {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
string scrolldir;
|
if (action != EVENT_NEXT && action != EVENT_PREV) {
|
||||||
|
|
||||||
if (action == EVENT_NEXT) {
|
|
||||||
scrolldir = m_revscroll ? "prev" : "next";
|
|
||||||
} else if (action == EVENT_PREV) {
|
|
||||||
scrolldir = m_revscroll ? "next" : "prev";
|
|
||||||
} else {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool next = action == EVENT_NEXT;
|
||||||
|
|
||||||
auto workspaces = i3_util::workspaces(conn, m_bar.monitor->name);
|
auto workspaces = i3_util::workspaces(conn, m_bar.monitor->name);
|
||||||
auto current_ws = find_if(workspaces.begin(), workspaces.end(),
|
auto current_ws = std::find_if(workspaces.begin(), workspaces.end(), [](auto ws) { return ws->visible; });
|
||||||
[](auto ws) { return ws->visible; });
|
|
||||||
|
|
||||||
if (current_ws == workspaces.end()) {
|
if (current_ws == workspaces.end()) {
|
||||||
m_log.warn("%s: Current workspace not found", name());
|
m_log.warn("%s: Current workspace not found", name());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scrolldir == "next" && (m_wrap || next(current_ws) != workspaces.end())) {
|
if (next && (m_wrap || std::next(current_ws) != workspaces.end())) {
|
||||||
if (!(*current_ws)->focused) {
|
if (!(*current_ws)->focused) {
|
||||||
m_log.info("%s: Sending workspace focus command to ipc handler", name());
|
m_log.info("%s: Sending workspace focus command to ipc handler", name());
|
||||||
conn.send_command(make_workspace_command((*current_ws)->name));
|
conn.send_command(make_workspace_command((*current_ws)->name));
|
||||||
}
|
}
|
||||||
m_log.info("%s: Sending workspace next_on_output command to ipc handler", name());
|
m_log.info("%s: Sending workspace next_on_output command to ipc handler", name());
|
||||||
conn.send_command("workspace next_on_output");
|
conn.send_command("workspace next_on_output");
|
||||||
} else if (scrolldir == "prev" && (m_wrap || current_ws != workspaces.begin())) {
|
} else if (!next && (m_wrap || current_ws != workspaces.begin())) {
|
||||||
if (!(*current_ws)->focused) {
|
if (!(*current_ws)->focused) {
|
||||||
m_log.info("%s: Sending workspace focus command to ipc handler", name());
|
m_log.info("%s: Sending workspace focus command to ipc handler", name());
|
||||||
conn.send_command(make_workspace_command((*current_ws)->name));
|
conn.send_command(make_workspace_command((*current_ws)->name));
|
||||||
|
Loading…
Reference in New Issue
Block a user