[vlc-commits] EGL: support non-default X11 display

Rémi Denis-Courmont git at videolan.org
Sun Nov 3 15:26:15 CET 2013


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Nov  3 16:14:35 2013 +0200| [e1cdb462c112f5567ffcb6db05a28b7805fa1432] | committer: Rémi Denis-Courmont

EGL: support non-default X11 display

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e1cdb462c112f5567ffcb6db05a28b7805fa1432
---

 modules/video_output/egl.c |   31 +++++++++++++++++++++++++++----
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/modules/video_output/egl.c b/modules/video_output/egl.c
index a6c02e9..dc0fa64 100644
--- a/modules/video_output/egl.c
+++ b/modules/video_output/egl.c
@@ -68,6 +68,9 @@ typedef struct vlc_gl_sys_t
     EGLDisplay display;
     EGLSurface surface;
     EGLContext context;
+#if defined (USE_PLATFORM_X11)
+    Display *x11;
+#endif
 } vlc_gl_sys_t;
 
 /* OpenGL callbacks */
@@ -138,12 +141,28 @@ static int Open (vlc_object_t *obj, const struct gl_api *api)
     sys->display = EGL_NO_DISPLAY;
 
 #ifdef USE_PLATFORM_X11
-    if (wnd->type != VOUT_WINDOW_TYPE_XID || wnd->display.x11 != NULL
-     || !vlc_xlib_init(obj))
+    sys->x11 = NULL;
+
+    if (wnd->type != VOUT_WINDOW_TYPE_XID || !vlc_xlib_init(obj))
         goto error;
 
-    sys->display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
-    window = wnd->handle.xid;
+    sys->x11 = XOpenDisplay(wnd->display.x11);
+    if (sys->x11 == NULL)
+        goto error;
+
+    int snum;
+    {
+        XWindowAttributes wa;
+
+        if (!XGetWindowAttributes(sys->x11, wnd->handle.xid, &wa))
+            goto error;
+        snum = XScreenNumberOfScreen(wa.screen);
+    }
+    if (snum == XDefaultScreen(sys->x11))
+    {
+        sys->display = eglGetDisplay(sys->x11);
+        window = wnd->handle.xid;
+    }
 
 #elif defined (USE_PLATFORM_WIN32)
     if (wnd->type != VOUT_WINDOW_TYPE_HWND)
@@ -264,6 +283,10 @@ static void Close (vlc_object_t *obj)
 
     if (sys->display != EGL_NO_DISPLAY)
         eglTerminate(sys->display);
+#ifdef USE_PLATFORM_X11
+    if (sys->x11 != NULL)
+        XCloseDisplay(sys->x11);
+#endif
     free (sys);
 }
 



More information about the vlc-commits mailing list