1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-11 13:50:56 -05:00

fix(i3): Check whether current ws is focused before issuing scroll commands #503

This commit is contained in:
Vasili Karaev 2017-03-30 13:53:35 +03:00 committed by Michael Carlberg
parent db0ab78d62
commit 68beb8d744

View file

@ -220,27 +220,23 @@ namespace modules {
} }
auto workspaces = i3_util::workspaces(conn, m_bar.monitor->name); auto workspaces = i3_util::workspaces(conn, m_bar.monitor->name);
auto current_ws_iter = find_if(workspaces.begin(), workspaces.end(), auto current_ws = *find_if(workspaces.begin(), workspaces.end(),
[](auto ws) { return ws->focused || ws->visible; }); [](auto ws) { return ws->visible; });
auto target_ws_iter = current_ws_iter;
if (scrolldir == "next") { if (scrolldir == "next" && (m_wrap || workspaces.back() != current_ws)) {
if (*current_ws_iter == workspaces.back() && m_wrap) { if (!current_ws->focused) {
target_ws_iter = workspaces.begin();
} else if (*current_ws_iter != workspaces.back()) {
target_ws_iter = std::next(current_ws_iter);
}
} else if (scrolldir == "prev") {
if (*current_ws_iter == workspaces.front() && m_wrap) {
target_ws_iter = std::prev(workspaces.end());
} else if (*current_ws_iter != workspaces.front()) {
target_ws_iter = std::prev(current_ws_iter);
}
}
if (current_ws_iter != target_ws_iter) {
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("workspace " + (*target_ws_iter)->name); conn.send_command("workspace " + current_ws->name);
}
m_log.info("%s: Sending workspace next_on_output command to ipc handler", name());
conn.send_command("workspace next_on_output");
} else if (scrolldir == "prev" && (m_wrap || workspaces.front() != current_ws)) {
if (!current_ws->focused) {
m_log.info("%s: Sending workspace focus command to ipc handler", name());
conn.send_command("workspace " + current_ws->name);
}
m_log.info("%s: Sending workspace prev_on_output command to ipc handler", name());
conn.send_command("workspace prev_on_output");
} }
} catch (const exception& err) { } catch (const exception& err) {