From 12d8720b9be46674c23d4e1cc45159695ed06cf4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 4 May 2021 00:29:59 +1000 Subject: WM: disable idle event handling timer when simulating events --- source/blender/windowmanager/intern/wm_window.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source/blender/windowmanager/intern/wm_window.c') diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index b90352b9e62..cdd5ea12df8 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -1563,8 +1563,11 @@ void wm_window_process_events(const bContext *C) has_event |= wm_xr_events_handle(CTX_wm_manager(C)); #endif - /* no event, we sleep 5 milliseconds */ - if (has_event == false) { + /* When there is no event, sleep 5 milliseconds not to use too much CPU when idle. + * + * Skip sleeping when simulating events so tests don't idle unnecessarily as simulated + * events are typically generated from a timer that runs in the main loop. */ + if ((has_event == false) && !(G.f & G_FLAG_EVENT_SIMULATE)) { PIL_sleep_ms(5); } } -- cgit v1.2.3