diff options
author | Ilia Mirkin <imirkin@alum.mit.edu> | 2018-02-06 20:43:02 -0500 |
---|---|---|
committer | Ilia Mirkin <imirkin@alum.mit.edu> | 2018-02-06 21:52:42 -0500 |
commit | c2d4ba86de1bebca536ef03525b067a42106f06e (patch) | |
tree | cb240ef3f40a1b9bbc3ecf3b924e3b262e4f89f0 /drm-legacy.c | |
parent | 0d8de4ce3a03f36af1817f9b0586d132ad2c5d2e (diff) | |
download | kmscube-c2d4ba86de1bebca536ef03525b067a42106f06e.tar.gz |
drm-legacy: fix poll for flip event, actually exit on user input
The select fds have to be reinitialized before each call to select.
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Rob Clark <robdclark@gmail.com>
Diffstat (limited to 'drm-legacy.c')
-rw-r--r-- | drm-legacy.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/drm-legacy.c b/drm-legacy.c index a0b419a..fd98a38 100644 --- a/drm-legacy.c +++ b/drm-legacy.c @@ -53,10 +53,6 @@ static int legacy_run(const struct gbm *gbm, const struct egl *egl) uint32_t i = 0; int ret; - FD_ZERO(&fds); - FD_SET(0, &fds); - FD_SET(drm.fd, &fds); - eglSwapBuffers(egl->display, egl->surface); bo = gbm_surface_lock_front_buffer(gbm->surface); fb = drm_fb_get_from_bo(bo); @@ -100,6 +96,10 @@ static int legacy_run(const struct gbm *gbm, const struct egl *egl) } while (waiting_for_flip) { + FD_ZERO(&fds); + FD_SET(0, &fds); + FD_SET(drm.fd, &fds); + ret = select(drm.fd + 1, &fds, NULL, NULL, NULL); if (ret < 0) { printf("select err: %s\n", strerror(errno)); @@ -109,7 +109,7 @@ static int legacy_run(const struct gbm *gbm, const struct egl *egl) return -1; } else if (FD_ISSET(0, &fds)) { printf("user interrupted!\n"); - break; + return 0; } drmHandleEvent(drm.fd, &evctx); } |