]> git.sesse.net Git - vlc/blobdiff - src/video_output/window.c
Use var_Inherit* instead of var_CreateGet*.
[vlc] / src / video_output / window.c
index 503006b189edb6e0ee7883233c7b2466e7ca13b7..e5f4c25bead61daf2b805fade7f35999150207bf 100644 (file)
 
 #include <vlc_common.h>
 #include <vlc_vout_window.h>
+#include <vlc_modules.h>
+#include "inhibit.h"
 #include <libvlc.h>
 
 typedef struct
 {
     vout_window_t wnd;
     module_t *module;
+    vlc_inhibit_t *inhibit;
 } window_t;
 
 vout_window_t *vout_window_New(vlc_object_t *obj,
@@ -56,11 +59,22 @@ vout_window_t *vout_window_New(vlc_object_t *obj,
 
     const char *type;
     switch (cfg->type) {
+#ifdef WIN32
     case VOUT_WINDOW_TYPE_HWND:
         type = "vout window hwnd";
+        window->handle.hwnd = NULL;
         break;
+#endif
+#ifdef __APPLE__
+    case VOUT_WINDOW_TYPE_NSOBJECT:
+        type = "vout window nsobject";
+        window->handle.nsobject = NULL;
+        break;
+#endif
     case VOUT_WINDOW_TYPE_XID:
         type = "vout window xid";
+        window->handle.xid = 0;
+        window->display.x11 = NULL;
         break;
     default:
         assert(0);
@@ -68,10 +82,20 @@ vout_window_t *vout_window_New(vlc_object_t *obj,
 
     w->module = module_need(window, type, module, module && *module != '\0');
     if (!w->module) {
-        vlc_object_detach(window);
         vlc_object_release(window);
         return NULL;
     }
+
+    /* Hook for screensaver inhibition */
+    if ( var_InheritBool( obj, "disable-screensaver" ) && cfg->type == VOUT_WINDOW_TYPE_XID) {
+        w->inhibit = vlc_inhibit_Create (VLC_OBJECT (window),
+                                         window->handle.xid);
+        if (w->inhibit != NULL)
+            vlc_inhibit_Set (w->inhibit, true);
+            /* FIXME: ^ wait for vout activation, pause */
+    }
+    else
+        w->inhibit = NULL;
     return window;
 }
 
@@ -81,7 +105,8 @@ void vout_window_Delete(vout_window_t *window)
         return;
 
     window_t *w = (window_t *)window;
-    vlc_object_detach(window);
+    if (w->inhibit)
+        vlc_inhibit_Destroy (w->inhibit);
 
     module_unneed(window, w->module);