vlc | branch: master | Steve Lhomme <[email protected]> | Fri Mar 22 09:19:04 2019 +0100| [799deffa0e3da54c187c6248bbdd2a7b3a0b0c18] | committer: Steve Lhomme
vout:win32: simplify the size/position checks using a RECT > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=799deffa0e3da54c187c6248bbdd2a7b3a0b0c18 --- modules/video_output/win32/common.c | 14 ++++++------- modules/video_output/win32/events.c | 39 +++++++++++++++---------------------- modules/video_output/win32/events.h | 3 +-- 3 files changed, 24 insertions(+), 32 deletions(-) diff --git a/modules/video_output/win32/common.c b/modules/video_output/win32/common.c index 4b4757a19d..7e6d7492e6 100644 --- a/modules/video_output/win32/common.c +++ b/modules/video_output/win32/common.c @@ -164,8 +164,8 @@ void UpdateRects(vout_display_t *vd, vout_display_sys_win32_t *sys, bool is_forc /* If nothing changed, we can return */ bool moved_or_resized; #if VLC_WINSTORE_APP - moved_or_resized = rect.right != RECTWidth(sys->rect_display) || - rect.bottom != RECTHeight(sys->rect_display); + moved_or_resized = RECTWidth(rect) != RECTWidth(sys->rect_display) || + RECTHeight(rect) != RECTHeight(sys->rect_display); sys->rect_display = rect; #else if (sys->b_windowless) @@ -177,9 +177,9 @@ void UpdateRects(vout_display_t *vd, vout_display_sys_win32_t *sys, bool is_forc /* Retrieve the window position */ ClientToScreen(sys->hwnd, &point); - EventThreadUpdateWindowPosition(sys->event, &moved_or_resized, - point.x, point.y, - rect.right, rect.bottom); + OffsetRect(&rect, point.x, point.y); + + moved_or_resized = EventThreadUpdateWindowPosition(sys->event, &rect); } #endif if (!is_forced && !moved_or_resized) @@ -187,8 +187,8 @@ void UpdateRects(vout_display_t *vd, vout_display_sys_win32_t *sys, bool is_forc /* Update the window position and size */ vout_display_cfg_t place_cfg = *cfg; - place_cfg.display.width = rect.right; - place_cfg.display.height = rect.bottom; + place_cfg.display.width = RECTWidth(rect); + place_cfg.display.height = RECTHeight(rect); #if (defined(MODULE_NAME_IS_glwin32)) /* Reverse vertical alignment as the GL tex are Y inverted */ diff --git a/modules/video_output/win32/events.c b/modules/video_output/win32/events.c index d31162f219..971da2ef4b 100644 --- a/modules/video_output/win32/events.c +++ b/modules/video_output/win32/events.c @@ -77,8 +77,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; @@ -410,19 +409,13 @@ int EventThreadGetWindowStyle( event_thread_t *p_event ) return p_event->i_window_style; } -void EventThreadUpdateWindowPosition( event_thread_t *p_event, - bool *pb_moved_or_resized, - int x, int y, unsigned w, unsigned h ) +bool EventThreadUpdateWindowPosition( event_thread_t *p_event, const RECT *area ) { vlc_mutex_lock( &p_event->lock ); - *pb_moved_or_resized = x != p_event->x || y != p_event->y || - w != p_event->width || h != p_event->height; - - p_event->x = x; - p_event->y = y; - p_event->width = w; - p_event->height = h; + bool changed = !EqualRect(&p_event->window_area, area); + p_event->window_area = *area; vlc_mutex_unlock( &p_event->lock ); + return changed; } void EventThreadUpdateSourceAndPlace( event_thread_t *p_event, @@ -489,10 +482,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); @@ -663,7 +656,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; @@ -740,10 +732,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 */ @@ -772,10 +765,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 */ diff --git a/modules/video_output/win32/events.h b/modules/video_output/win32/events.h index 859c712ff4..25c9a27041 100644 --- a/modules/video_output/win32/events.h +++ b/modules/video_output/win32/events.h @@ -52,8 +52,7 @@ void EventThreadStop( event_thread_t * ); void EventThreadUpdateTitle( event_thread_t *, const char *psz_fallback ); int EventThreadGetWindowStyle( event_thread_t * ); -void EventThreadUpdateWindowPosition( event_thread_t *, bool *pb_moved_or_resized, - int x, int y, unsigned w, unsigned h ); +bool EventThreadUpdateWindowPosition( event_thread_t *, const RECT * ); void EventThreadUpdateSourceAndPlace( event_thread_t *p_event, const video_format_t *p_source, const vout_display_place_t *p_place ); _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
