From f364ff0649a6b32b5f948d29c5edba2e4f753890 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 19 Nov 2015 11:07:52 +0100 Subject: [PATCH] Create x11_connect --- gfx/common/x11_common.c | 16 ++++++++++++++++ gfx/common/x11_common.h | 2 ++ gfx/drivers_context/glx_ctx.c | 7 +------ gfx/drivers_context/xegl_ctx.c | 12 ++---------- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/gfx/common/x11_common.c b/gfx/common/x11_common.c index ec6db79f8a..a481c586fd 100644 --- a/gfx/common/x11_common.c +++ b/gfx/common/x11_common.c @@ -503,3 +503,19 @@ void x11_install_sighandlers(void) sigaction(SIGINT, &sa, NULL); sigaction(SIGTERM, &sa, NULL); } + +bool x11_connect(void) +{ + g_x11_quit = 0; + + /* Keep one g_x11_dpy alive the entire process lifetime. + * This is necessary for nVidia's EGL implementation for now. */ + if (!g_x11_dpy) + { + g_x11_dpy = XOpenDisplay(NULL); + if (!g_x11_dpy) + return false; + } + + return true; +} diff --git a/gfx/common/x11_common.h b/gfx/common/x11_common.h index 839adb307d..8d35680ebe 100644 --- a/gfx/common/x11_common.h +++ b/gfx/common/x11_common.h @@ -79,5 +79,7 @@ bool x11_alive(void *data); void x11_install_sighandlers(void); +bool x11_connect(void); + #endif diff --git a/gfx/drivers_context/glx_ctx.c b/gfx/drivers_context/glx_ctx.c index 1be3c9bab0..cccea2700b 100644 --- a/gfx/drivers_context/glx_ctx.c +++ b/gfx/drivers_context/glx_ctx.c @@ -260,12 +260,7 @@ static bool gfx_ctx_glx_init(void *data) XInitThreads(); - g_x11_quit = 0; - - if (!g_x11_dpy) - g_x11_dpy = XOpenDisplay(NULL); - - if (!g_x11_dpy) + if (!x11_connect()) goto error; glXQueryVersion(g_x11_dpy, &major, &minor); diff --git a/gfx/drivers_context/xegl_ctx.c b/gfx/drivers_context/xegl_ctx.c index fa40297c17..5231a467d7 100644 --- a/gfx/drivers_context/xegl_ctx.c +++ b/gfx/drivers_context/xegl_ctx.c @@ -215,16 +215,8 @@ static bool gfx_ctx_xegl_init(void *data) attrib_ptr = NULL; } - g_x11_quit = 0; - - /* Keep one g_x11_dpy alive the entire process lifetime. - * This is necessary for nVidia's EGL implementation for now. */ - if (!g_x11_dpy) - { - g_x11_dpy = XOpenDisplay(NULL); - if (!g_x11_dpy) - goto error; - } + if (!x11_connect()) + goto error; g_egl_dpy = eglGetDisplay((EGLNativeDisplayType)g_x11_dpy); if (g_egl_dpy == EGL_NO_DISPLAY)