From 9323cafb65092000e44a37ac9e581823a0a70fcc Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Thu, 11 Nov 2021 12:00:29 -0700 Subject: [PATCH] menu.c: scroll wheel virt switch wraps around --- menu.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/menu.c b/menu.c index 2b344a8..75f99e9 100644 --- a/menu.c +++ b/menu.c @@ -155,16 +155,29 @@ void button(XButtonEvent* e) { case Button3: break; case Button4: - /* scroll up changes to previous virtual screen */ + /* scroll up changes to previous virtual screen, wraps around */ if (!c && e->type == ButtonPress) - if (numvirtuals > 1 && virt > 0) - switch_to(virt - 1); + { + if (numvirtuals > 1) { + if (virt > 0) { + switch_to(virt - 1); + } else { + switch_to(numvirtuals - 1); + } + } + } return; case Button5: - /* scroll down changes to next virtual screen */ - if (!c && e->type == ButtonPress) - if (numvirtuals > 1 && virt < numvirtuals - 1) - switch_to(virt + 1); + /* scroll down changes to next virtual screen, wraps around */ + if (!c && e->type == ButtonPress) { + if (numvirtuals > 1) { + if (virt < numvirtuals - 1) { + switch_to(virt + 1); + } else { + switch_to(0); + } + } + } return; default: return;