diff --git a/tools/gnome-session-check-accelerated-gles-helper.c b/tools/gnome-session-check-accelerated-gles-helper.c index 6a4463d..8fd14d4 100644 --- a/tools/gnome-session-check-accelerated-gles-helper.c +++ b/tools/gnome-session-check-accelerated-gles-helper.c @@ -38,11 +38,43 @@ #include #include #include +#include #endif #include "gnome-session-check-accelerated-common.h" #ifdef GDK_WINDOWING_X11 +static EGLDisplay +get_display (void *native) +{ + EGLDisplay dpy = NULL; + const char *client_exts = eglQueryString (NULL, EGL_EXTENSIONS); + + if (g_strstr_len (client_exts, -1, "EGL_KHR_platform_base")) { + PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display = + (void *) eglGetProcAddress ("eglGetPlatformDisplay"); + + if (get_platform_display) + dpy = get_platform_display (EGL_PLATFORM_X11_KHR, native, NULL); + + if (dpy) + return dpy; + } + + if (g_strstr_len (client_exts, -1, "EGL_EXT_platform_base")) { + PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display = + (void *) eglGetProcAddress ("eglGetPlatformDisplayEXT"); + + if (get_platform_display) + dpy = get_platform_display (EGL_PLATFORM_X11_KHR, native, NULL); + + if (dpy) + return dpy; + } + + return eglGetDisplay ((EGLNativeDisplayType) native); +} + static char * get_gles_renderer (void) { @@ -71,7 +103,9 @@ get_gles_renderer (void) gdk_error_trap_push (); display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); - egl_dpy = eglGetDisplay (display); + + egl_dpy = get_display (display); + if (!egl_dpy) { g_warning ("eglGetDisplay() failed"); goto out;