From 5173b85ac1fb69ce24dbf8aa4e410ef3dbbc5b2d Mon Sep 17 00:00:00 2001 From: Matthew Budd Date: Fri, 15 May 2020 17:02:33 -0400 Subject: [PATCH] Added logic to check if the screen size has actually changed in the window configure event callback. Do not reset video is screen size is the same. This prevents annoying screen flickering during transitions to/from full screen mode. --- src/drivers/sdl/gui.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/drivers/sdl/gui.cpp b/src/drivers/sdl/gui.cpp index 4a3e4676..51f6d88f 100644 --- a/src/drivers/sdl/gui.cpp +++ b/src/drivers/sdl/gui.cpp @@ -64,6 +64,8 @@ GtkRadioAction *stateSlot = NULL; bool gtkIsStarted = false; bool menuTogglingEnabled = false; +unsigned int gtk_win_width = NES_WIDTH; +unsigned int gtk_win_height = NES_HEIGHT; unsigned int gtk_draw_area_width = NES_WIDTH; unsigned int gtk_draw_area_height = NES_HEIGHT; static GtkTreeStore *hotkey_store = NULL; @@ -3013,11 +3015,16 @@ gboolean handle_resize (GtkWindow * win, GdkEvent * event, gpointer data) // of the GTK window as possible // get new window width/height - int width, height; + int width, height, winsize_changed; width = event->configure.width; height = event->configure.height; //printf ("DEBUG: Configure new window size: %dx%d\n", width, height); + winsize_changed = (width != gtk_win_width) || (height != gtk_win_height); + + gtk_win_width = width; + gtk_win_height = height; + // get width/height multipliers double xscale = width / (double) NES_WIDTH; double yscale = height / (double) NES_HEIGHT; @@ -3039,8 +3046,9 @@ gboolean handle_resize (GtkWindow * win, GdkEvent * event, gpointer data) g_config->setOption ("SDL.XScale", xscale); g_config->setOption ("SDL.YScale", yscale); //gtk_widget_realize(evbox); + flushGtkEvents (); - if (GameInfo != 0) + if ( winsize_changed && (GameInfo != 0) ) { KillVideo (); InitVideo (GameInfo);