[client,sdl] add signal termination handler

This commit is contained in:
Armin Novak 2023-12-15 15:28:26 +01:00 committed by akallabeth
parent 2db9e1e258
commit 6e718f7958
1 changed files with 10 additions and 0 deletions

View File

@ -661,6 +661,13 @@ static const char* sdl_window_get_title(rdpSettings* settings)
return freerdp_settings_get_string(settings, FreeRDP_WindowTitle); return freerdp_settings_get_string(settings, FreeRDP_WindowTitle);
} }
static void sdl_term_handler(int signum, const char* signame, void* context)
{
SDL_Event ev = { 0 };
ev.type = SDL_QUIT;
SDL_PushEvent(&ev);
}
static void sdl_cleanup_sdl(SdlContext* sdl) static void sdl_cleanup_sdl(SdlContext* sdl)
{ {
if (!sdl) if (!sdl)
@ -670,6 +677,7 @@ static void sdl_cleanup_sdl(SdlContext* sdl)
sdl_destroy_primary(sdl); sdl_destroy_primary(sdl);
freerdp_del_signal_cleanup_handler(sdl->context(), sdl_term_handler);
SDL_Quit(); SDL_Quit();
} }
@ -792,6 +800,8 @@ static int sdl_run(SdlContext* sdl)
SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0"); SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0");
#endif #endif
freerdp_add_signal_cleanup_handler(sdl->context(), sdl_term_handler);
sdl->initialized.set(); sdl->initialized.set();
while (!freerdp_shall_disconnect_context(sdl->context())) while (!freerdp_shall_disconnect_context(sdl->context()))