Fullscreen/windowed fixes when using overrides (#16213)

This commit is contained in:
Bobby Smith 2024-02-09 20:54:46 +01:00 committed by GitHub
parent bc5805e8e6
commit c43f4738d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 38 additions and 8 deletions

View File

@ -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 */

View File

@ -569,6 +569,7 @@ typedef struct settings
} paths;
bool modified;
bool skip_window_positions;
struct
{

View File

@ -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)
{