From 51c227fa256227519b755ef4524871ff2c0ddb88 Mon Sep 17 00:00:00 2001 From: Sangjin Lee Date: Mon, 17 Apr 2017 14:47:11 +0900 Subject: [PATCH] wayland_egl: fix handle to the source of wayland Change-Id: I7c15966a2874d6fc7b3b3e88bad6a6a79ac41062 --- src/tpl_wayland_egl_thread.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index d85a346..e99d650 100644 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -1,8 +1,10 @@ +#include #include #include #include #include +#include typedef struct _twe_thread_context twe_thread_context; typedef struct _twe_thread twe_thread; @@ -83,13 +85,14 @@ _twe_thread_wl_disp_prepare(GSource *source, gint *time) { twe_wl_disp_source *wl_source = (twe_wl_disp_source *)source; - while (wl_display_prepare_read(wl_source->disp) != 0) { - wl_display_dispatch_pending(wl_source->disp); + while (wl_display_prepare_read_queue(wl_source->disp, wl_source->ev_queue) != 0) { + wl_display_dispatch_queue_pending(wl_source->disp, wl_source->ev_queue); } wl_display_flush(wl_source->disp); + *time = -1; - return TRUE; + return FALSE; } static gboolean @@ -97,12 +100,14 @@ _twe_thread_wl_disp_check(GSource *source) { twe_wl_disp_source *wl_source = (twe_wl_disp_source *)source; - if (wl_source->gfd.revents) + if (wl_source->gfd.revents) { wl_display_read_events(wl_source->disp); - else + return TRUE; + } else { wl_display_cancel_read(wl_source->disp); + } - return TRUE; + return FALSE; } static gboolean @@ -144,11 +149,12 @@ twe_thread_add_wl_display(twe_thread* thread, source->disp = display; source->ev_queue = ev_queue; source->gfd.fd = wl_display_get_fd(display); - source->gfd.events = G_IO_IN | G_IO_OUT | G_IO_ERR; + source->gfd.events = G_IO_IN | G_IO_ERR; source->gfd.revents = 0; g_source_add_poll(&source->gsource, &source->gfd); g_source_attach(&source->gsource, g_main_loop_get_context(ctx->twe_loop)); + g_source_unref(&source->gsource); } void -- 2.7.4