void gli_select(event_t *event, int block) { gli_curevent = event; gli_event_clearevent(event); gli_input_guess_focus(); if (block) { while (gli_curevent->type == evtype_None && !timeouts) gtk_main_iteration(); } else { while (gtk_events_pending() && !timeouts) gtk_main_iteration(); } if (gli_curevent->type == evtype_None && timeouts) { gli_event_store(evtype_Timer, NULL, 0, 0); timeouts = 0; } gli_curevent = NULL; }
void gli_select(event_t *event, int block) { MSG msg; gli_curevent = event; gli_event_clearevent(event); gli_input_guess_focus(); if (block) { while (gli_curevent->type == evtype_None && !timeouts) { int code = GetMessage(&msg, NULL, 0, 0); if (code < 0) exit(1); if (code > 0) { TranslateMessage(&msg); DispatchMessage(&msg); } } } else { while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) > 0 && !timeouts) { TranslateMessage(&msg); DispatchMessage(&msg); } } if (gli_curevent->type == evtype_None && timeouts) { gli_event_store(evtype_Timer, NULL, 0, 0); timeouts = 0; } gli_curevent = NULL; }
void glk_select(event_t *event) { int needrefresh = TRUE; curevent = event; gli_event_clearevent(curevent); gli_windows_update(); gli_windows_set_paging(FALSE); gli_input_guess_focus(); while (curevent->type == evtype_None) { int key; /* It would be nice to display a "hit any key to continue" message in all windows which require it. */ if (needrefresh) { gli_windows_place_cursor(); refresh(); needrefresh = FALSE; } key = getch(); #ifdef OPT_USE_SIGNALS if (just_killed) { /* Someone hit ctrl-C. This flag is set by the SIGINT / SIGHUP signal handlers.*/ gli_fast_exit(); } #endif /* OPT_USE_SIGNALS */ if (key != ERR) { /* An actual key has been hit */ gli_input_handle_key(key); needrefresh = TRUE; continue; } /* key == ERR; it's an idle event */ #ifdef OPT_USE_SIGNALS /* Check to see if the program has just resumed. This flag is set by the SIGCONT signal handler. */ if (just_resumed) { just_resumed = FALSE; gli_set_halfdelay(); needrefresh = TRUE; continue; } #ifdef OPT_WINCHANGED_SIGNAL /* Check to see if the screen-size has changed. The screen_size_changed flag is set by the SIGWINCH signal handler. */ if (screen_size_changed) { screen_size_changed = FALSE; gli_windows_size_change(); needrefresh = TRUE; continue; } #endif /* OPT_WINCHANGED_SIGNAL */ #endif /* OPT_USE_SIGNALS */ #ifdef OPT_TIMED_INPUT /* Check to see if we've passed next_time. */ if (timing_msec) { struct timeval tv; gettimeofday(&tv, NULL); if (tv.tv_sec > next_time.tv_sec || (tv.tv_sec == next_time.tv_sec && tv.tv_usec > next_time.tv_usec)) { next_time = tv; add_millisec_to_time(&next_time, timing_msec); gli_event_store(evtype_Timer, NULL, 0, 0); continue; } } #endif /* OPT_TIMED_INPUT */ } /* An event has occurred; glk_select() is over. */ gli_windows_trim_buffers(); curevent = NULL; }