aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerek Stevens <nilix@nilfm.cc>2021-11-11 12:00:29 -0700
committerDerek Stevens <nilix@nilfm.cc>2021-11-11 12:00:29 -0700
commit9323cafb65092000e44a37ac9e581823a0a70fcc (patch)
tree3d0ae4bd9b928fa6fe1ccf57f89d4e4b137243bc
parent7a8843267f77fa917fb021254a39c958d7e86450 (diff)
menu.c: scroll wheel virt switch wraps around
-rw-r--r--menu.c27
1 files 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;