]> git.sesse.net Git - vlc/blobdiff - modules/video_output/msw/common.c
Called vout_display_DeleteWindow(vd, NULL) for vout display not using vout window.
[vlc] / modules / video_output / msw / common.c
index 081bb000a2d3327ea3d98ca50d4eea7c02802b47..fc11a167a3426ae50b6f62075c74c64ecc6a0faa 100644 (file)
@@ -60,6 +60,7 @@
     //WINSHELLAPI BOOL WINAPI SHFullScreen(HWND hwndRequester, DWORD dwState);
 #endif
 
+static void CommonChangeThumbnailClip(vout_display_t *, bool show);
 static int CommonControlSetFullscreen(vout_display_t *, bool is_fullscreen);
 
 static void DisableScreensaver(vout_display_t *);
@@ -97,11 +98,11 @@ int CommonInit(vout_display_t *vd)
     cfg.use_desktop = sys->use_desktop;
 #endif
 #ifdef MODULE_NAME_IS_directx
-    cfg.use_overlay = sys->b_using_overlay;
+    cfg.use_overlay = sys->use_overlay;
 #endif
     cfg.win.type   = VOUT_WINDOW_TYPE_HWND;
-    cfg.win.x      = 0;
-    cfg.win.y      = 0;
+    cfg.win.x      = var_InheritInteger(vd, "video-x");
+    cfg.win.y      = var_InheritInteger(vd, "video-y");
     cfg.win.width  = vd->cfg->display.width;
     cfg.win.height = vd->cfg->display.height;
 
@@ -135,6 +136,7 @@ void CommonClean(vout_display_t *vd)
     vout_display_sys_t *sys = vd->sys;
 
     if (sys->event) {
+        CommonChangeThumbnailClip(vd, false);
         EventThreadStop(sys->event);
         EventThreadDestroy(sys->event);
     }
@@ -222,6 +224,57 @@ void CommonDisplay(vout_display_t *vd)
     sys->is_first_display = false;
 }
 
+void AlignRect(RECT *r, int align_boundary, int align_size)
+{
+    if (align_boundary)
+        r->left = (r->left + align_boundary/2) & ~align_boundary;
+    if (align_size)
+        r->right = ((r->right - r->left + align_size/2) & ~align_size) + r->left;
+}
+
+/* */
+static void CommonChangeThumbnailClip(vout_display_t *vd, bool show)
+{
+#ifndef UNDER_CE
+    vout_display_sys_t *sys = vd->sys;
+
+    /* Windows 7 taskbar thumbnail code */
+    OSVERSIONINFO winVer;
+    winVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+    if (!GetVersionEx(&winVer) || winVer.dwMajorVersion <= 5)
+        return;
+
+    CoInitialize(0);
+
+    LPTASKBARLIST3 taskbl;
+    if (S_OK == CoCreateInstance(&clsid_ITaskbarList,
+                                 NULL, CLSCTX_INPROC_SERVER,
+                                 &IID_ITaskbarList3,
+                                 &taskbl)) {
+        taskbl->vt->HrInit(taskbl);
+
+        HWND hroot = GetAncestor(sys->hwnd,GA_ROOT);
+        RECT relative;
+        if (show) {
+            RECT video, parent;
+            GetWindowRect(sys->hvideownd, &video);
+            GetWindowRect(hroot, &parent);
+            relative.left   = video.left   - parent.left - 8;
+            relative.top    = video.top    - parent.top - 10;
+
+            relative.right  = video.right  - video.left + relative.left;
+            relative.bottom = video.bottom - video.top  + relative.top - 25;
+        }
+        if (S_OK != taskbl->vt->SetThumbnailClip(taskbl, hroot,
+                                                 show ? &relative : NULL))
+            msg_Err(vd, "SetThumbNailClip failed");
+
+        taskbl->vt->Release(taskbl);
+    }
+    CoUninitialize();
+#endif
+}
+
 /*****************************************************************************
  * UpdateRects: update clipping rectangles
  *****************************************************************************
@@ -277,7 +330,7 @@ void UpdateRects(vout_display_t *vd,
 
     EventThreadUpdateSourceAndPlace(sys->event, source, &place);
 #if defined(MODULE_NAME_IS_wingapi)
-    if (place.width != fmt->i_width || place.height != fmt->i_height)
+    if (place.width != vd->fmt.i_width || place.height != vd->fmt.i_height)
         vout_display_SendEventPicturesInvalid(vd);
 #endif
 
@@ -300,18 +353,8 @@ void UpdateRects(vout_display_t *vd,
 
 #ifdef MODULE_NAME_IS_directx
     /* Apply overlay hardware constraints */
-    if (sys->b_using_overlay) {
-        if (sys->i_align_dest_boundary)
-            rect_dest.left = (rect_dest.left +
-                              sys->i_align_dest_boundary / 2) &
-                                        ~sys->i_align_dest_boundary;
-
-        if (sys->i_align_dest_size)
-            rect_dest.right = ((rect_dest.right -
-                                rect_dest.left +
-                                sys->i_align_dest_size / 2) &
-                                    ~sys->i_align_dest_size) + rect_dest.left;
-    }
+    if (sys->use_overlay)
+        AlignRect(&rect_dest, sys->i_align_dest_boundary, sys->i_align_dest_size);
 #endif
 
 #endif
@@ -325,7 +368,7 @@ void UpdateRects(vout_display_t *vd,
     if (!IntersectRect(&rect_dest_clipped, &rect_dest,
                        &sys->rect_display)) {
         SetRectEmpty(&rect_src_clipped);
-        return;
+        goto exit;
     }
 
 #ifndef NDEBUG
@@ -346,7 +389,7 @@ void UpdateRects(vout_display_t *vd,
     if ((rect_dest_clipped.right - rect_dest_clipped.left) == 0 ||
         (rect_dest_clipped.bottom - rect_dest_clipped.top) == 0) {
         SetRectEmpty(&rect_src_clipped);
-        return;
+        goto exit;
     }
 
     /* src image dimensions */
@@ -373,19 +416,8 @@ void UpdateRects(vout_display_t *vd,
 
 #ifdef MODULE_NAME_IS_directx
     /* Apply overlay hardware constraints */
-    if (sys->b_using_overlay) {
-        if (sys->i_align_src_boundary)
-            rect_src_clipped.left =
-                (rect_src_clipped.left +
-                 sys->i_align_src_boundary / 2) &
-                            ~sys->i_align_src_boundary;
-
-        if (sys->i_align_src_size)
-            rect_src_clipped.right =
-                ((rect_src_clipped.right - rect_src_clipped.left +
-                  sys->i_align_src_size / 2) &
-                            ~sys->i_align_src_size) + rect_src_clipped.left;
-    }
+    if (sys->use_overlay)
+        AlignRect(&rect_src_clipped, sys->i_align_src_boundary, sys->i_align_src_size);
 #elif defined(MODULE_NAME_IS_direct3d)
     /* Needed at least with YUV content */
     rect_src_clipped.left &= ~1;
@@ -408,42 +440,11 @@ void UpdateRects(vout_display_t *vd,
     rect_dest_clipped.right -= sys->rect_display.left;
     rect_dest_clipped.top -= sys->rect_display.top;
     rect_dest_clipped.bottom -= sys->rect_display.top;
-
-    if (sys->b_using_overlay)
-        DirectDrawUpdateOverlay(vd);
 #endif
 
-#ifndef UNDER_CE
-    /* Windows 7 taskbar thumbnail code */
-    LPTASKBARLIST3 taskbl;
-    OSVERSIONINFO winVer;
-    winVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
-    if (GetVersionEx(&winVer) && winVer.dwMajorVersion > 5) {
-        CoInitialize(0);
-
-        if (S_OK == CoCreateInstance(&clsid_ITaskbarList,
-                                     NULL, CLSCTX_INPROC_SERVER,
-                                     &IID_ITaskbarList3,
-                                     &taskbl)) {
-            RECT rect_video, rect_parent, rect_relative;
-            HWND hroot = GetAncestor(sys->hwnd,GA_ROOT);
-
-            taskbl->vt->HrInit(taskbl);
-            GetWindowRect(sys->hvideownd, &rect_video);
-            GetWindowRect(hroot, &rect_parent);
-            rect_relative.left = rect_video.left - rect_parent.left - 8;
-            rect_relative.right = rect_video.right - rect_video.left + rect_relative.left;
-            rect_relative.top = rect_video.top - rect_parent.top - 10;
-            rect_relative.bottom = rect_video.bottom - rect_video.top + rect_relative.top - 25;
-
-            if (S_OK != taskbl->vt->SetThumbnailClip(taskbl, hroot, &rect_relative))
-                msg_Err(vd, "SetThumbNailClip failed");
-
-            taskbl->vt->Release(taskbl);
-        }
-        CoUninitialize();
-    }
-#endif
+    CommonChangeThumbnailClip(vd, true);
+
+exit:
     /* Signal the change in size/position */
     sys->changes |= DX_POSITION_CHANGE;