Cleanup: use boolean for has_event variable & return value

This commit is contained in:
Campbell Barton 2021-05-04 00:14:05 +10:00
parent efe9928545
commit 3e4863376e
6 changed files with 20 additions and 20 deletions

View File

@ -276,7 +276,7 @@ extern int GHOST_GetFullScreen(GHOST_SystemHandle systemhandle);
* wait (block) until the next event before returning.
* \return Indication of the presence of events.
*/
extern int GHOST_ProcessEvents(GHOST_SystemHandle systemhandle, int waitForEvent);
extern bool GHOST_ProcessEvents(GHOST_SystemHandle systemhandle, bool waitForEvent);
/**
* Retrieves events from the queue and send them to the event consumers.

View File

@ -248,11 +248,11 @@ int GHOST_GetFullScreen(GHOST_SystemHandle systemhandle)
return (int)system->getFullScreen();
}
int GHOST_ProcessEvents(GHOST_SystemHandle systemhandle, int waitForEvent)
bool GHOST_ProcessEvents(GHOST_SystemHandle systemhandle, bool waitForEvent)
{
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
return (int)system->processEvents(waitForEvent ? true : false);
return system->processEvents(waitForEvent);
}
void GHOST_DispatchEvents(GHOST_SystemHandle systemhandle)

View File

@ -477,7 +477,7 @@ int main(int argc, char **argv)
/* Enter main loop */
while (!sExitRequested) {
if (!GHOST_ProcessEvents(shSystem, 0)) {
if (!GHOST_ProcessEvents(shSystem, false)) {
#ifdef WIN32
/* If there were no events, be nice to other applications */
Sleep(10);

View File

@ -926,7 +926,7 @@ void multitestapp_exit(MultiTestApp *app)
void multitestapp_run(MultiTestApp *app)
{
while (!app->exit) {
GHOST_ProcessEvents(app->sys, 1);
GHOST_ProcessEvents(app->sys, true);
GHOST_DispatchEvents(app->sys);
}
}

View File

@ -441,7 +441,7 @@ static void build_pict_list_ex(
*/
while (IMB_ispic(filepath) && totframes) {
bool hasevent;
bool has_event;
size_t size;
int file;
@ -522,7 +522,7 @@ static void build_pict_list_ex(
BLI_path_sequence_encode(
filepath, fp_decoded.head, fp_decoded.tail, fp_decoded.digits, fp_framenr);
while ((hasevent = GHOST_ProcessEvents(g_WS.ghost_system, 0))) {
while ((has_event = GHOST_ProcessEvents(g_WS.ghost_system, false))) {
GHOST_DispatchEvents(g_WS.ghost_system);
if (ps->loading == false) {
return;
@ -1389,7 +1389,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
#endif
while (ps.picture) {
int hasevent;
bool has_event;
#ifndef USE_IMB_CACHE
if (ibuf != NULL && ibuf->ftype == IMB_FTYPE_NONE) {
IMB_freeImBuf(ibuf);
@ -1474,14 +1474,14 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
ps.next_frame = ps.direction;
while ((hasevent = GHOST_ProcessEvents(g_WS.ghost_system, 0))) {
while ((has_event = GHOST_ProcessEvents(g_WS.ghost_system, false))) {
GHOST_DispatchEvents(g_WS.ghost_system);
}
if (ps.go == false) {
break;
}
change_frame(&ps);
if (!hasevent) {
if (!has_event) {
PIL_sleep_ms(1);
}
if (ps.wait2) {

View File

@ -133,7 +133,7 @@ static struct WMInitStruct {
* \{ */
static void wm_window_set_drawable(wmWindowManager *wm, wmWindow *win, bool activate);
static int wm_window_timer(const bContext *C);
static bool wm_window_timer(const bContext *C);
/* XXX this one should correctly check for apple top header...
* done for Cocoa : returns window contents (and not frame) max size*/
@ -1498,12 +1498,12 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
* Timer handlers should check for delta to decide if they just update, or follow real time.
* Timer handlers can also set duration to match frames passed
*/
static int wm_window_timer(const bContext *C)
static bool wm_window_timer(const bContext *C)
{
Main *bmain = CTX_data_main(C);
wmWindowManager *wm = CTX_wm_manager(C);
double time = PIL_check_seconds_timer();
int retval = 0;
bool has_event = false;
/* Mutable in case the timer gets removed. */
LISTBASE_FOREACH_MUTABLE (wmTimer *, wt, &wm->timers) {
@ -1540,31 +1540,31 @@ static int wm_window_timer(const bContext *C)
event.customdata = wt;
wm_event_add(win, &event);
retval = 1;
has_event = true;
}
}
}
return retval;
return has_event;
}
void wm_window_process_events(const bContext *C)
{
BLI_assert(BLI_thread_is_main());
int hasevent = GHOST_ProcessEvents(g_system, 0); /* 0 is no wait */
bool has_event = GHOST_ProcessEvents(g_system, false); /* `false` is no wait. */
if (hasevent) {
if (has_event) {
GHOST_DispatchEvents(g_system);
}
hasevent |= wm_window_timer(C);
has_event |= wm_window_timer(C);
#ifdef WITH_XR_OPENXR
/* XR events don't use the regular window queues. So here we don't only trigger
* processing/dispatching but also handling. */
hasevent |= wm_xr_events_handle(CTX_wm_manager(C));
has_event |= wm_xr_events_handle(CTX_wm_manager(C));
#endif
/* no event, we sleep 5 milliseconds */
if (hasevent == 0) {
if (has_event == false) {
PIL_sleep_ms(5);
}
}