menu.c: scroll wheel virt switch wraps around

This commit is contained in:
Iris Lightshard 2021-11-11 12:00:29 -07:00
parent 7a8843267f
commit 9323cafb65
Signed by: Iris Lightshard
GPG key ID: 3B7FBC22144E6398

23
menu.c
View file

@ -155,16 +155,29 @@ void button(XButtonEvent* e) {
case Button3: case Button3:
break; break;
case Button4: case Button4:
/* scroll up changes to previous virtual screen */ /* scroll up changes to previous virtual screen, wraps around */
if (!c && e->type == ButtonPress) if (!c && e->type == ButtonPress)
if (numvirtuals > 1 && virt > 0) {
if (numvirtuals > 1) {
if (virt > 0) {
switch_to(virt - 1); switch_to(virt - 1);
} else {
switch_to(numvirtuals - 1);
}
}
}
return; return;
case Button5: case Button5:
/* scroll down changes to next virtual screen */ /* scroll down changes to next virtual screen, wraps around */
if (!c && e->type == ButtonPress) if (!c && e->type == ButtonPress) {
if (numvirtuals > 1 && virt < numvirtuals - 1) if (numvirtuals > 1) {
if (virt < numvirtuals - 1) {
switch_to(virt + 1); switch_to(virt + 1);
} else {
switch_to(0);
}
}
}
return; return;
default: default:
return; return;