From ebef027c4f13e7cd30743525e845ad06b3660679 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Fri, 21 Jan 2022 19:16:32 +0100 Subject: [PATCH] Do not return status for event handling It is never read. Simplify. --- app/src/input_manager.c | 18 ++++++++---------- app/src/input_manager.h | 2 +- app/src/scrcpy.c | 3 +-- app/src/screen.c | 20 ++++++++++---------- app/src/screen.h | 2 +- 5 files changed, 21 insertions(+), 24 deletions(-) diff --git a/app/src/input_manager.c b/app/src/input_manager.c index 9eee6e6c..e1e8738c 100644 --- a/app/src/input_manager.c +++ b/app/src/input_manager.c @@ -834,45 +834,43 @@ sc_input_manager_process_mouse_wheel(struct sc_input_manager *im, im->mp->ops->process_mouse_scroll(im->mp, &evt); } -bool +void sc_input_manager_handle_event(struct sc_input_manager *im, SDL_Event *event) { switch (event->type) { case SDL_TEXTINPUT: if (!im->control) { - return true; + break; } sc_input_manager_process_text_input(im, &event->text); - return true; + break; case SDL_KEYDOWN: case SDL_KEYUP: // some key events do not interact with the device, so process the // event even if control is disabled sc_input_manager_process_key(im, &event->key); - return true; + break; case SDL_MOUSEMOTION: if (!im->control) { break; } sc_input_manager_process_mouse_motion(im, &event->motion); - return true; + break; case SDL_MOUSEWHEEL: if (!im->control) { break; } sc_input_manager_process_mouse_wheel(im, &event->wheel); - return true; + break; case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: // some mouse events do not interact with the device, so process // the event even if control is disabled sc_input_manager_process_mouse_button(im, &event->button); - return true; + break; case SDL_FINGERMOTION: case SDL_FINGERDOWN: case SDL_FINGERUP: sc_input_manager_process_touch(im, &event->tfinger); - return true; + break; } - - return false; } diff --git a/app/src/input_manager.h b/app/src/input_manager.h index 5d552ee2..b28b110f 100644 --- a/app/src/input_manager.h +++ b/app/src/input_manager.h @@ -59,7 +59,7 @@ void sc_input_manager_init(struct sc_input_manager *im, const struct sc_input_manager_params *params); -bool +void sc_input_manager_handle_event(struct sc_input_manager *im, SDL_Event *event); #endif diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c index d628df51..1c03b8c1 100644 --- a/app/src/scrcpy.c +++ b/app/src/scrcpy.c @@ -195,8 +195,7 @@ handle_event(struct scrcpy *s, const struct scrcpy_options *options, } } - bool consumed = sc_screen_handle_event(&s->screen, event); - (void) consumed; + sc_screen_handle_event(&s->screen, event); end: return EVENT_RESULT_CONTINUE; diff --git a/app/src/screen.c b/app/src/screen.c index a357eecf..b1abe985 100644 --- a/app/src/screen.c +++ b/app/src/screen.c @@ -770,7 +770,7 @@ sc_screen_is_mouse_capture_key(SDL_Keycode key) { return key == SDLK_LALT || key == SDLK_LGUI || key == SDLK_RGUI; } -bool +void sc_screen_handle_event(struct sc_screen *screen, SDL_Event *event) { switch (event->type) { case EVENT_NEW_FRAME: { @@ -778,12 +778,12 @@ sc_screen_handle_event(struct sc_screen *screen, SDL_Event *event) { if (!ok) { LOGW("Frame update failed\n"); } - return true; + return; } case SDL_WINDOWEVENT: if (!screen->has_frame) { // Do nothing - return true; + return; } switch (event->window.event) { case SDL_WINDOWEVENT_EXPOSED: @@ -814,14 +814,14 @@ sc_screen_handle_event(struct sc_screen *screen, SDL_Event *event) { } break; } - return true; + return; case SDL_KEYDOWN: if (screen->im.mp->relative_mode) { SDL_Keycode key = event->key.keysym.sym; if (sc_screen_is_mouse_capture_key(key)) { if (!screen->mouse_capture_key_pressed) { screen->mouse_capture_key_pressed = key; - return true; + return; } else { // Another mouse capture key has been pressed, cancel // mouse (un)capture @@ -841,7 +841,7 @@ sc_screen_handle_event(struct sc_screen *screen, SDL_Event *event) { // A mouse capture key has been pressed then released: // toggle the capture mouse mode sc_screen_capture_mouse(screen, !screen->mouse_captured); - return true; + return; } // Do not return, the event must be forwarded to the input // manager @@ -853,7 +853,7 @@ sc_screen_handle_event(struct sc_screen *screen, SDL_Event *event) { if (screen->im.mp->relative_mode && !screen->mouse_captured) { // Do not forward to input manager, the mouse will be captured // on SDL_MOUSEBUTTONUP - return true; + return; } break; case SDL_FINGERMOTION: @@ -862,17 +862,17 @@ sc_screen_handle_event(struct sc_screen *screen, SDL_Event *event) { if (screen->im.mp->relative_mode) { // Touch events are not compatible with relative mode // (coordinates are not relative) - return true; + return; } break; case SDL_MOUSEBUTTONUP: if (screen->im.mp->relative_mode && !screen->mouse_captured) { sc_screen_capture_mouse(screen, true); - return true; + return; } } - return sc_input_manager_handle_event(&screen->im, event); + sc_input_manager_handle_event(&screen->im, event); } struct sc_point diff --git a/app/src/screen.h b/app/src/screen.h index 3e6c1031..8af53a5e 100644 --- a/app/src/screen.h +++ b/app/src/screen.h @@ -139,7 +139,7 @@ void sc_screen_set_rotation(struct sc_screen *screen, unsigned rotation); // react to SDL events -bool +void sc_screen_handle_event(struct sc_screen *screen, SDL_Event *event); // convert point from window coordinates to frame coordinates