egl_dri2/wayland: Add support for EGL_DEFAULT_DISPLAY
authorBenjamin Franzke <benjaminfranzke@googlemail.com>
Sat, 11 Jun 2011 20:07:02 +0000 (22:07 +0200)
committerKristian Høgsberg <krh@bitplanet.net>
Sun, 12 Jun 2011 12:56:35 +0000 (08:56 -0400)
src/egl/drivers/dri2/egl_dri2.c
src/egl/drivers/dri2/platform_wayland.c

index ea8c8fba8c05bcc5205bb4d670fbf70826f0267a..a94300552586efe123a79c66feeacad72edd8c65 100644 (file)
@@ -528,10 +528,24 @@ dri2_terminate(_EGLDriver *drv, _EGLDisplay *disp)
    if (dri2_dpy->fd)
       close(dri2_dpy->fd);
    dlclose(dri2_dpy->driver);
+
+   if (disp->PlatformDisplay == NULL) {
+      switch (disp->Platform) {
 #ifdef HAVE_X11_PLATFORM
-   if (disp->PlatformDisplay == NULL)
-      xcb_disconnect(dri2_dpy->conn);
+      case _EGL_PLATFORM_X11:
+         xcb_disconnect(dri2_dpy->conn);
+         break;
+#endif
+#ifdef HAVE_WAYLAND_PLATFORM
+      case _EGL_PLATFORM_WAYLAND:
+         wl_display_destroy(dri2_dpy->wl_dpy);
+         break;
 #endif
+      default:
+         break;
+      }
+   }
+
    free(dri2_dpy);
    disp->DriverData = NULL;
 
index 1d6ce2ec49c2de3046adf198e613eac4e23213d8..e786780d3fb962d9a40efa0adce6ae7dc5dd6c04 100644 (file)
@@ -676,7 +676,13 @@ dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp)
    memset(dri2_dpy, 0, sizeof *dri2_dpy);
 
    disp->DriverData = (void *) dri2_dpy;
-   dri2_dpy->wl_dpy = disp->PlatformDisplay;
+   if (disp->PlatformDisplay == NULL) {
+      dri2_dpy->wl_dpy = wl_display_connect(NULL);
+      if (dri2_dpy->wl_dpy == NULL)
+         goto cleanup_dpy;
+   } else {
+      dri2_dpy->wl_dpy = disp->PlatformDisplay;
+   }
 
    id = wl_display_get_global(dri2_dpy->wl_dpy, "wl_drm", 1);
    if (id == 0)