-/*****************************************************************************
- * UpdateRects: update clipping rectangles
- *****************************************************************************
- * This function is called when the window position or size are changed, and
- * its job is to update the source and destination RECTs used to display the
- * picture.
- *****************************************************************************/
-void UpdateRects( vout_thread_t *p_vout, bool b_force )
-{
-#define rect_src p_vout->p_sys->rect_src
-#define rect_src_clipped p_vout->p_sys->rect_src_clipped
-#define rect_dest p_vout->p_sys->rect_dest
-#define rect_dest_clipped p_vout->p_sys->rect_dest_clipped
-
- unsigned int i_width, i_height, i_x, i_y;
-
- RECT rect;
- POINT point;
-
- /* Retrieve the window size */
- GetClientRect( p_vout->p_sys->hwnd, &rect );
-
- /* Retrieve the window position */
- point.x = point.y = 0;
- ClientToScreen( p_vout->p_sys->hwnd, &point );
-
- /* If nothing changed, we can return */
- if( !b_force
- && p_vout->p_sys->i_window_width == rect.right
- && p_vout->p_sys->i_window_height == rect.bottom
- && p_vout->p_sys->i_window_x == point.x
- && p_vout->p_sys->i_window_y == point.y )
- {
- return;
- }
-
- /* Update the window position and size */
- p_vout->p_sys->i_window_x = point.x;
- p_vout->p_sys->i_window_y = point.y;
- p_vout->p_sys->i_window_width = rect.right;
- p_vout->p_sys->i_window_height = rect.bottom;
-
- vout_PlacePicture( p_vout, rect.right, rect.bottom,
- &i_x, &i_y, &i_width, &i_height );
-
- if( p_vout->p_sys->hvideownd )
- SetWindowPos( p_vout->p_sys->hvideownd, 0,
- i_x, i_y, i_width, i_height,
- SWP_NOCOPYBITS|SWP_NOZORDER|SWP_ASYNCWINDOWPOS );
-
- /* Destination image position and dimensions */
- rect_dest.left = point.x + i_x;
- rect_dest.right = rect_dest.left + i_width;
- rect_dest.top = point.y + i_y;
- rect_dest.bottom = rect_dest.top + i_height;
-
-#ifdef MODULE_NAME_IS_directx
- /* Apply overlay hardware constraints */
- if( p_vout->p_sys->b_using_overlay )
- {
- if( p_vout->p_sys->i_align_dest_boundary )
- rect_dest.left = ( rect_dest.left +
- p_vout->p_sys->i_align_dest_boundary / 2 ) &
- ~p_vout->p_sys->i_align_dest_boundary;
-
- if( p_vout->p_sys->i_align_dest_size )
- rect_dest.right = (( rect_dest.right - rect_dest.left +
- p_vout->p_sys->i_align_dest_size / 2 ) &
- ~p_vout->p_sys->i_align_dest_size) + rect_dest.left;
- }
-
- /* UpdateOverlay directdraw function doesn't automatically clip to the
- * display size so we need to do it otherwise it will fail */
-
- /* Clip the destination window */
- if( !IntersectRect( &rect_dest_clipped, &rect_dest,
- &p_vout->p_sys->rect_display ) )
- {
- SetRectEmpty( &rect_src_clipped );
- return;
- }
-
-#ifndef NDEBUG
- msg_Dbg( p_vout, "DirectXUpdateRects image_dst_clipped coords:"
- " %li,%li,%li,%li",
- rect_dest_clipped.left, rect_dest_clipped.top,
- rect_dest_clipped.right, rect_dest_clipped.bottom );
-#endif
-
-#else /* MODULE_NAME_IS_directx */
-
- /* AFAIK, there are no clipping constraints in Direct3D, OpenGL and GDI */
- rect_dest_clipped = rect_dest;
-
-#endif
-
- /* the 2 following lines are to fix a bug when clicking on the desktop */
- if( (rect_dest_clipped.right - rect_dest_clipped.left)==0 ||
- (rect_dest_clipped.bottom - rect_dest_clipped.top)==0 )
- {
- SetRectEmpty( &rect_src_clipped );
- return;
- }
-
- /* src image dimensions */
- rect_src.left = 0;
- rect_src.top = 0;
- rect_src.right = p_vout->render.i_width;
- rect_src.bottom = p_vout->render.i_height;
-
- /* Clip the source image */
- rect_src_clipped.left = p_vout->fmt_out.i_x_offset +
- (rect_dest_clipped.left - rect_dest.left) *
- p_vout->fmt_out.i_visible_width / (rect_dest.right - rect_dest.left);
- rect_src_clipped.right = p_vout->fmt_out.i_x_offset +
- p_vout->fmt_out.i_visible_width -
- (rect_dest.right - rect_dest_clipped.right) *
- p_vout->fmt_out.i_visible_width / (rect_dest.right - rect_dest.left);
- rect_src_clipped.top = p_vout->fmt_out.i_y_offset +
- (rect_dest_clipped.top - rect_dest.top) *
- p_vout->fmt_out.i_visible_height / (rect_dest.bottom - rect_dest.top);
- rect_src_clipped.bottom = p_vout->fmt_out.i_y_offset +
- p_vout->fmt_out.i_visible_height -
- (rect_dest.bottom - rect_dest_clipped.bottom) *
- p_vout->fmt_out.i_visible_height / (rect_dest.bottom - rect_dest.top);
-
-#ifdef MODULE_NAME_IS_directx
- /* Apply overlay hardware constraints */
- if( p_vout->p_sys->b_using_overlay )
- {
- if( p_vout->p_sys->i_align_src_boundary )
- rect_src_clipped.left = ( rect_src_clipped.left +
- p_vout->p_sys->i_align_src_boundary / 2 ) &
- ~p_vout->p_sys->i_align_src_boundary;
-
- if( p_vout->p_sys->i_align_src_size )
- rect_src_clipped.right = (( rect_src_clipped.right -
- rect_src_clipped.left +
- p_vout->p_sys->i_align_src_size / 2 ) &
- ~p_vout->p_sys->i_align_src_size) + rect_src_clipped.left;
- }
-#endif
-
-#ifndef NDEBUG
- msg_Dbg( p_vout, "DirectXUpdateRects image_src_clipped"
- " coords: %li,%li,%li,%li",
- rect_src_clipped.left, rect_src_clipped.top,
- rect_src_clipped.right, rect_src_clipped.bottom );
-#endif
-
-#ifdef MODULE_NAME_IS_directx
- /* The destination coordinates need to be relative to the current
- * directdraw primary surface (display) */
- rect_dest_clipped.left -= p_vout->p_sys->rect_display.left;
- rect_dest_clipped.right -= p_vout->p_sys->rect_display.left;
- rect_dest_clipped.top -= p_vout->p_sys->rect_display.top;
- rect_dest_clipped.bottom -= p_vout->p_sys->rect_display.top;
-
- if( p_vout->p_sys->b_using_overlay )
- DirectDrawUpdateOverlay( p_vout );
-#endif
-
-#ifndef UNDER_CE
- /* Windows 7 taskbar thumbnail code */
- LPTASKBARLIST3 p_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,
- &p_taskbl) )
- {
- RECT rect_video, rect_parent, rect_relative;
- HWND hroot = GetAncestor(p_vout->p_sys->hwnd,GA_ROOT);
-
- p_taskbl->vt->HrInit(p_taskbl);
- GetWindowRect(p_vout->p_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 != p_taskbl->vt->SetThumbnailClip(p_taskbl, hroot, &rect_relative))
- msg_Err( p_vout, "SetThumbNailClip failed");
-
- p_taskbl->vt->Release(p_taskbl);
- }
- CoUninitialize();
- }
-#endif
- /* Signal the change in size/position */
- p_vout->p_sys->i_changes |= DX_POSITION_CHANGE;
-
-#undef rect_src
-#undef rect_src_clipped
-#undef rect_dest
-#undef rect_dest_clipped
-}
-