]> git.sesse.net Git - vlc/blobdiff - modules/video_output/msw/common.c
Win32: use video-x and video-y (fixes #3215)
[vlc] / modules / video_output / msw / common.c
index d1cf7100fe5980765e6ae7c75d2751bbba7e6cc5..8dd2d79f061b362e6e89cf39fc7f9b343e67d45b 100644 (file)
@@ -97,11 +97,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;
 
@@ -155,7 +155,7 @@ void CommonManage(vout_display_t *vd)
 
     /* If we do not control our window, we check for geometry changes
      * ourselves because the parent might not send us its events. */
-    if (sys->hparent && !vd->cfg->is_fullscreen) {
+    if (sys->hparent) {
         RECT rect_parent;
         POINT point;
 
@@ -169,7 +169,7 @@ void CommonManage(vout_display_t *vd)
 
             /* FIXME I find such #ifdef quite weirds. Are they really needed ? */
 
-#if defined(MODULE_NAME_IS_direct3d)
+#if defined(MODULE_NAME_IS_direct3d) || defined(MODULE_NAME_IS_wingdi) || defined(MODULE_NAME_IS_wingapi)
             SetWindowPos(sys->hwnd, 0, 0, 0,
                          rect_parent.right - rect_parent.left,
                          rect_parent.bottom - rect_parent.top,
@@ -186,15 +186,6 @@ void CommonManage(vout_display_t *vd)
                          rect_parent.right - rect_parent.left,
                          rect_parent.bottom - rect_parent.top, 0);
 
-#if defined(MODULE_NAME_IS_wingdi) || defined(MODULE_NAME_IS_wingapi)
-            unsigned int i_x, i_y, i_width, i_height;
-            vout_PlacePicture(vd, rect_parent.right - rect_parent.left,
-                              rect_parent.bottom - rect_parent.top,
-                              &i_x, &i_y, &i_width, &i_height);
-
-            SetWindowPos(sys->hvideownd, HWND_TOP,
-                         i_x, i_y, i_width, i_height, 0);
-#endif
 #endif
         }
     }
@@ -231,6 +222,14 @@ 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;
+}
+
 /*****************************************************************************
  * UpdateRects: update clipping rectangles
  *****************************************************************************
@@ -252,6 +251,12 @@ void UpdateRects(vout_display_t *vd,
     RECT  rect;
     POINT point;
 
+    /* */
+    if (!cfg)
+        cfg = vd->cfg;
+    if (!source)
+        source = &vd->source;
+
     /* Retrieve the window size */
     GetClientRect(sys->hwnd, &rect);
 
@@ -260,19 +265,16 @@ void UpdateRects(vout_display_t *vd,
     ClientToScreen(sys->hwnd, &point);
 
     /* If nothing changed, we can return */
-    bool has_changed;
-    EventThreadUpdateWindowPosition(sys->event, &has_changed,
+    bool has_moved;
+    bool is_resized;
+    EventThreadUpdateWindowPosition(sys->event, &has_moved, &is_resized,
                                     point.x, point.y,
                                     rect.right, rect.bottom);
-    if (!is_forced && !has_changed)
+    if (is_resized)
+        vout_display_SendEventDisplaySize(vd, rect.right, rect.bottom, cfg->is_fullscreen);
+    if (!is_forced && !has_moved && !is_resized )
         return;
 
-    /* */
-    if (!cfg)
-        cfg = vd->cfg;
-    if (!source)
-        source = &vd->source;
-
     /* Update the window position and size */
     vout_display_cfg_t place_cfg = *cfg;
     place_cfg.display.width  = rect.right;
@@ -282,6 +284,10 @@ void UpdateRects(vout_display_t *vd,
     vout_display_PlacePicture(&place, source, &place_cfg, true);
 
     EventThreadUpdateSourceAndPlace(sys->event, source, &place);
+#if defined(MODULE_NAME_IS_wingapi)
+    if (place.width != vd->fmt.i_width || place.height != vd->fmt.i_height)
+        vout_display_SendEventPicturesInvalid(vd);
+#endif
 
     if (sys->hvideownd)
         SetWindowPos(sys->hvideownd, 0,
@@ -302,18 +308,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
@@ -375,19 +371,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;
@@ -410,9 +395,6 @@ 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
@@ -606,14 +588,15 @@ int CommonControl(vout_display_t *vd, int query, va_list args)
         UpdateRects(vd, cfg, source, is_forced);
         return VLC_SUCCESS;
     }
-    case VOUT_DISPLAY_CHANGE_ON_TOP: {       /* int b_on_top */
-        const bool is_on_top = va_arg(args, int);
+    case VOUT_DISPLAY_CHANGE_WINDOW_STATE: {       /* unsigned state */
+        const unsigned state = va_arg(args, unsigned);
+        const bool is_on_top = (state & VOUT_WINDOW_STATE_ABOVE) != 0;
 #ifdef MODULE_NAME_IS_direct3d
         if (sys->use_desktop && is_on_top)
             return VLC_EGENERIC;
 #endif
         if (sys->parent_window) {
-            if (vout_window_SetState(sys->parent_window, is_on_top))
+            if (vout_window_SetState(sys->parent_window, state))
                 return VLC_EGENERIC;
         } else {
             HMENU hMenu = GetSystemMenu(sys->hwnd, FALSE);