From 0fd60a2bc50c624ff119e8d7d28057d646955541 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 27 May 2021 18:42:32 -0400 Subject: Avoid confusing fallthrough structure --- src/x11.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/x11.c b/src/x11.c index c95edff..b115b21 100644 --- a/src/x11.c +++ b/src/x11.c @@ -689,7 +689,9 @@ translateEvent(PuglView* const view, XEvent xevent) } break; case ButtonPress: - if (xevent.xbutton.button >= 4 && xevent.xbutton.button <= 7) { + case ButtonRelease: + if (xevent.type == ButtonPress && xevent.xbutton.button >= 4 && + xevent.xbutton.button <= 7) { event.type = PUGL_SCROLL; event.scroll.time = (double)xevent.xbutton.time / 1e3; event.scroll.x = xevent.xbutton.x; @@ -717,11 +719,7 @@ translateEvent(PuglView* const view, XEvent xevent) event.scroll.direction = PUGL_SCROLL_RIGHT; break; } - // fallthru - } - // fallthru - case ButtonRelease: - if (xevent.xbutton.button < 4 || xevent.xbutton.button > 7) { + } else if (xevent.xbutton.button < 4 || xevent.xbutton.button > 7) { event.button.type = ((xevent.type == ButtonPress) ? PUGL_BUTTON_PRESS : PUGL_BUTTON_RELEASE); event.button.time = (double)xevent.xbutton.time / 1e3; -- cgit v1.2.1