From 324e8c7813414ce570d1f76eb22f26a28acbb24d Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Tue, 30 May 2023 18:22:57 +0200 Subject: [PATCH] [client,sdl] use SDL_WaitEvent --- client/SDL/sdl_freerdp.cpp | 7 ++++++- client/SDL/sdl_utils.cpp | 3 ++- client/SDL/sdl_utils.hpp | 3 ++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/client/SDL/sdl_freerdp.cpp b/client/SDL/sdl_freerdp.cpp index 7b49444fa..f5e98a8f5 100644 --- a/client/SDL/sdl_freerdp.cpp +++ b/client/SDL/sdl_freerdp.cpp @@ -700,7 +700,7 @@ static int sdl_run(sdlContext* sdl) { SDL_Event windowEvent = { 0 }; while (!freerdp_shall_disconnect_context(&sdl->common.context) && - SDL_PollEvent(&windowEvent)) + SDL_WaitEvent(&windowEvent)) { #if defined(WITH_DEBUG_SDL_EVENTS) SDL_Log("got event %s [0x%08" PRIx32 "]", sdl_event_type_str(windowEvent.type), @@ -854,6 +854,7 @@ static int sdl_run(sdlContext* sdl) case SDL_USEREVENT_POINTER_SET: sdl_Pointer_Set_Process(&windowEvent.user); break; + case SDL_USEREVENT_QUIT: default: break; } @@ -1103,6 +1104,10 @@ terminate: sdl_map_to_code_tag(exit_code), exit_code); sdl->exit_code = exit_code; + sdl_push_user_event(SDL_USEREVENT_QUIT); +#if SDL_VERSION_ATLEAST(2, 0, 16) + SDL_TLSCleanup(); +#endif return 0; } diff --git a/client/SDL/sdl_utils.cpp b/client/SDL/sdl_utils.cpp index 9ffd0d70b..67826e2cb 100644 --- a/client/SDL/sdl_utils.cpp +++ b/client/SDL/sdl_utils.cpp @@ -103,7 +103,7 @@ const char* sdl_event_type_str(Uint32 type) EV_CASE_STR(SDL_USEREVENT_POINTER_DEFAULT); EV_CASE_STR(SDL_USEREVENT_POINTER_POSITION); EV_CASE_STR(SDL_USEREVENT_POINTER_SET); - + EV_CASE_STR(SDL_USEREVENT_QUIT); EV_CASE_STR(SDL_LASTEVENT); default: return "SDL_UNKNOWNEVENT"; @@ -163,6 +163,7 @@ BOOL sdl_push_user_event(Uint32 type, ...) event->data1 = va_arg(ap, void*); event->code = va_arg(ap, int); break; + case SDL_USEREVENT_QUIT: case SDL_USEREVENT_POINTER_NULL: case SDL_USEREVENT_POINTER_DEFAULT: break; diff --git a/client/SDL/sdl_utils.hpp b/client/SDL/sdl_utils.hpp index f9daf06aa..4c5067a84 100644 --- a/client/SDL/sdl_utils.hpp +++ b/client/SDL/sdl_utils.hpp @@ -50,7 +50,8 @@ enum SDL_USEREVENT_POINTER_NULL, SDL_USEREVENT_POINTER_DEFAULT, SDL_USEREVENT_POINTER_POSITION, - SDL_USEREVENT_POINTER_SET + SDL_USEREVENT_POINTER_SET, + SDL_USEREVENT_QUIT }; BOOL sdl_push_user_event(Uint32 type, ...);