(UI Companion) simplify boolean code by replacing it with flags
This commit is contained in:
parent
c39770e23c
commit
9bbe6992e2
|
@ -2511,7 +2511,7 @@ bool command_event(enum event_command cmd, void *data)
|
||||||
#ifdef HAVE_MENU
|
#ifdef HAVE_MENU
|
||||||
retroarch_menu_running_finished(false);
|
retroarch_menu_running_finished(false);
|
||||||
#endif
|
#endif
|
||||||
if (uico_st->is_on_foreground)
|
if (uico_st->flags & UICO_ST_FLAG_IS_ON_FOREGROUND)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_QT
|
#ifdef HAVE_QT
|
||||||
bool desktop_menu_enable = settings->bools.desktop_menu_enable;
|
bool desktop_menu_enable = settings->bools.desktop_menu_enable;
|
||||||
|
|
10
runloop.c
10
runloop.c
|
@ -6847,9 +6847,9 @@ static enum runloop_state_enum runloop_check_state(
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (pause_nonactive)
|
if (pause_nonactive)
|
||||||
focused = is_focused && !uico_st->is_on_foreground;
|
focused = is_focused && (!(uico_st->flags & UICO_ST_FLAG_IS_ON_FOREGROUND));
|
||||||
else
|
else
|
||||||
focused = !uico_st->is_on_foreground;
|
focused = (!(uico_st->flags & UICO_ST_FLAG_IS_ON_FOREGROUND));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action == old_action)
|
if (action == old_action)
|
||||||
|
@ -6975,7 +6975,7 @@ static enum runloop_state_enum runloop_check_state(
|
||||||
menu->userdata,
|
menu->userdata,
|
||||||
menu->menu_state_msg);
|
menu->menu_state_msg);
|
||||||
|
|
||||||
if (uico_st->is_on_foreground)
|
if (uico_st->flags & UICO_ST_FLAG_IS_ON_FOREGROUND)
|
||||||
{
|
{
|
||||||
if ( uico_st->drv
|
if ( uico_st->drv
|
||||||
&& uico_st->drv->render_messagebox)
|
&& uico_st->drv->render_messagebox)
|
||||||
|
@ -7774,7 +7774,7 @@ int runloop_iterate(void)
|
||||||
netplay_driver_ctl(RARCH_NETPLAY_CTL_PAUSE, NULL);
|
netplay_driver_ctl(RARCH_NETPLAY_CTL_PAUSE, NULL);
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_COCOATOUCH)
|
#if defined(HAVE_COCOATOUCH)
|
||||||
if (!uico_st->is_on_foreground)
|
if (!(uico_st->flags & UICO_ST_FLAG_IS_ON_FOREGROUND))
|
||||||
#endif
|
#endif
|
||||||
retro_sleep(10);
|
retro_sleep(10);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -8102,7 +8102,7 @@ end:
|
||||||
if (sleep_ms > 0)
|
if (sleep_ms > 0)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_COCOATOUCH)
|
#if defined(HAVE_COCOATOUCH)
|
||||||
if (!uico_state_get_ptr()->is_on_foreground)
|
if (!(uico_state_get_ptr()->flags & UICO_ST_FLAG_IS_ON_FOREGROUND))
|
||||||
#endif
|
#endif
|
||||||
retro_sleep(sleep_ms);
|
retro_sleep(sleep_ms);
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,29 +71,30 @@ void ui_companion_set_foreground(unsigned enable)
|
||||||
{
|
{
|
||||||
uico_driver_state_t *uico_st = &uico_driver_st;
|
uico_driver_state_t *uico_st = &uico_driver_st;
|
||||||
if (uico_st)
|
if (uico_st)
|
||||||
uico_st->is_on_foreground = enable;
|
{
|
||||||
|
if (enable)
|
||||||
|
uico_st->flags |= UICO_ST_FLAG_IS_ON_FOREGROUND;
|
||||||
|
else
|
||||||
|
uico_st->flags &= ~UICO_ST_FLAG_IS_ON_FOREGROUND;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ui_companion_is_on_foreground(void)
|
uint8_t ui_companion_get_flags(void)
|
||||||
{
|
{
|
||||||
uico_driver_state_t *uico_st = &uico_driver_st;
|
uico_driver_state_t *uico_st = &uico_driver_st;
|
||||||
if (!uico_st)
|
if (!uico_st)
|
||||||
return false;
|
return 0;
|
||||||
return uico_st->is_on_foreground;
|
return uico_st->flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_companion_event_command(enum event_command action)
|
void ui_companion_event_command(enum event_command action)
|
||||||
{
|
{
|
||||||
uico_driver_state_t *uico_st = &uico_driver_st;
|
uico_driver_state_t *uico_st = &uico_driver_st;
|
||||||
#ifdef HAVE_QT
|
|
||||||
bool qt_is_inited = uico_st->qt_is_inited;
|
|
||||||
#endif
|
|
||||||
const ui_companion_driver_t *ui = uico_st->drv;
|
const ui_companion_driver_t *ui = uico_st->drv;
|
||||||
|
|
||||||
if (ui && ui->event_command)
|
if (ui && ui->event_command)
|
||||||
ui->event_command(uico_st->data, action);
|
ui->event_command(uico_st->data, action);
|
||||||
#ifdef HAVE_QT
|
#ifdef HAVE_QT
|
||||||
if (ui_companion_qt.toggle && qt_is_inited)
|
if (ui_companion_qt.toggle && (uico_st->flags & UICO_ST_FLAG_QT_IS_INITED))
|
||||||
ui_companion_qt.event_command(uico_st->qt_data, action);
|
ui_companion_qt.event_command(uico_st->qt_data, action);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -101,9 +102,6 @@ void ui_companion_event_command(enum event_command action)
|
||||||
void ui_companion_driver_deinit(void)
|
void ui_companion_driver_deinit(void)
|
||||||
{
|
{
|
||||||
uico_driver_state_t *uico_st = &uico_driver_st;
|
uico_driver_state_t *uico_st = &uico_driver_st;
|
||||||
#ifdef HAVE_QT
|
|
||||||
bool qt_is_inited = uico_st->qt_is_inited;
|
|
||||||
#endif
|
|
||||||
const ui_companion_driver_t *ui = uico_st->drv;
|
const ui_companion_driver_t *ui = uico_st->drv;
|
||||||
|
|
||||||
if (!ui)
|
if (!ui)
|
||||||
|
@ -112,13 +110,13 @@ void ui_companion_driver_deinit(void)
|
||||||
ui->deinit(uico_st->data);
|
ui->deinit(uico_st->data);
|
||||||
|
|
||||||
#ifdef HAVE_QT
|
#ifdef HAVE_QT
|
||||||
if (qt_is_inited)
|
if (uico_st->flags & UICO_ST_FLAG_QT_IS_INITED)
|
||||||
{
|
{
|
||||||
ui_companion_qt.deinit(uico_st->qt_data);
|
ui_companion_qt.deinit(uico_st->qt_data);
|
||||||
uico_st->qt_data = NULL;
|
uico_st->qt_data = NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
uico_st->data = NULL;
|
uico_st->data = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_companion_driver_toggle(
|
void ui_companion_driver_toggle(
|
||||||
|
@ -133,13 +131,13 @@ void ui_companion_driver_toggle(
|
||||||
#ifdef HAVE_QT
|
#ifdef HAVE_QT
|
||||||
if (desktop_menu_enable)
|
if (desktop_menu_enable)
|
||||||
{
|
{
|
||||||
if ((ui_companion_toggle || force) && !uico_st->qt_is_inited)
|
if ((ui_companion_toggle || force) && (!(uico_st->flags & UICO_ST_FLAG_QT_IS_INITED)))
|
||||||
{
|
{
|
||||||
uico_st->qt_data = ui_companion_qt.init();
|
uico_st->qt_data = ui_companion_qt.init();
|
||||||
uico_st->qt_is_inited = true;
|
uico_st->flags |= UICO_ST_FLAG_QT_IS_INITED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ui_companion_qt.toggle && uico_st->qt_is_inited)
|
if (ui_companion_qt.toggle && (uico_st->flags & UICO_ST_FLAG_QT_IS_INITED))
|
||||||
ui_companion_qt.toggle(uico_st->qt_data, force);
|
ui_companion_qt.toggle(uico_st->qt_data, force);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -156,7 +154,7 @@ void ui_companion_driver_init_first(void)
|
||||||
if (desktop_menu_enable && ui_companion_toggle)
|
if (desktop_menu_enable && ui_companion_toggle)
|
||||||
{
|
{
|
||||||
uico_st->qt_data = ui_companion_qt.init();
|
uico_st->qt_data = ui_companion_qt.init();
|
||||||
uico_st->qt_is_inited = true;
|
uico_st->flags |= UICO_ST_FLAG_QT_IS_INITED;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
bool desktop_menu_enable = false;
|
bool desktop_menu_enable = false;
|
||||||
|
@ -181,20 +179,14 @@ void ui_companion_driver_notify_refresh(void)
|
||||||
{
|
{
|
||||||
uico_driver_state_t *uico_st = &uico_driver_st;
|
uico_driver_state_t *uico_st = &uico_driver_st;
|
||||||
const ui_companion_driver_t *ui = uico_st->drv;
|
const ui_companion_driver_t *ui = uico_st->drv;
|
||||||
#ifdef HAVE_QT
|
|
||||||
settings_t *settings = config_get_ptr();
|
|
||||||
bool desktop_menu_enable = settings->bools.desktop_menu_enable;
|
|
||||||
bool qt_is_inited = uico_st->qt_is_inited;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!ui)
|
if (!ui)
|
||||||
return;
|
return;
|
||||||
if (ui->notify_refresh)
|
if (ui->notify_refresh)
|
||||||
ui->notify_refresh(uico_st->data);
|
ui->notify_refresh(uico_st->data);
|
||||||
|
|
||||||
#ifdef HAVE_QT
|
#ifdef HAVE_QT
|
||||||
if (desktop_menu_enable)
|
if (config_get_ptr()->bools.desktop_menu_enable)
|
||||||
if (ui_companion_qt.notify_refresh && qt_is_inited)
|
if (ui_companion_qt.notify_refresh && (uico_st->flags & UICO_ST_FLAG_QT_IS_INITED))
|
||||||
ui_companion_qt.notify_refresh(uico_st->qt_data);
|
ui_companion_qt.notify_refresh(uico_st->qt_data);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -254,17 +246,11 @@ void ui_companion_driver_msg_queue_push(
|
||||||
ui->msg_queue_push(uico_st->data, msg, priority, duration, flush);
|
ui->msg_queue_push(uico_st->data, msg, priority, duration, flush);
|
||||||
|
|
||||||
#ifdef HAVE_QT
|
#ifdef HAVE_QT
|
||||||
{
|
if (config_get_ptr()->bools.desktop_menu_enable)
|
||||||
settings_t *settings = config_get_ptr();
|
if (ui_companion_qt.msg_queue_push && (uico_st->flags & UICO_ST_FLAG_QT_IS_INITED))
|
||||||
bool qt_is_inited = uico_st->qt_is_inited;
|
ui_companion_qt.msg_queue_push(
|
||||||
bool desktop_menu_enable = settings->bools.desktop_menu_enable;
|
uico_st->qt_data,
|
||||||
|
msg, priority, duration, flush);
|
||||||
if (desktop_menu_enable)
|
|
||||||
if (ui_companion_qt.msg_queue_push && qt_is_inited)
|
|
||||||
ui_companion_qt.msg_queue_push(
|
|
||||||
uico_st->qt_data,
|
|
||||||
msg, priority, duration, flush);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,13 +276,9 @@ void ui_companion_driver_log_msg(const char *msg)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_QT
|
#ifdef HAVE_QT
|
||||||
uico_driver_state_t *uico_st= &uico_driver_st;
|
uico_driver_state_t *uico_st= &uico_driver_st;
|
||||||
settings_t *settings = config_get_ptr();
|
bool window_is_active = uico_st->qt_data && (uico_st->flags & UICO_ST_FLAG_QT_IS_INITED)
|
||||||
bool qt_is_inited = uico_st->qt_is_inited;
|
|
||||||
bool desktop_menu_enable = settings->bools.desktop_menu_enable;
|
|
||||||
bool window_is_active = uico_st->qt_data && qt_is_inited
|
|
||||||
&& ui_companion_qt.is_active(uico_st->qt_data);
|
&& ui_companion_qt.is_active(uico_st->qt_data);
|
||||||
|
if (config_get_ptr()->bools.desktop_menu_enable)
|
||||||
if (desktop_menu_enable)
|
|
||||||
if (window_is_active)
|
if (window_is_active)
|
||||||
ui_companion_qt.log_msg(uico_st->qt_data, msg);
|
ui_companion_qt.log_msg(uico_st->qt_data, msg);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -133,15 +133,20 @@ typedef struct ui_companion_driver
|
||||||
const char *ident;
|
const char *ident;
|
||||||
} ui_companion_driver_t;
|
} ui_companion_driver_t;
|
||||||
|
|
||||||
|
enum uico_driver_state_flags
|
||||||
|
{
|
||||||
|
UICO_ST_FLAG_QT_IS_INITED = (1 << 0),
|
||||||
|
UICO_ST_FLAG_IS_ON_FOREGROUND = (1 << 1)
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
const ui_companion_driver_t *drv;
|
const ui_companion_driver_t *drv;
|
||||||
void *data;
|
void *data;
|
||||||
#ifdef HAVE_QT
|
#ifdef HAVE_QT
|
||||||
void *qt_data;
|
void *qt_data;
|
||||||
bool qt_is_inited;
|
|
||||||
#endif
|
#endif
|
||||||
bool is_on_foreground;
|
uint8_t flags;
|
||||||
} uico_driver_state_t;
|
} uico_driver_state_t;
|
||||||
|
|
||||||
extern ui_companion_driver_t ui_companion_cocoa;
|
extern ui_companion_driver_t ui_companion_cocoa;
|
||||||
|
@ -151,7 +156,7 @@ extern ui_companion_driver_t ui_companion_win32;
|
||||||
|
|
||||||
extern ui_msg_window_t ui_msg_window_win32;
|
extern ui_msg_window_t ui_msg_window_win32;
|
||||||
|
|
||||||
bool ui_companion_is_on_foreground(void);
|
uint8_t ui_companion_get_flags(void);
|
||||||
|
|
||||||
void ui_companion_set_foreground(unsigned enable);
|
void ui_companion_set_foreground(unsigned enable);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue