diff --git a/configuration.c b/configuration.c index eecc14c050..79f490bfaf 100644 --- a/configuration.c +++ b/configuration.c @@ -33,6 +33,7 @@ #endif #include "file_path_special.h" +#include "command.h" #include "configuration.h" #include "content.h" #include "config.def.h" @@ -4451,6 +4452,10 @@ bool config_load_override_file(const char *config_path) */ bool config_unload_override(void) { + settings_t *settings = config_st; + bool fullscreen_prev = settings->bools.video_fullscreen; + uint32_t flags = runloop_get_flags(); + runloop_state_get_ptr()->flags &= ~RUNLOOP_FLAG_OVERRIDES_ACTIVE; path_clear(RARCH_PATH_CONFIG_OVERRIDE); @@ -4462,6 +4467,20 @@ bool config_unload_override(void) path_get(RARCH_PATH_CONFIG), config_st)) return false; + if (settings->bools.video_fullscreen != fullscreen_prev) + { + /* This is for 'win32_common.c', so we don't save + * fullscreen size and position if we're switching + * back to windowed mode. + * Might be useful for other devices as well? */ + if ( settings->bools.video_window_save_positions + && !settings->bools.video_fullscreen) + settings->skip_window_positions = true; + + if (flags & RUNLOOP_FLAG_CORE_RUNNING) + command_event(CMD_EVENT_REINIT, NULL); + } + RARCH_LOG("[Overrides]: Configuration overrides unloaded, original configuration restored.\n"); /* Reset save paths */ diff --git a/configuration.h b/configuration.h index abddbad675..7e491941b8 100644 --- a/configuration.h +++ b/configuration.h @@ -569,6 +569,7 @@ typedef struct settings } paths; bool modified; + bool skip_window_positions; struct { diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index 8cbc5f9f4d..5ddcd7de60 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -877,17 +877,27 @@ static void win32_save_position(void) placement.rcNormalPosition.right = 0; placement.rcNormalPosition.bottom = 0; - if (GetWindowPlacement(main_window.hwnd, &placement)) + /* If 'skip_window_positions' is true it means we've + * just unloaded an override that had fullscreen mode + * enabled while we have windowed mode set globally, + * in this case we skip the following blocks to not + * end up with fullscreen size and position. */ + if (!settings->skip_window_positions) { - g_win32->pos_x = placement.rcNormalPosition.left; - g_win32->pos_y = placement.rcNormalPosition.top; - } + if (GetWindowPlacement(main_window.hwnd, &placement)) + { + g_win32->pos_x = placement.rcNormalPosition.left; + g_win32->pos_y = placement.rcNormalPosition.top; + } - if (GetWindowRect(main_window.hwnd, &rect)) - { - g_win32->pos_width = rect.right - rect.left; - g_win32->pos_height = rect.bottom - rect.top; + if (GetWindowRect(main_window.hwnd, &rect)) + { + g_win32->pos_width = rect.right - rect.left; + g_win32->pos_height = rect.bottom - rect.top; + } } + else + settings->skip_window_positions = false; if (window_save_positions) {