+#ifndef UNDER_CE
+ WINDOWPLACEMENT window_placement;
+#endif
+
+ /* If we do not control our window, we check for geometry changes
+ * ourselves because the parent might not send us its events. */
+ if( p_vout->p_sys->hparent && !p_vout->b_fullscreen )
+ {
+ RECT rect_parent;
+ POINT point;
+
+ GetClientRect( p_vout->p_sys->hparent, &rect_parent );
+ point.x = point.y = 0;
+ ClientToScreen( p_vout->p_sys->hparent, &point );
+ OffsetRect( &rect_parent, point.x, point.y );
+
+ if( !EqualRect( &rect_parent, &p_vout->p_sys->rect_parent ) )
+ {
+ int i_x, i_y, i_width, i_height;
+ p_vout->p_sys->rect_parent = rect_parent;
+
+ /* This one is to force the update even if only
+ * the position has changed */
+ SetWindowPos( p_vout->p_sys->hwnd, 0, 1, 1,
+ rect_parent.right - rect_parent.left,
+ rect_parent.bottom - rect_parent.top, 0 );
+
+ SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,
+ rect_parent.right - rect_parent.left,
+ rect_parent.bottom - rect_parent.top, 0 );
+
+ vout_PlacePicture( p_vout, rect_parent.right - rect_parent.left,
+ rect_parent.bottom - rect_parent.top,
+ &i_x, &i_y, &i_width, &i_height );
+
+ SetWindowPos( p_vout->p_sys->hvideownd, HWND_TOP,
+ i_x, i_y, i_width, i_height, 0 );
+ }
+ }
+
+ /* We used to call the Win32 PeekMessage function here to read the window
+ * messages. But since window can stay blocked into this function for a
+ * long time (for example when you move your window on the screen), I
+ * decided to isolate PeekMessage in another thread. */
+
+ /*
+ * Fullscreen change
+ */
+ if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE
+ || p_vout->p_sys->i_changes & VOUT_FULLSCREEN_CHANGE )
+ {
+ int i_style = 0;
+ vlc_value_t val;
+
+ HWND hwnd = (p_vout->p_sys->hparent && p_vout->p_sys->hfswnd) ?
+ p_vout->p_sys->hfswnd : p_vout->p_sys->hwnd;
+
+ p_vout->b_fullscreen = ! p_vout->b_fullscreen;
+
+ /* We need to switch between Maximized and Normal sized window */
+#ifndef UNDER_CE
+ window_placement.length = sizeof(WINDOWPLACEMENT);
+ GetWindowPlacement( hwnd, &window_placement );
+#endif
+ if( p_vout->b_fullscreen )
+ {
+#ifndef UNDER_CE
+ /* Change window style, no borders and no title bar */
+ int i_style = WS_CLIPCHILDREN | WS_VISIBLE;
+ SetWindowLong( hwnd, GWL_STYLE, i_style );
+
+ if( p_vout->p_sys->hparent )
+ {
+ /* Retrieve current window position so fullscreen will happen
+ * on the right screen */
+ POINT point = {0,0};
+ RECT rect;
+ ClientToScreen( p_vout->p_sys->hwnd, &point );
+ GetClientRect( p_vout->p_sys->hwnd, &rect );
+ SetWindowPos( hwnd, 0, point.x, point.y,
+ rect.right, rect.bottom,
+ SWP_NOZORDER|SWP_FRAMECHANGED );
+ GetWindowPlacement( hwnd, &window_placement );
+ }
+
+ /* Maximize window */
+ window_placement.showCmd = SW_SHOWMAXIMIZED;
+ SetWindowPlacement( hwnd, &window_placement );
+ SetWindowPos( hwnd, 0, 0, 0, 0, 0,
+ SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED);
+#endif
+
+ if( p_vout->p_sys->hparent )
+ {
+ RECT rect;
+ GetClientRect( hwnd, &rect );
+ SetParent( p_vout->p_sys->hwnd, hwnd );
+ SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,
+ rect.right, rect.bottom,
+ SWP_NOZORDER|SWP_FRAMECHANGED );
+ }
+
+ ShowWindow( hwnd, SW_SHOW );
+ SetForegroundWindow( hwnd );
+ }
+ else
+ {
+ /* Change window style, no borders and no title bar */
+ //SetWindowLong( hwnd, GWL_STYLE, p_vout->p_sys->i_window_style );
+
+#ifndef UNDER_CE
+ /* Normal window */
+ window_placement.showCmd = SW_SHOWNORMAL;
+ SetWindowPlacement( hwnd, &window_placement );
+ SetWindowPos( hwnd, 0, 0, 0, 0, 0,
+ SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED);
+#endif
+
+ if( p_vout->p_sys->hparent )
+ {
+ RECT rect;
+ GetClientRect( p_vout->p_sys->hparent, &rect );
+ SetParent( p_vout->p_sys->hwnd, p_vout->p_sys->hparent );
+ SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,
+ rect.right, rect.bottom,
+ SWP_NOZORDER|SWP_FRAMECHANGED );
+
+ ShowWindow( hwnd, SW_HIDE );
+ SetForegroundWindow( p_vout->p_sys->hparent );
+ }
+
+ /* Make sure the mouse cursor is displayed */
+ //PostMessage( p_vout->p_sys->hwnd, WM_VLC_SHOW_MOUSE, 0, 0 );
+ }
+
+ /* Change window style, borders and title bar */
+ ShowWindow( p_vout->p_sys->hwnd, SW_SHOW );
+ UpdateWindow( p_vout->p_sys->hwnd );
+
+ /* Update the object variable and trigger callback */
+ val.b_bool = p_vout->b_fullscreen;
+ var_Set( p_vout, "fullscreen", val );
+
+ p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
+ p_vout->p_sys->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
+ }
+