From 832871707fc3f2d37ff1891de8115d3a96301d15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net> Date: Tue, 25 Apr 2023 12:40:28 -0400 Subject: [PATCH] On a window resize event, only set the window size if it's different Fixes issue on Linux where the window size is constantly updated, and window rabidly steals focus. --- src/conio/sdl_con.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/conio/sdl_con.c b/src/conio/sdl_con.c index e5c3f3dcae..83815ae99b 100644 --- a/src/conio/sdl_con.c +++ b/src/conio/sdl_con.c @@ -454,9 +454,10 @@ int sdl_init(int mode) return(-1); } -static void internal_setwinsize(struct video_stats *vs) +static void internal_setwinsize(struct video_stats *vs, bool force) { int w, h; + bool changed = true; w = vs->winwidth; h = vs->winheight; @@ -469,11 +470,16 @@ static void internal_setwinsize(struct video_stats *vs) if (h < vs->scrnheight) h = vs->scrnheight; pthread_mutex_lock(&vstatlock); - vs->winwidth = vstat.winwidth = w; - vs->winheight = vstat.winheight = h; + if (w == vstat.winwidth && h == vstat.winheight) + changed = force; + else { + vs->winwidth = vstat.winwidth = w; + vs->winheight = vstat.winheight = h; + } pthread_mutex_unlock(&vstatlock); internal_scaling = window_can_scale_internally(vs); - setup_surfaces_locked(vs); + if (changed) + setup_surfaces_locked(vs); } void sdl_setwinsize(int w, int h) @@ -1037,7 +1043,7 @@ void sdl_video_event_thread(void *data) break; } pthread_mutex_unlock(&sdl_mode_mutex); - internal_setwinsize(&cvstat); + internal_setwinsize(&cvstat, false); break; case SDL_WINDOWEVENT_EXPOSED: bitmap_drv_request_pixels(); @@ -1197,7 +1203,7 @@ void sdl_video_event_thread(void *data) pthread_mutex_lock(&vstatlock); cvstat = vstat; pthread_mutex_unlock(&vstatlock); - internal_setwinsize(&cvstat); + internal_setwinsize(&cvstat, true); sdl_ufunc_retval=0; sem_post(&sdl_ufunc_ret); break; -- GitLab