egl_dri2: Fix initialization with EGL_DEFAULT_DISPLAY
authorKristian Høgsberg <krh@bitplanet.net>
Tue, 9 Feb 2010 14:49:56 +0000 (09:49 -0500)
committerKristian Høgsberg <krh@bitplanet.net>
Tue, 9 Feb 2010 14:51:05 +0000 (09:51 -0500)
src/egl/drivers/dri2/egl_dri2.c

index 8b01b8453e7becf930750a2a48b5c77349d17434..92378892e5bd414ca9303a12dd2fbffdaf4e6fc9 100644 (file)
@@ -404,13 +404,13 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp,
       return _eglError(EGL_BAD_ALLOC, "eglInitialize");
 
    disp->DriverData = (void *) dri2_dpy;
-   dri2_dpy->conn = XGetXCBConnection(disp->NativeDisplay);
-   if (!dri2_dpy->conn) {
+   if (disp->NativeDisplay != NULL)
+      dri2_dpy->conn = XGetXCBConnection(disp->NativeDisplay);
+   else
       dri2_dpy->conn = xcb_connect(0, 0);
-      if (!dri2_dpy->conn) {
-         _eglLog(_EGL_WARNING, "DRI2: xcb_connect failed");
-        goto cleanup_dpy;
-      }
+   if (!dri2_dpy->conn) {
+      _eglLog(_EGL_WARNING, "DRI2: xcb_connect failed");
+      goto cleanup_dpy;
    }
 
    xcb_prefetch_extension_data (dri2_dpy->conn, &xcb_xfixes_id);