From d6b0c5f003b4f8fb9f276c9eade989ce2b6ea98a Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Sun, 2 Apr 2017 18:21:09 +0200 Subject: [PATCH] fix(bspwm): Focus monitor before sending scroll cmd #503 --- src/modules/bspwm.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/modules/bspwm.cpp b/src/modules/bspwm.cpp index 0ae8e725..e26b0677 100644 --- a/src/modules/bspwm.cpp +++ b/src/modules/bspwm.cpp @@ -473,25 +473,31 @@ namespace modules { return true; } - string modifier; string scrolldir; - if (m_pinworkspaces) { - modifier = ".local"; - } - if (cmd.compare(0, strlen(EVENT_SCROLL_UP), EVENT_SCROLL_UP) == 0) { scrolldir = m_revscroll ? "prev" : "next"; } else if (cmd.compare(0, strlen(EVENT_SCROLL_DOWN), EVENT_SCROLL_DOWN) == 0) { scrolldir = m_revscroll ? "next" : "prev"; - } - - if (!scrolldir.empty()) { - send_command("desktop -f " + scrolldir + modifier, "Sending desktop " + scrolldir + " command to ipc handler"); } else { return false; } + string modifier; + + if (m_pinworkspaces) { + modifier = ".local"; + } + + for (const auto& mon : m_monitors) { + if (m_bar.monitor->match(mon->name, false) && !mon->focused) { + send_command("monitor -f " + mon->name, "Sending monitor focus command to ipc handler"); + break; + } + } + + send_command("desktop -f " + scrolldir + modifier, "Sending desktop " + scrolldir + " command to ipc handler"); + return true; } }