]> git.sesse.net Git - vlc/commitdiff
Privatized i_window_x/y/w/h in msw.
authorLaurent Aimar <fenrir@videolan.org>
Mon, 28 Sep 2009 18:52:58 +0000 (20:52 +0200)
committerLaurent Aimar <fenrir@videolan.org>
Mon, 28 Sep 2009 18:52:58 +0000 (20:52 +0200)
It also fixed a race condition with mouse events.

modules/video_output/msw/common.c
modules/video_output/msw/events.c
modules/video_output/msw/events.h
modules/video_output/msw/vout.h

index 7c14f199879ef66ecdc83bb10584e4c4a6d41a68..39e624345692ecc55ef8be0d56c8532e43d977f7 100644 (file)
@@ -89,10 +89,16 @@ int CommonInit( vout_thread_t *p_vout )
     var_Create( p_vout, "video-title", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
 
     /* Set main window's size */
-    p_sys->i_window_width  = p_vout->i_window_width;
-    p_sys->i_window_height = p_vout->i_window_height;
+    vout_window_cfg_t wnd_cfg;
 
-    p_sys->p_event = EventThreadCreate( p_vout );
+    memset( &wnd_cfg, 0, sizeof(wnd_cfg) );
+    wnd_cfg.type   = VOUT_WINDOW_TYPE_HWND;
+    wnd_cfg.x      = 0;
+    wnd_cfg.y      = 0;
+    wnd_cfg.width  = p_vout->i_window_width;
+    wnd_cfg.height = p_vout->i_window_height;
+
+    p_sys->p_event = EventThreadCreate( p_vout, &wnd_cfg );
     if( !p_sys->p_event )
         return VLC_EGENERIC;
     if( EventThreadStart( p_sys->p_event ) )
@@ -311,21 +317,14 @@ void UpdateRects( vout_thread_t *p_vout, bool b_force )
     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 )
-    {
+    bool b_changed;
+    EventThreadUpdateWindowPosition( p_vout->p_sys->p_event, &b_changed,
+                                     point.x, point.y,
+                                     rect.right, rect.bottom );
+    if( !b_force && !b_changed )
         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 );
 
index e81d81d5e3fbab12a1f8666e7fa121a6a224345c..33a5bf8e9075ea39ccc02dc00e552a384076be28 100644 (file)
@@ -95,7 +95,9 @@ struct event_thread_t
 
     /* Title */
     char *psz_title;
-    int  i_window_style;
+
+    int               i_window_style;
+    vout_window_cfg_t wnd_cfg;
 
     /* */
     unsigned i_changes;
@@ -194,10 +196,12 @@ static void *EventThread( void *p_this )
         {
 
         case WM_MOUSEMOVE:
+            vlc_mutex_lock( &p_event->lock );
             vout_PlacePicture( p_event->p_vout,
-                               p_event->p_vout->p_sys->i_window_width,
-                               p_event->p_vout->p_sys->i_window_height,
+                               p_event->wnd_cfg.width,
+                               p_event->wnd_cfg.height,
                                &i_x, &i_y, &i_width, &i_height );
+            vlc_mutex_unlock( &p_event->lock );
 
             if( msg.hwnd == p_event->p_vout->p_sys->hvideownd )
             {
@@ -437,16 +441,8 @@ static int DirectXCreateWindow( event_thread_t *p_event )
     if( !p_vout->p_sys->b_desktop )
     {
     #endif
-        vout_window_cfg_t wnd_cfg;
-        memset( &wnd_cfg, 0, sizeof(wnd_cfg) );
-        wnd_cfg.type   = VOUT_WINDOW_TYPE_HWND;
-        wnd_cfg.x      = p_vout->p_sys->i_window_x;
-        wnd_cfg.y      = p_vout->p_sys->i_window_y;
-        wnd_cfg.width  = p_vout->p_sys->i_window_width;
-        wnd_cfg.height = p_vout->p_sys->i_window_height;
-
         /* If an external window was specified, we'll draw in it. */
-        p_vout->p_sys->parent_window = vout_window_New( VLC_OBJECT(p_vout), NULL, &wnd_cfg );
+        p_vout->p_sys->parent_window = vout_window_New( VLC_OBJECT(p_vout), NULL, &p_event->wnd_cfg );
         if( p_vout->p_sys->parent_window )
             p_vout->p_sys->hparent = p_vout->p_sys->parent_window->handle.hwnd;
     #ifdef MODULE_NAME_IS_direct3d
@@ -522,8 +518,8 @@ static int DirectXCreateWindow( event_thread_t *p_event )
      * the window corresponding to the useable surface we want */
     rect_window.top    = 10;
     rect_window.left   = 10;
-    rect_window.right  = rect_window.left + p_vout->p_sys->i_window_width;
-    rect_window.bottom = rect_window.top + p_vout->p_sys->i_window_height;
+    rect_window.right  = rect_window.left + p_event->wnd_cfg.width;
+    rect_window.bottom = rect_window.top  + p_event->wnd_cfg.height;
 
     if( var_GetBool( p_vout, "video-deco" ) )
     {
@@ -555,10 +551,10 @@ static int DirectXCreateWindow( event_thread_t *p_event )
                     _T("VLC DirectX"),               /* name of window class */
                     _T(VOUT_TITLE) _T(" (DirectX Output)"),  /* window title */
                     i_style,                                 /* window style */
-                    (p_vout->p_sys->i_window_x < 0) ? CW_USEDEFAULT :
-                        (UINT)p_vout->p_sys->i_window_x,   /* default X coordinate */
-                    (p_vout->p_sys->i_window_y < 0) ? CW_USEDEFAULT :
-                        (UINT)p_vout->p_sys->i_window_y,   /* default Y coordinate */
+                    (p_event->wnd_cfg.x < 0) ? CW_USEDEFAULT :
+                        (UINT)p_event->wnd_cfg.x,   /* default X coordinate */
+                    (p_event->wnd_cfg.y < 0) ? CW_USEDEFAULT :
+                        (UINT)p_event->wnd_cfg.y,   /* default Y coordinate */
                     rect_window.right - rect_window.left,    /* window width */
                     rect_window.bottom - rect_window.top,   /* window height */
                     p_vout->p_sys->hparent,                 /* parent window */
@@ -955,7 +951,22 @@ int EventThreadGetWindowStyle( event_thread_t *p_event )
     return p_event->i_window_style;
 }
 
-event_thread_t *EventThreadCreate( vout_thread_t *p_vout )
+void EventThreadUpdateWindowPosition( event_thread_t *p_event, bool *pb_changed,
+                                      int x, int y, int w, int h )
+{
+    vlc_mutex_lock( &p_event->lock );
+    *pb_changed = x != p_event->wnd_cfg.x ||
+                  y != p_event->wnd_cfg.y ||
+                  w != p_event->wnd_cfg.width ||
+                  h != p_event->wnd_cfg.height;
+
+    p_event->wnd_cfg.x      = x;
+    p_event->wnd_cfg.y      = y;
+    p_event->wnd_cfg.width  = y;
+    p_event->wnd_cfg.height = h;
+    vlc_mutex_unlock( &p_event->lock );
+}
+event_thread_t *EventThreadCreate( vout_thread_t *p_vout, const vout_window_cfg_t *p_wnd_cfg )
 {
      /* Create the Vout EventThread, this thread is created by us to isolate
      * the Win32 PeekMessage function calls. We want to do this because
@@ -978,6 +989,7 @@ event_thread_t *EventThreadCreate( vout_thread_t *p_vout )
     p_event->i_mouse_hide_timeout =
         var_GetInteger(p_vout, "mouse-hide-timeout") * 1000;
     p_event->psz_title = NULL;
+    p_event->wnd_cfg = *p_wnd_cfg;
    
     return p_event;
 }
index 275e513a7fc789462f34b1cd6148be438f5e6c2f..21fac59b0811cfe597423fa5e625c90b9030ee81 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
+#include <vlc_vout_window.h>
+
 /**
  * HWNDs manager.
  */
 typedef struct event_thread_t event_thread_t;
 
-event_thread_t *EventThreadCreate( vout_thread_t * );
+event_thread_t *EventThreadCreate( vout_thread_t *, const vout_window_cfg_t * );
 void            EventThreadDestroy( event_thread_t * );
 int             EventThreadStart( event_thread_t * );
 void            EventThreadStop( event_thread_t * );
@@ -36,3 +38,5 @@ void            EventThreadMouseAutoHide( event_thread_t * );
 void            EventThreadUpdateTitle( event_thread_t *, const char *psz_fallback );
 unsigned        EventThreadRetreiveChanges( event_thread_t * );
 int             EventThreadGetWindowStyle( event_thread_t * );
+void            EventThreadUpdateWindowPosition( event_thread_t *, bool *pb_changed,
+                                                 int x, int y, int w, int h );
index 6de2e5e99e95fe3c8370a0bb96f0de8fb7949447..93de50c420330418aee73f39357f87428a816130 100644 (file)
@@ -90,12 +90,6 @@ struct vout_sys_t
     /* size of the overall window (including black bands) */
     RECT         rect_parent;
 
-    /* Window position and size */
-    int          i_window_x;
-    int          i_window_y;
-    int          i_window_width;
-    int          i_window_height;
-
     volatile uint16_t i_changes;        /* changes made to the video display */
 
     /* Misc */