From 41a0cfe5162f6f6ce57b1fce5eb28f7ea32a1993 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sun, 17 Jan 2021 14:28:50 +1100 Subject: [PATCH] [client] app: move SDL mouse event handling out of main.c --- client/displayservers/SDL/sdl.c | 28 +++++++++++++++++++++++++++ client/src/main.c | 34 --------------------------------- 2 files changed, 28 insertions(+), 34 deletions(-) diff --git a/client/displayservers/SDL/sdl.c b/client/displayservers/SDL/sdl.c index d811a340..ba0d0672 100644 --- a/client/displayservers/SDL/sdl.c +++ b/client/displayservers/SDL/sdl.c @@ -81,6 +81,34 @@ static bool sdlEventFilter(SDL_Event * event) app_handleMouseNormal(event->motion.xrel, event->motion.yrel); return true; + case SDL_MOUSEBUTTONDOWN: + { + int button = event->button.button; + if (button > 3) + button += 2; + + app_handleButtonPress(button); + return true; + } + + case SDL_MOUSEBUTTONUP: + { + int button = event->button.button; + if (button > 3) + button += 2; + + app_handleButtonRelease(button); + return true; + } + + case SDL_MOUSEWHEEL: + { + int button = event->wheel.y > 0 ? 4 : 5; + app_handleButtonPress(button); + app_handleButtonRelease(button); + return true; + } + case SDL_WINDOWEVENT: switch(event->window.event) { diff --git a/client/src/main.c b/client/src/main.c index ca5db704..66d04b6a 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -1445,40 +1445,6 @@ int eventFilter(void * userdata, SDL_Event * event) } break; } - - case SDL_MOUSEWHEEL: - if (!app_inputEnabled() || !g_cursor.inView) - break; - - if ( - !spice_mouse_press (event->wheel.y > 0 ? 4 : 5) || - !spice_mouse_release(event->wheel.y > 0 ? 4 : 5) - ) - { - DEBUG_ERROR("SDL_MOUSEWHEEL: failed to send messages"); - break; - } - break; - - case SDL_MOUSEBUTTONDOWN: - { - int button = event->button.button; - if (button > 3) - button += 2; - - app_handleButtonPress(button); - break; - } - - case SDL_MOUSEBUTTONUP: - { - int button = event->button.button; - if (button > 3) - button += 2; - - app_handleButtonRelease(button); - break; - } } // consume all events