Create x11_connect

This commit is contained in:
twinaphex 2015-11-19 11:07:52 +01:00
parent 95a5818ccb
commit f364ff0649
4 changed files with 21 additions and 16 deletions

View File

@ -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;
}

View File

@ -79,5 +79,7 @@ bool x11_alive(void *data);
void x11_install_sighandlers(void);
bool x11_connect(void);
#endif

View File

@ -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);

View File

@ -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)