mirror of
https://github.com/libretro/RetroArch
synced 2025-02-20 15:40:44 +00:00
Move is_menu out of runloop struct and create get/set functions in menu_driver.c
and make the underlying variable static to make it thread-safe
This commit is contained in:
parent
3a7263020a
commit
375c49b6c8
@ -1030,7 +1030,7 @@ bool event_command(enum event_command cmd)
|
||||
global->pending.windowed_scale = 0;
|
||||
break;
|
||||
case EVENT_CMD_MENU_TOGGLE:
|
||||
if (runloop->is_menu)
|
||||
if (menu_driver_alive())
|
||||
rarch_main_set_state(RARCH_ACTION_STATE_MENU_RUNNING_FINISHED);
|
||||
else
|
||||
rarch_main_set_state(RARCH_ACTION_STATE_MENU_RUNNING);
|
||||
@ -1094,7 +1094,7 @@ bool event_command(enum event_command cmd)
|
||||
#ifdef HAVE_MENU
|
||||
menu_display_fb_set_dirty();
|
||||
|
||||
if (runloop->is_menu)
|
||||
if (menu_driver_alive())
|
||||
event_command(EVENT_CMD_VIDEO_SET_BLOCKING_STATE);
|
||||
#endif
|
||||
break;
|
||||
@ -1387,7 +1387,7 @@ bool event_command(enum event_command cmd)
|
||||
event_command(EVENT_CMD_PAUSE_CHECKS);
|
||||
break;
|
||||
case EVENT_CMD_MENU_PAUSE_LIBRETRO:
|
||||
if (runloop->is_menu)
|
||||
if (menu_driver_alive())
|
||||
{
|
||||
if (settings->menu.pause_libretro)
|
||||
event_command(EVENT_CMD_AUDIO_STOP);
|
||||
|
@ -1723,7 +1723,7 @@ static bool d3d_frame(void *data, const void *frame,
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
if (runloop->is_menu)
|
||||
if (menu_driver_alive())
|
||||
menu_driver_frame();
|
||||
|
||||
#ifdef _XBOX
|
||||
|
@ -1613,7 +1613,7 @@ static bool gl_frame(void *data, const void *frame,
|
||||
gl_set_prev_texture(gl, &gl->tex_info);
|
||||
|
||||
#if defined(HAVE_MENU)
|
||||
if (runloop->is_menu)
|
||||
if (menu_driver_alive())
|
||||
menu_driver_frame();
|
||||
|
||||
if (gl->menu_texture_enable)
|
||||
|
@ -504,7 +504,7 @@ static bool sdl2_gfx_frame(void *data, const void *frame, unsigned width,
|
||||
SDL_RenderCopyEx(vid->renderer, vid->frame.tex, NULL, NULL, vid->rotation, NULL, SDL_FLIP_NONE);
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
if (runloop->is_menu)
|
||||
if (menu_driver_alive())
|
||||
menu_driver_frame();
|
||||
#endif
|
||||
|
||||
|
@ -190,7 +190,7 @@ static void ps3_joypad_poll(void)
|
||||
*state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_TRIANGLE) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_X) : 0;
|
||||
*state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_SQUARE) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_Y) : 0;
|
||||
|
||||
if (runloop->is_menu)
|
||||
if (menu_driver_alive())
|
||||
{
|
||||
int value = 0;
|
||||
if (cellSysutilGetSystemParamInt(CELL_SYSUTIL_SYSTEMPARAM_ID_ENTER_BUTTON_ASSIGN, &value) == 0)
|
||||
|
@ -337,7 +337,7 @@ static void glui_frame(void)
|
||||
glui = (glui_handle_t*)menu->userdata;
|
||||
|
||||
if (menu_needs_refresh()
|
||||
&& runloop->is_menu
|
||||
&& menu_driver_alive()
|
||||
&& !menu->msg_force
|
||||
&& !glui->box_message[0])
|
||||
return;
|
||||
|
@ -343,7 +343,7 @@ static void rgui_render(void)
|
||||
if (!menu)
|
||||
return;
|
||||
|
||||
if (menu_needs_refresh() && runloop->is_menu && !menu->msg_force)
|
||||
if (menu_needs_refresh() && menu_driver_alive() && !menu->msg_force)
|
||||
return;
|
||||
|
||||
if (runloop->is_idle)
|
||||
|
@ -143,7 +143,7 @@ static void rmenu_render(void)
|
||||
return;
|
||||
}
|
||||
|
||||
if (menu_needs_refresh() && runloop->is_menu
|
||||
if (menu_needs_refresh() && menu_driver_alive()
|
||||
&& !menu->msg_force)
|
||||
return;
|
||||
|
||||
|
@ -539,7 +539,7 @@ static void rmenu_xui_render(void)
|
||||
if (!menu)
|
||||
return;
|
||||
if (menu_needs_refresh() &&
|
||||
runloop->is_menu && !menu->msg_force)
|
||||
menu_driver_alive() && !menu->msg_force)
|
||||
return;
|
||||
|
||||
menu_display_fb_unset_dirty();
|
||||
|
@ -170,6 +170,7 @@ void *menu_init(const void *data)
|
||||
rarch_assert(menu->msg_queue = msg_queue_new(8));
|
||||
|
||||
menu_display_fb_set_dirty();
|
||||
menu_driver_set_alive();
|
||||
|
||||
return menu;
|
||||
error:
|
||||
@ -255,6 +256,8 @@ void menu_free(menu_handle_t *menu)
|
||||
if (global->core_info_current)
|
||||
free(global->core_info_current);
|
||||
|
||||
menu_driver_unset_alive();
|
||||
|
||||
free(menu);
|
||||
}
|
||||
|
||||
@ -299,7 +302,7 @@ int menu_iterate(retro_input_t input,
|
||||
|
||||
ret = menu_entry_iterate(action);
|
||||
|
||||
if (runloop->is_menu && !runloop->is_idle)
|
||||
if (menu_driver_alive() && !runloop->is_idle)
|
||||
menu_display_fb();
|
||||
|
||||
menu_driver_set_texture();
|
||||
|
@ -22,6 +22,8 @@
|
||||
#include "../driver.h"
|
||||
#include "../general.h"
|
||||
|
||||
static bool menu_alive = false;
|
||||
|
||||
static const menu_ctx_driver_t *menu_ctx_drivers[] = {
|
||||
#if defined(HAVE_RMENU)
|
||||
&menu_ctx_rmenu,
|
||||
@ -360,3 +362,18 @@ void menu_driver_navigation_ascend_alphabet(size_t *ptr_out)
|
||||
if (driver->navigation_ascend_alphabet)
|
||||
driver->navigation_ascend_alphabet(ptr_out);
|
||||
}
|
||||
|
||||
bool menu_driver_alive(void)
|
||||
{
|
||||
return menu_alive;
|
||||
}
|
||||
|
||||
void menu_driver_set_alive(void)
|
||||
{
|
||||
menu_alive = true;
|
||||
}
|
||||
|
||||
void menu_driver_unset_alive(void)
|
||||
{
|
||||
menu_alive = false;
|
||||
}
|
||||
|
@ -344,6 +344,12 @@ void menu_driver_list_set_selection(file_list_t *list);
|
||||
|
||||
void menu_driver_context_destroy(void);
|
||||
|
||||
bool menu_driver_alive(void);
|
||||
|
||||
void menu_driver_set_alive(void);
|
||||
|
||||
void menu_driver_unset_alive(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -1274,7 +1274,7 @@ void rarch_main_set_state(unsigned cmd)
|
||||
}
|
||||
|
||||
menu_set_refresh();
|
||||
runloop->is_menu = true;
|
||||
menu_driver_set_alive();
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
@ -1292,8 +1292,7 @@ void rarch_main_set_state(unsigned cmd)
|
||||
menu_setting_apply_deferred();
|
||||
|
||||
menu_driver_toggle(false);
|
||||
|
||||
runloop->is_menu = false;
|
||||
menu_driver_unset_alive();
|
||||
|
||||
driver_set_nonblock_state(driver->nonblock_state);
|
||||
|
||||
|
@ -418,10 +418,9 @@ static void check_shader_dir(bool pressed_next, bool pressed_prev)
|
||||
#ifdef HAVE_MENU
|
||||
static void do_state_check_menu_toggle(void)
|
||||
{
|
||||
runloop_t *runloop = rarch_main_get_ptr();
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
if (runloop->is_menu)
|
||||
if (menu_driver_alive())
|
||||
{
|
||||
if (global->main_is_init && !global->libretro_dummy)
|
||||
rarch_main_set_state(RARCH_ACTION_STATE_MENU_RUNNING_FINISHED);
|
||||
@ -450,7 +449,7 @@ static int do_pre_state_checks(event_cmd_state_t *cmd)
|
||||
if (cmd->overlay_next_pressed)
|
||||
event_command(EVENT_CMD_OVERLAY_NEXT);
|
||||
|
||||
if (!runloop->is_paused || runloop->is_menu)
|
||||
if (!runloop->is_paused || menu_driver_alive())
|
||||
{
|
||||
if (cmd->fullscreen_toggle)
|
||||
event_command(EVENT_CMD_FULLSCREEN_TOGGLE);
|
||||
@ -1109,7 +1108,7 @@ int rarch_main_iterate(void)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
if (runloop->is_menu)
|
||||
if (menu_driver_alive())
|
||||
{
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
if (menu)
|
||||
|
Loading…
x
Reference in New Issue
Block a user