Don't render menu if unfocused - reimplement this

This commit is contained in:
twinaphex 2015-11-28 03:03:26 +01:00
parent a3c34a7813
commit ce7ec0681b
9 changed files with 26 additions and 21 deletions

View File

@ -733,16 +733,17 @@ static void android_app_entry(void *data)
#ifndef HAVE_MAIN
do
{
bool sleeping = false;
unsigned sleep_ms = 0;
ret = rarch_main_iterate(&sleep_ms);
bool sleeping = false;
unsigned unfocused = 0;
unsigned sleep_ms = 0;
ret = rarch_main_iterate(&unfocused, &sleep_ms);
if (ret == 1 && sleep_ms > 0)
{
sleeping = true;
retro_sleep(sleep_ms);
}
rarch_main_data_iterate(sleeping);
rarch_main_data_iterate(unfocused, sleeping);
}while (ret != -1);
main_exit(data);

View File

@ -325,15 +325,16 @@ int rarch_main(int argc, char *argv[], void *data)
do
{
bool sleeping = false;
unsigned sleep_ms = 0;
ret = rarch_main_iterate(&sleep_ms);
unsigned unfocused = 0;
unsigned sleep_ms = 0;
ret = rarch_main_iterate(&unfocused, &sleep_ms);
if (ret == 1 && sleep_ms > 0)
{
sleeping = true;
retro_sleep(sleep_ms);
}
rarch_main_data_iterate(sleeping);
rarch_main_data_iterate(unfocused, sleeping);
}while(ret != -1);
main_exit(args);

View File

@ -78,7 +78,7 @@ static int action_select_default(const char *path, const char *label, unsigned t
if (action != MENU_ACTION_NOOP)
ret = menu_entry_action(&entry, idx, action);
rarch_main_data_iterate(false);
rarch_main_data_iterate(false, false);
return ret;
}

View File

@ -828,7 +828,7 @@ static INLINE int rarch_main_iterate_time_to_exit(event_cmd_state_t *cmd)
* Returns: 0 on success, 1 if we have to wait until button input in order
* to wake up the loop, -1 if we forcibly quit out of the RetroArch iteration loop.
**/
int rarch_main_iterate(unsigned *sleep_ms)
int rarch_main_iterate(unsigned *unfocused, unsigned *sleep_ms)
{
int ret;
unsigned i;
@ -933,7 +933,8 @@ int rarch_main_iterate(unsigned *sleep_ms)
if (!rarch_main_ctl(RARCH_MAIN_CTL_CHECK_IDLE_STATE, &cmd))
{
*sleep_ms = 10;
*unfocused = 1;
*sleep_ms = 10;
return 1;
}

View File

@ -339,7 +339,7 @@ global_t *global_get_ptr(void);
* Returns: 0 on successful run, 1 if we have to wait until button input in order
* to wake up the loop, -1 if we forcibly quit out of the RetroArch iteration loop.
**/
int rarch_main_iterate(unsigned *sleep_ms);
int rarch_main_iterate(unsigned *unfocused, unsigned *sleep_ms);
void rarch_main_msg_queue_push(const char *msg, unsigned prio,
unsigned duration, bool flush);

View File

@ -31,10 +31,10 @@ void rarch_main_data_deinit(void)
rarch_task_deinit();
}
void rarch_main_data_iterate(bool sleeping)
void rarch_main_data_iterate(bool unfocused, bool sleeping)
{
#ifdef HAVE_MENU
if (!sleeping)
if (unfocused)
menu_iterate_render();
#endif

View File

@ -27,7 +27,7 @@ typedef int (*transfer_cb_t)(void *data, size_t len);
void rarch_main_data_clear_state(void);
void rarch_main_data_iterate(bool sleeping);
void rarch_main_data_iterate(bool unfocused, bool sleeping);
void rarch_main_data_deinit(void);

View File

@ -226,16 +226,17 @@ static void poll_iteration(void)
int ret = 0;
while (ret != -1)
{
bool sleeping = false;
unsigned sleep_ms = 0;
bool sleeping = false;
unsigned unfocused = 0;
unsigned sleep_ms = 0;
poll_iteration();
ret = rarch_main_iterate(&sleep_ms);
ret = rarch_main_iterate(&unfocused, &sleep_ms);
if (ret == 1 && sleep_ms > 0)
{
sleeping = true;
sleeping = true;
retro_sleep(sleep_ms);
}
rarch_main_data_iterate(sleeping);
rarch_main_data_iterate(unfocused, sleeping);
while(CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.002, FALSE) == kCFRunLoopRunHandledSource);
}

View File

@ -72,15 +72,16 @@ static void rarch_draw_observer(CFRunLoopObserverRef observer,
{
bool is_idle;
bool sleeping = false;
unsigned unfocused = 0;
unsigned sleep_ms = 0;
int ret = rarch_main_iterate(&sleep_ms);
int ret = rarch_main_iterate(&unfocused, &sleep_ms);
if (ret == 1 && !ui_companion_is_on_foreground() && sleep_ms > 0)
{
sleeping = true;
retro_sleep(sleep_ms);
}
rarch_main_data_iterate(sleeping);
rarch_main_data_iterate(unfocused, sleeping);
if (ret == -1)
{