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

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

View File

@ -325,15 +325,16 @@ int rarch_main(int argc, char *argv[], void *data)
do do
{ {
bool sleeping = false; bool sleeping = false;
unsigned unfocused = 0;
unsigned sleep_ms = 0; unsigned sleep_ms = 0;
ret = rarch_main_iterate(&sleep_ms); ret = rarch_main_iterate(&unfocused, &sleep_ms);
if (ret == 1 && sleep_ms > 0) if (ret == 1 && sleep_ms > 0)
{ {
sleeping = true; sleeping = true;
retro_sleep(sleep_ms); retro_sleep(sleep_ms);
} }
rarch_main_data_iterate(sleeping); rarch_main_data_iterate(unfocused, sleeping);
}while(ret != -1); }while(ret != -1);
main_exit(args); 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) if (action != MENU_ACTION_NOOP)
ret = menu_entry_action(&entry, idx, action); ret = menu_entry_action(&entry, idx, action);
rarch_main_data_iterate(false); rarch_main_data_iterate(false, false);
return ret; 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 * 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. * 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; int ret;
unsigned i; unsigned i;
@ -933,6 +933,7 @@ int rarch_main_iterate(unsigned *sleep_ms)
if (!rarch_main_ctl(RARCH_MAIN_CTL_CHECK_IDLE_STATE, &cmd)) if (!rarch_main_ctl(RARCH_MAIN_CTL_CHECK_IDLE_STATE, &cmd))
{ {
*unfocused = 1;
*sleep_ms = 10; *sleep_ms = 10;
return 1; 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 * 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. * 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, void rarch_main_msg_queue_push(const char *msg, unsigned prio,
unsigned duration, bool flush); unsigned duration, bool flush);

View File

@ -31,10 +31,10 @@ void rarch_main_data_deinit(void)
rarch_task_deinit(); rarch_task_deinit();
} }
void rarch_main_data_iterate(bool sleeping) void rarch_main_data_iterate(bool unfocused, bool sleeping)
{ {
#ifdef HAVE_MENU #ifdef HAVE_MENU
if (!sleeping) if (unfocused)
menu_iterate_render(); menu_iterate_render();
#endif #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_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); void rarch_main_data_deinit(void);

View File

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

View File

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