]> git.sesse.net Git - vlc/blobdiff - modules/video_output/xcb/glx.c
XCB: reset the X11 screen saver when displaying a picture
[vlc] / modules / video_output / xcb / glx.c
index 879335ffadb0d91f917c170ce87d949c14d41bc6..42ff5cf111a5de4fc69343c73b7d5b14f186c820 100644 (file)
@@ -34,6 +34,7 @@
 
 #include <vlc_common.h>
 #include <vlc_plugin.h>
+#include <vlc_xlib.h>
 #include <vlc_vout_display.h>
 #include <vlc_vout_opengl.h>
 #include "../opengl.h"
@@ -51,12 +52,10 @@ vlc_module_begin ()
     set_description (N_("GLX video output (XCB)"))
     set_category (CAT_VIDEO)
     set_subcategory (SUBCAT_VIDEO_VOUT)
-    set_capability ("vout display", 20)
+    set_capability ("vout display", 50)
     set_callbacks (Open, Close)
 
-    add_shortcut ("xcb-glx")
-    add_shortcut ("glx")
-    add_shortcut ("opengl")
+    add_shortcut ("xcb-glx", "glx", "opengl", "xid")
 vlc_module_end ()
 
 struct vout_display_sys_t
@@ -90,6 +89,8 @@ static vout_window_t *MakeWindow (vout_display_t *vd)
 
     memset (&wnd_cfg, 0, sizeof (wnd_cfg));
     wnd_cfg.type = VOUT_WINDOW_TYPE_XID;
+    wnd_cfg.x = var_InheritInteger (vd, "video-x");
+    wnd_cfg.y = var_InheritInteger (vd, "video-y");
     wnd_cfg.width  = vd->cfg->display.width;
     wnd_cfg.height = vd->cfg->display.height;
 
@@ -201,6 +202,9 @@ static int CreateWindow (vout_display_t *vd, xcb_connection_t *conn,
  */
 static int Open (vlc_object_t *obj)
 {
+    if (!vlc_xlib_init (obj))
+        return VLC_EGENERIC;
+
     vout_display_t *vd = (vout_display_t *)obj;
     vout_display_sys_t *sys = malloc (sizeof (*sys));
 
@@ -372,6 +376,7 @@ static int Open (vlc_object_t *obj)
     /* */
     vout_display_info_t info = vd->info;
     info.has_pictures_invalid = false;
+    info.has_event_thread = true;
 
     /* Setup vout_display_t once everything is fine */
     vd->info = info;
@@ -383,8 +388,11 @@ static int Open (vlc_object_t *obj)
     vd->manage = Manage;
 
     /* */
-    vout_display_SendEventFullscreen (vd, false);
-    vout_display_SendEventDisplaySize (vd, width, height, false);
+    bool is_fullscreen = vd->cfg->is_fullscreen;
+    if (is_fullscreen && vout_window_SetFullScreen (sys->embed, true))
+        is_fullscreen = false;
+    vout_display_SendEventFullscreen (vd, is_fullscreen);
+    vout_display_SendEventDisplaySize (vd, width, height, is_fullscreen);
 
     return VLC_SUCCESS;
 
@@ -409,14 +417,20 @@ static void Close (vlc_object_t *obj)
     if (sys->ctx != NULL)
     {
         if (sys->v1_3)
-        {
             glXMakeContextCurrent (dpy, None, None, NULL);
-            glXDestroyWindow (dpy, sys->glwin);
-        }
         else
             glXMakeCurrent (dpy, None, NULL);
         glXDestroyContext (dpy, sys->ctx);
+        if (sys->v1_3)
+            glXDestroyWindow (dpy, sys->glwin);
     }
+
+    /* show the default cursor */
+    xcb_change_window_attributes (XGetXCBConnection (sys->display),
+                                  sys->embed->handle.xid, XCB_CW_CURSOR,
+                                  &(uint32_t) { XCB_CURSOR_NONE });
+    xcb_flush (XGetXCBConnection (sys->display));
+
     XCloseDisplay (dpy);
     vout_display_DeleteWindow (vd, sys->embed);
     free (sys);
@@ -444,7 +458,7 @@ static picture_pool_t *Pool (vout_display_t *vd, unsigned requested_count)
 
 static void PictureRender (vout_display_t *vd, picture_t *pic)
 {
-   vout_display_sys_t *sys = vd->sys;
+    vout_display_sys_t *sys = vd->sys;
 
     vout_display_opengl_Prepare (&sys->vgl, pic);
 }
@@ -452,8 +466,11 @@ static void PictureRender (vout_display_t *vd, picture_t *pic)
 static void PictureDisplay (vout_display_t *vd, picture_t *pic)
 {
     vout_display_sys_t *sys = vd->sys;
+    xcb_connection_t *conn = XGetXCBConnection (sys->display);
 
+    xcb_force_screen_saver (conn, XCB_SCREEN_SAVER_RESET);
     vout_display_opengl_Display (&sys->vgl, &vd->source);
+    xcb_flush (conn);
     picture_Release (pic);
 }