[vlc-devel] [PATCH 12/41] vout:win32: store the window dimensions as a RECT

Steve Lhomme robux4 at ycbcr.xyz
Fri Mar 22 16:13:50 CET 2019


---
 modules/video_output/win32/events.c | 39 +++++++++++------------------
 1 file changed, 15 insertions(+), 24 deletions(-)

diff --git a/modules/video_output/win32/events.c b/modules/video_output/win32/events.c
index be08df5258..91574d5e13 100644
--- a/modules/video_output/win32/events.c
+++ b/modules/video_output/win32/events.c
@@ -80,8 +80,7 @@ struct event_thread_t
     char *psz_title;
 
     int i_window_style;
-    int x, y;
-    unsigned width, height;
+    RECT window_area;
 
     /* */
     vout_window_t *parent_window;
@@ -416,18 +415,10 @@ int EventThreadGetWindowStyle( event_thread_t *p_event )
 bool EventThreadUpdateWindowPosition( event_thread_t *p_event, const RECT *area )
 {
     vlc_mutex_lock( &p_event->lock );
-    RECT current_area;
-    current_area.left   = p_event->x;
-    current_area.right  = p_event->x + p_event->width;
-    current_area.top    = p_event->y;
-    current_area.bottom = p_event->y + p_event->height;
-
-    p_event->x      = area->left;
-    p_event->y      = area->top;
-    p_event->width  = RECTWidth(*area);
-    p_event->height = RECTHeight(*area);
+    bool changed = !EqualRect(&p_event->window_area, area);
+    p_event->window_area = *area;
     vlc_mutex_unlock( &p_event->lock );
-    return !EqualRect(&current_area, area);
+    return changed;
 }
 
 void EventThreadUpdateSourceAndPlace( event_thread_t *p_event,
@@ -494,10 +485,10 @@ void EventThreadDestroy( event_thread_t *p_event )
 int EventThreadStart( event_thread_t *p_event, event_hwnd_t *p_hwnd, const event_cfg_t *p_cfg )
 {
     p_event->use_desktop = p_cfg->use_desktop;
-    p_event->x           = p_cfg->x;
-    p_event->y           = p_cfg->y;
-    p_event->width       = p_cfg->width;
-    p_event->height      = p_cfg->height;
+    p_event->window_area.left   = p_cfg->x;
+    p_event->window_area.top    = p_cfg->y;
+    p_event->window_area.right  = p_cfg->x + p_cfg->width;
+    p_event->window_area.bottom = p_cfg->y + p_cfg->height;
 
     atomic_store(&p_event->has_moved, false);
 
@@ -668,7 +659,6 @@ static int Win32VoutCreateWindow( event_thread_t *p_event )
     vout_display_t *vd = p_event->vd;
     HINSTANCE  hInstance;
     HMENU      hMenu;
-    RECT       rect_window;
     WNDCLASS   wc;                            /* window class components */
     TCHAR      vlc_path[MAX_PATH+1];
     int        i_style;
@@ -745,10 +735,11 @@ static int Win32VoutCreateWindow( event_thread_t *p_event )
      * have. Unfortunatly these dimensions will include the borders and
      * titlebar. We use the following function to find out the size of
      * the window corresponding to the useable surface we want */
+    RECT rect_window;
     rect_window.left   = 10;
     rect_window.top    = 10;
-    rect_window.right  = rect_window.left + p_event->width;
-    rect_window.bottom = rect_window.top  + p_event->height;
+    rect_window.right  = rect_window.left + RECTWidth(p_event->window_area);
+    rect_window.bottom = rect_window.top  + RECTHeight(p_event->window_area);
 
     i_style = var_GetBool( vd, "video-deco" )
         /* Open with window decoration */
@@ -777,10 +768,10 @@ static int Win32VoutCreateWindow( event_thread_t *p_event )
                     p_event->class_main,             /* name of window class */
                     _T(VOUT_TITLE) _T(" (VLC Video Output)"),/* window title */
                     i_style,                                 /* window style */
-                    (!p_event->x) ? (UINT)CW_USEDEFAULT :
-                        (UINT)p_event->x,            /* default X coordinate */
-                    (!p_event->y) ? (UINT)CW_USEDEFAULT :
-                        (UINT)p_event->y,            /* default Y coordinate */
+                    (!p_event->window_area.left) ? (UINT)CW_USEDEFAULT :
+                        (UINT)p_event->window_area.left, /* default X coordinate */
+                    (!p_event->window_area.top) ? (UINT)CW_USEDEFAULT :
+                        (UINT)p_event->window_area.top, /* default Y coordinate */
                     RECTWidth(rect_window),                  /* window width */
                     RECTHeight(rect_window),                /* window height */
                     p_event->hparent,                       /* parent window */
-- 
2.17.1



More information about the vlc-devel mailing list