]> git.sesse.net Git - vlc/blobdiff - modules/video_output/msw/common.c
Revert "Revert "redundant includes of vlc_playlist.h""
[vlc] / modules / video_output / msw / common.c
index 8dd2d79f061b362e6e89cf39fc7f9b343e67d45b..dbcf984fd5935862e886e0b1810d384f4b9f419d 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 *);
@@ -83,9 +84,6 @@ int CommonInit(vout_display_t *vd)
     var_Create(vd, "video-title", VLC_VAR_STRING | VLC_VAR_DOINHERIT);
     var_Create(vd, "video-deco", VLC_VAR_BOOL | VLC_VAR_DOINHERIT);
 
-    /* FIXME remove mouse hide from msw */
-    var_Create(vd, "mouse-hide-timeout", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT);
-
     /* */
     sys->event = EventThreadCreate(vd);
     if (!sys->event)
@@ -135,6 +133,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);
     }
@@ -159,6 +158,7 @@ void CommonManage(vout_display_t *vd)
         RECT rect_parent;
         POINT point;
 
+        /* Check if the parent window has resized or moved */
         GetClientRect(sys->hparent, &rect_parent);
         point.x = point.y = 0;
         ClientToScreen(sys->hparent, &point);
@@ -167,35 +167,27 @@ void CommonManage(vout_display_t *vd)
         if (!EqualRect(&rect_parent, &sys->rect_parent)) {
             sys->rect_parent = rect_parent;
 
-            /* FIXME I find such #ifdef quite weirds. Are they really needed ? */
-
-#if defined(MODULE_NAME_IS_direct3d) || defined(MODULE_NAME_IS_wingdi) || defined(MODULE_NAME_IS_wingapi)
+            /* This code deals with both resize and move
+             *
+             * For most drivers(direct3d, gdi, opengl), move is never
+             * an issue. The surface automatically gets moved together
+             * with the associated window (hvideownd)
+             *
+             * For directx, it is still important to call UpdateRects
+             * on a move of the parent window, even if no resize occured
+             */
             SetWindowPos(sys->hwnd, 0, 0, 0,
                          rect_parent.right - rect_parent.left,
                          rect_parent.bottom - rect_parent.top,
                          SWP_NOZORDER);
-            UpdateRects(vd, NULL, NULL, true);
-#else
-            /* This one is to force the update even if only
-             * the position has changed */
-            SetWindowPos(sys->hwnd, 0, 1, 1,
-                         rect_parent.right - rect_parent.left,
-                         rect_parent.bottom - rect_parent.top, 0);
-
-            SetWindowPos(sys->hwnd, 0, 0, 0,
-                         rect_parent.right - rect_parent.left,
-                         rect_parent.bottom - rect_parent.top, 0);
 
-#endif
+            UpdateRects(vd, NULL, NULL, true);
         }
     }
 
-    /* */
+    /* HasMoved means here resize or move */
     if (EventThreadGetAndResetHasMoved(sys->event))
         UpdateRects(vd, NULL, NULL, false);
-
-    /* Pointer change */
-    EventThreadMouseAutoHide(sys->event);
 }
 
 /**
@@ -230,6 +222,49 @@ void AlignRect(RECT *r, int align_boundary, int 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
  *****************************************************************************
@@ -281,7 +316,7 @@ void UpdateRects(vout_display_t *vd,
     place_cfg.display.height = rect.bottom;
 
     vout_display_place_t place;
-    vout_display_PlacePicture(&place, source, &place_cfg, true);
+    vout_display_PlacePicture(&place, source, &place_cfg, false);
 
     EventThreadUpdateSourceAndPlace(sys->event, source, &place);
 #if defined(MODULE_NAME_IS_wingapi)
@@ -323,7 +358,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
@@ -344,7 +379,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 */
@@ -397,37 +432,9 @@ void UpdateRects(vout_display_t *vd,
     rect_dest_clipped.bottom -= sys->rect_display.top;
 #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;
 
@@ -538,9 +545,6 @@ static int CommonControlSetFullscreen(vout_display_t *vd, bool is_fullscreen)
             SetWindowPlacement(hwnd, &window_placement);
             ShowWindow(hwnd, SW_SHOWNORMAL);
         }
-
-        /* Make sure the mouse cursor is displayed */
-        EventThreadMouseShow(sys->event);
     }
     return VLC_SUCCESS;
 }
@@ -614,11 +618,16 @@ int CommonControl(vout_display_t *vd, int query, va_list args)
     }
     case VOUT_DISPLAY_CHANGE_FULLSCREEN: {   /* const vout_display_cfg_t *p_cfg */
         const vout_display_cfg_t *cfg = va_arg(args, const vout_display_cfg_t *);
-        return CommonControlSetFullscreen(vd, cfg->is_fullscreen);
+        if (CommonControlSetFullscreen(vd, cfg->is_fullscreen))
+            return VLC_EGENERIC;
+        UpdateRects(vd, NULL, NULL, false);
+        return VLC_SUCCESS;
     }
 
-    case VOUT_DISPLAY_RESET_PICTURES:
     case VOUT_DISPLAY_HIDE_MOUSE:
+        EventThreadMouseHide(sys->event);
+        return VLC_SUCCESS;
+    case VOUT_DISPLAY_RESET_PICTURES:
         assert(0);
     default:
         return VLC_EGENERIC;