From 4bf9c057fe00c397982bc610998f7f1d1fd39017 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Sun, 23 Jan 2022 21:23:31 +0100 Subject: [PATCH] Extract relative mode check to an inline function This will allow to reuse the condition in another function. --- app/src/screen.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/screen.c b/app/src/screen.c index af433648..31c63092 100644 --- a/app/src/screen.c +++ b/app/src/screen.c @@ -156,6 +156,12 @@ get_initial_optimal_size(struct sc_size content_size, uint16_t req_width, return window_size; } +static inline bool +sc_screen_is_relative_mode(struct sc_screen *screen) { + // screen->im.mp may be NULL if --no-control + return screen->im.mp && screen->im.mp->relative_mode; +} + static void sc_screen_capture_mouse(struct sc_screen *screen, bool capture) { if (SDL_SetRelativeMouseMode(capture)) { @@ -772,8 +778,7 @@ sc_screen_is_mouse_capture_key(SDL_Keycode key) { void sc_screen_handle_event(struct sc_screen *screen, SDL_Event *event) { - // screen->im.mp may be NULL if --no-control - bool relative_mode = screen->im.mp && screen->im.mp->relative_mode; + bool relative_mode = sc_screen_is_relative_mode(screen); switch (event->type) { case EVENT_NEW_FRAME: {