From a7f989fdb6bde1e3504a5d09015dfaec138a89d0 Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 17 Dec 2017 12:56:26 -0500 Subject: [PATCH] fix fullscreen toggle --- command.c | 16 +++++++++++++--- command.h | 2 ++ configuration.c | 8 -------- gfx/video_driver.c | 6 +++--- intl/msg_hash_us.h | 4 ++-- menu/menu_setting.c | 2 +- retroarch.c | 8 +++++--- retroarch.h | 2 ++ 8 files changed, 28 insertions(+), 20 deletions(-) diff --git a/command.c b/command.c index 0745ec1d22..0b3f966bab 100644 --- a/command.c +++ b/command.c @@ -1957,6 +1957,10 @@ bool command_event(enum event_command cmd, void *data) cheevos_toggle_hardcore_mode(); #endif break; + /* this fallthrough is on purpose, it should do + a CMD_EVENT_REINIT too */ + case CMD_EVENT_REINIT_FROM_TOGGLE: + retroarch_unset_forced_fullscreen(); case CMD_EVENT_REINIT: video_driver_reinit(); /* Poll input to avoid possibly stale data to corrupt things. */ @@ -2567,15 +2571,21 @@ TODO: Add a setting for these tweaks */ case CMD_EVENT_FULLSCREEN_TOGGLE: { settings_t *settings = config_get_ptr(); - bool new_fullscreen_state = !settings->bools.video_fullscreen; + bool new_fullscreen_state = !settings->bools.video_fullscreen + && !retroarch_is_forced_fullscreen(); if (!video_driver_has_windowed()) return false; - /* If we go fullscreen we drop all drivers and - * reinitialize to be safe. */ + /* we toggled manually, write the new value to settings */ configuration_set_bool(settings, settings->bools.video_fullscreen, new_fullscreen_state); + /* we toggled manually, the cli arg is irrelevant now */ + if (retroarch_is_forced_fullscreen()) + retroarch_unset_forced_fullscreen(); + + /* If we go fullscreen we drop all drivers and + * reinitialize to be safe. */ command_event(CMD_EVENT_REINIT, NULL); if (settings->bools.video_fullscreen) video_driver_hide_mouse(); diff --git a/command.h b/command.h index 858fcd820f..dd5099f9bc 100644 --- a/command.h +++ b/command.h @@ -61,6 +61,8 @@ enum event_command /* Quits RetroArch. */ CMD_EVENT_QUIT, /* Reinitialize all drivers. */ + CMD_EVENT_REINIT_FROM_TOGGLE, + /* Reinitialize all drivers. */ CMD_EVENT_REINIT, /* Toggles cheevos hardcore mode. */ CMD_EVENT_CHEEVOS_HARDCORE_MODE_TOGGLE, diff --git a/configuration.c b/configuration.c index db278743c7..6138b56aab 100644 --- a/configuration.c +++ b/configuration.c @@ -1578,11 +1578,6 @@ static void config_set_defaults(void) #endif settings->floats.video_scale = scale; - if (retroarch_is_forced_fullscreen()) - { - configuration_set_bool(settings, settings->bools.video_fullscreen, true); - } - if (g_defaults.settings.video_threaded_enable != video_threaded) video_driver_set_threaded(g_defaults.settings.video_threaded_enable); @@ -2377,9 +2372,6 @@ static bool config_load_file(const char *path, bool set_defaults, *bool_settings[i].ptr = tmp; } - if (!retroarch_is_forced_fullscreen()) - CONFIG_GET_BOOL_BASE(conf, settings, bools.video_fullscreen, "video_fullscreen"); - #ifdef HAVE_NETWORKGAMEPAD for (i = 0; i < MAX_USERS; i++) { diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 0302d7008b..da87988eb9 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -955,7 +955,7 @@ static bool video_driver_init_internal(bool *video_is_threaded) video_driver_set_aspect_ratio_value( aspectratio_lut[settings->uints.video_aspect_ratio_idx].value); - if (settings->bools.video_fullscreen) + if (settings->bools.video_fullscreen|| retroarch_is_forced_fullscreen()) { width = settings->uints.video_fullscreen_x; height = settings->uints.video_fullscreen_y; @@ -999,7 +999,7 @@ static bool video_driver_init_internal(bool *video_is_threaded) video.width = width; video.height = height; - video.fullscreen = settings->bools.video_fullscreen; + video.fullscreen = settings->bools.video_fullscreen || retroarch_is_forced_fullscreen(); video.vsync = settings->bools.video_vsync && !rarch_ctl(RARCH_CTL_IS_NONBLOCK_FORCED, NULL); video.force_aspect = settings->bools.video_force_aspect; video.font_enable = settings->bools.video_font_enable; @@ -2515,7 +2515,7 @@ void video_driver_build_info(video_frame_info_t *video_info) video_info->post_filter_record = settings->bools.video_post_filter_record; video_info->max_swapchain_images = settings->uints.video_max_swapchain_images; video_info->windowed_fullscreen = settings->bools.video_windowed_fullscreen; - video_info->fullscreen = settings->bools.video_fullscreen; + video_info->fullscreen = settings->bools.video_fullscreen || retroarch_is_forced_fullscreen(); video_info->monitor_index = settings->uints.video_monitor_index; video_info->shared_context = settings->bools.video_shared_context; diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index e7ad35b7cc..72f5c9c5bc 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -1670,7 +1670,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_FORCE_SRGB_DISABLE, MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_FRAME_DELAY, "Frame Delay") MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_FULLSCREEN, - "Use Fullscreen Mode") + "Start in Fullscreen Mode") MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_GAMMA, "Video Gamma") MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_GPU_RECORD, @@ -2618,7 +2618,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_FULLSCREEN, - "Start in fullscreen. Can be changed at runtime." + "Start in fullscreen. Can be changed at runtime. Can be overriden by a command line switch" ) MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_WINDOWED_FULLSCREEN, diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 265b6004fb..6929da58f8 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -3354,7 +3354,7 @@ static bool setting_append_list( general_write_handler, general_read_handler, SD_FLAG_CMD_APPLY_AUTO); - menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_REINIT); + menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_REINIT_FROM_TOGGLE); settings_data_list_current_add_flags(list, list_info, SD_FLAG_LAKKA_ADVANCED); } if (video_driver_has_windowed()) diff --git a/retroarch.c b/retroarch.c index 06227d1381..fbb5273894 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1106,8 +1106,6 @@ static bool retroarch_init_state(void) video_driver_set_active(); audio_driver_set_active(); - rarch_force_fullscreen = false; - return true; } @@ -1447,7 +1445,6 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) rarch_is_inited = false; rarch_error_on_init = false; rarch_block_config_read = false; - rarch_force_fullscreen = false; retroarch_msg_queue_deinit(); driver_uninit(DRIVERS_CMD_ALL); @@ -1926,6 +1923,11 @@ bool retroarch_is_forced_fullscreen(void) return rarch_force_fullscreen; } +void retroarch_unset_forced_fullscreen(void) +{ + rarch_force_fullscreen = false; +} + bool retroarch_override_setting_is_set(enum rarch_override_setting enum_idx, void *data) { switch (enum_idx) diff --git a/retroarch.h b/retroarch.h index 123f3c6bcb..05614aba92 100644 --- a/retroarch.h +++ b/retroarch.h @@ -289,6 +289,8 @@ bool retroarch_validate_game_options(char *s, size_t len, bool mkdir); bool retroarch_is_forced_fullscreen(void); +void retroarch_unset_forced_fullscreen(void); + void retroarch_set_current_core_type(enum rarch_core_type type, bool explicitly_set); /**