Neaten up main_loop()
This commit is contained in:
parent
5630c0e434
commit
532d51c411
@ -735,22 +735,15 @@ process_pending_resizes(double now) {
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
main_loop(ChildMonitor *self, PyObject *a UNUSED) {
|
||||
#define main_loop_doc "The main thread loop"
|
||||
bool has_open_windows = true;
|
||||
|
||||
while (has_open_windows) {
|
||||
double now = monotonic();
|
||||
if (global_state.has_pending_resizes) process_pending_resizes(now);
|
||||
render(now);
|
||||
wait_for_events();
|
||||
parse_input(self);
|
||||
if (global_state.close_all_windows) {
|
||||
static inline void
|
||||
close_all_windows() {
|
||||
for (size_t w = 0; w < global_state.num_os_windows; w++) mark_os_window_for_close(&global_state.os_windows[w], true);
|
||||
global_state.close_all_windows = false;
|
||||
}
|
||||
has_open_windows = false;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
process_pending_closes(ChildMonitor *self) {
|
||||
bool has_open_windows = false;
|
||||
for (size_t w = global_state.num_os_windows; w > 0; w--) {
|
||||
OSWindow *os_window = global_state.os_windows + w - 1;
|
||||
if (should_os_window_close(os_window)) {
|
||||
@ -763,6 +756,22 @@ main_loop(ChildMonitor *self, PyObject *a UNUSED) {
|
||||
remove_os_window(os_window->id);
|
||||
} else has_open_windows = true;
|
||||
}
|
||||
return has_open_windows;
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
main_loop(ChildMonitor *self, PyObject *a UNUSED) {
|
||||
#define main_loop_doc "The main thread loop"
|
||||
bool has_open_windows = true;
|
||||
|
||||
while (has_open_windows) {
|
||||
double now = monotonic();
|
||||
if (global_state.has_pending_resizes) process_pending_resizes(now);
|
||||
render(now);
|
||||
wait_for_events();
|
||||
parse_input(self);
|
||||
if (global_state.close_all_windows) close_all_windows();
|
||||
has_open_windows = process_pending_closes(self);
|
||||
}
|
||||
if (PyErr_Occurred()) return NULL;
|
||||
Py_RETURN_NONE;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user