Demos (master): egl/eglut: Avoid busy looping.
Chia-I Wu
olv at kemper.freedesktop.org
Thu Dec 2 08:54:21 UTC 2010
Module: Demos
Branch: master
Commit: 1222800fd2037d5e1b3c781bb70443dbb9743095
URL: http://cgit.freedesktop.org/mesa/demos/commit/?id=1222800fd2037d5e1b3c781bb70443dbb9743095
Author: Chia-I Wu <olvaffe at gmail.com>
Date: Thu Dec 2 16:38:09 2010 +0800
egl/eglut: Avoid busy looping.
next_event should block unless there is an idle callback.
---
src/egl/eglut/eglut_x11.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/egl/eglut/eglut_x11.c b/src/egl/eglut/eglut_x11.c
index 78a7b86..af3eb2c 100644
--- a/src/egl/eglut/eglut_x11.c
+++ b/src/egl/eglut/eglut_x11.c
@@ -183,11 +183,18 @@ next_event(struct eglut_window *win)
XEvent event;
if (!XPending(_eglut->native_dpy)) {
- if (_eglut->idle_cb)
+ /* there is an idle callback */
+ if (_eglut->idle_cb) {
_eglut->idle_cb();
- return;
+ return;
+ }
+
+ /* the app requests re-display */
+ if (_eglut->redisplay)
+ return;
}
+ /* block for next event */
XNextEvent(_eglut->native_dpy, &event);
switch (event.type) {
More information about the mesa-commit
mailing list