From b9885ff21e499f1fc963267d24632ce00d9ffeb5 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sun, 14 Oct 2012 21:05:44 +0200 Subject: [PATCH] =?utf8?q?bugfix:=20don=E2=80=99t=20send=20workspace=20com?= =?utf8?q?mand=20when=20at=20beginning/end=20of=20workspaces=20(Thanks=20w?= =?utf8?q?hitequark)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit fixes #843 --- i3bar/src/xcb.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/i3bar/src/xcb.c b/i3bar/src/xcb.c index 405eefdb..2c0d2a6a 100644 --- a/i3bar/src/xcb.c +++ b/i3bar/src/xcb.c @@ -302,16 +302,24 @@ void handle_button(xcb_button_press_event_t *event) { } break; case 4: - /* Mouse wheel down. We select the next ws */ - if (cur_ws != TAILQ_FIRST(walk->workspaces)) { - cur_ws = TAILQ_PREV(cur_ws, ws_head, tailq); - } + /* Mouse wheel up. We select the previous ws, if any. + * If there is no more workspace, don’t even send the workspace + * command, otherwise (with workspace auto_back_and_forth) we’d end + * up on the wrong workspace. */ + if (cur_ws == TAILQ_FIRST(walk->workspaces)) + return; + + cur_ws = TAILQ_PREV(cur_ws, ws_head, tailq); break; case 5: - /* Mouse wheel up. We select the previos ws */ - if (cur_ws != TAILQ_LAST(walk->workspaces, ws_head)) { - cur_ws = TAILQ_NEXT(cur_ws, tailq); - } + /* Mouse wheel down. We select the next ws, if any. + * If there is no more workspace, don’t even send the workspace + * command, otherwise (with workspace auto_back_and_forth) we’d end + * up on the wrong workspace. */ + if (cur_ws == TAILQ_LAST(walk->workspaces, ws_head)) + return; + + cur_ws = TAILQ_NEXT(cur_ws, tailq); break; } -- 2.39.5