From 352f25ea40b28731a3ff347367bf67c410ee9961 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Mon, 23 Jul 2018 11:29:44 +0200 Subject: [PATCH] SDL2: recreate window on reconfigure This behaves better with Wayland backend. --- src/video_display/sdl2.cpp | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/video_display/sdl2.cpp b/src/video_display/sdl2.cpp index 6134902d6..46311e1ce 100644 --- a/src/video_display/sdl2.cpp +++ b/src/video_display/sdl2.cpp @@ -273,24 +273,21 @@ static int display_sdl_reconfigure_real(void *state, struct video_desc desc) s->current_display_desc = desc; + if (s->window) { + SDL_DestroyWindow(s->window); + } + int flags = SDL_WINDOW_RESIZABLE; + if (s->fs) { + flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; + } + const char *window_title = "UltraGrid - SDL2 Display"; + if (get_commandline_param("window-title")) { + window_title = get_commandline_param("window-title"); + } + s->window = SDL_CreateWindow(window_title, SDL_WINDOWPOS_CENTERED_DISPLAY(s->display_idx), SDL_WINDOWPOS_CENTERED_DISPLAY(s->display_idx), desc.width, desc.height, flags); if (!s->window) { - int flags = SDL_WINDOW_RESIZABLE; - if (s->fs) { - flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; - } - const char *window_title = "UltraGrid - SDL2 Display"; - if (get_commandline_param("window-title")) { - window_title = get_commandline_param("window-title"); - } - s->window = SDL_CreateWindow(window_title, SDL_WINDOWPOS_CENTERED_DISPLAY(s->display_idx), SDL_WINDOWPOS_CENTERED_DISPLAY(s->display_idx), desc.width, desc.height, flags); - if (!s->window) { - log_msg(LOG_LEVEL_ERROR, "[SDL] Unable to create window: %s\n", SDL_GetError()); - return FALSE; - } - } else { - if (!s->fs) { - SDL_SetWindowSize(s->window, desc.width, desc.height); - } + log_msg(LOG_LEVEL_ERROR, "[SDL] Unable to create window: %s\n", SDL_GetError()); + return FALSE; } if (s->renderer) {