From 00be95159d9665afca333cb88f71c1c4a0fbe24b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 19 Nov 2015 15:05:17 +0100 Subject: [PATCH] Create x11_event_queue_check --- gfx/common/x11_common.c | 10 ++++++++++ gfx/common/x11_common.h | 2 ++ gfx/drivers_context/glx_ctx.c | 7 +------ gfx/drivers_context/xegl_ctx.c | 10 +--------- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/gfx/common/x11_common.c b/gfx/common/x11_common.c index e8499f14fa..b797a61754 100644 --- a/gfx/common/x11_common.c +++ b/gfx/common/x11_common.c @@ -587,3 +587,13 @@ void x11_install_quit_atom(void) if (g_x11_quit_atom) XSetWMProtocols(g_x11_dpy, g_x11_win, &g_x11_quit_atom, 1); } + +static Bool x11_wait_notify(Display *d, XEvent *e, char *arg) +{ + return e->type == MapNotify && e->xmap.window == g_x11_win; +} + +void x11_event_queue_check(XEvent *event) +{ + XIfEvent(g_x11_dpy, event, x11_wait_notify, NULL); +} diff --git a/gfx/common/x11_common.h b/gfx/common/x11_common.h index 5b4ef825e4..3e42c413dd 100644 --- a/gfx/common/x11_common.h +++ b/gfx/common/x11_common.h @@ -91,5 +91,7 @@ void x11_colormap_destroy(void); void x11_install_quit_atom(void); +void x11_event_queue_check(XEvent *event); + #endif diff --git a/gfx/drivers_context/glx_ctx.c b/gfx/drivers_context/glx_ctx.c index ee8c350141..e715d3413e 100644 --- a/gfx/drivers_context/glx_ctx.c +++ b/gfx/drivers_context/glx_ctx.c @@ -54,11 +54,6 @@ static unsigned g_minor; static PFNGLXCREATECONTEXTATTRIBSARBPROC glx_create_context_attribs; -static Bool glx_wait_notify(Display *d, XEvent *e, char *arg) -{ - return (e->type == MapNotify) && (e->xmap.window == g_x11_win); -} - static int glx_nul_handler(Display *dpy, XErrorEvent *event) { (void)dpy; @@ -390,7 +385,7 @@ static bool gfx_ctx_glx_set_video_mode(void *data, x11_move_window(g_x11_dpy, g_x11_win, x_off, y_off, width, height); } - XIfEvent(g_x11_dpy, &event, glx_wait_notify, NULL); + x11_event_queue_check(&event); if (!glx->g_ctx) { diff --git a/gfx/drivers_context/xegl_ctx.c b/gfx/drivers_context/xegl_ctx.c index b49acce2cb..29202c804b 100644 --- a/gfx/drivers_context/xegl_ctx.c +++ b/gfx/drivers_context/xegl_ctx.c @@ -39,13 +39,6 @@ static enum gfx_ctx_api g_api; static unsigned g_major; static unsigned g_minor; -static Bool egl_wait_notify(Display *d, XEvent *e, char *arg) -{ - (void)d; - (void)e; - return e->type == MapNotify && e->xmap.window == g_x11_win; -} - static int egl_nul_handler(Display *dpy, XErrorEvent *event) { (void)dpy; @@ -400,8 +393,7 @@ static bool gfx_ctx_xegl_set_video_mode(void *data, x11_move_window(g_x11_dpy, g_x11_win, x_off, y_off, width, height); } - XIfEvent(g_x11_dpy, &event, egl_wait_notify, NULL); - + x11_event_queue_check(&event); x11_install_quit_atom(); gfx_ctx_xegl_swap_interval(data, g_interval);