# HG changeset patch # User faust3 # Date 1119807847 0 # Node ID 0651bf2803918c707b6e8a51369ea1a518b66230 # Parent 1a3efcc32e8503e477da7864cedce3db4f596792 keep aspect when resizing, quit MPlayer when closing the window patch by Erik Lunchpail diff -r 1a3efcc32e85 -r 0651bf280391 libvo/vo_winvidix.c --- a/libvo/vo_winvidix.c Sun Jun 26 17:32:59 2005 +0000 +++ b/libvo/vo_winvidix.c Sun Jun 26 17:44:07 2005 +0000 @@ -50,6 +50,7 @@ static HWND hWnd; /* Window parameters */ static HWND hWnd=NULL,hWndFS=NULL; +static float window_aspect; static vidix_grkey_t gr_key; @@ -62,11 +63,15 @@ { switch (message){ case WM_DESTROY: + PostQuitMessage(0); + return 0; + case WM_CLOSE: mp_input_queue_cmd(mp_input_parse_cmd("quit")); break; case WM_WINDOWPOSCHANGED: { - /*calculate new window rect*/ + int tmpheight=0; + /*calculate new window rect*/ if(!vo_fs){ RECT rd; POINT point_window; @@ -82,6 +87,26 @@ vo_dx =point_window.x; vo_dy =point_window.y; // aspect(&vo_dwidth, &vo_dheight, A_NOZOOM); + + /* keep aspect on resize, borrowed from vo_directx.c */ + tmpheight = ((float)vo_dwidth/window_aspect); + tmpheight += tmpheight % 2; + if(tmpheight > vo_dheight) + { + vo_dwidth = ((float)vo_dheight*window_aspect); + vo_dwidth += vo_dwidth % 2; + } + else vo_dheight = tmpheight; + rd.right = rd.left + vo_dwidth; + rd.bottom = rd.top + vo_dheight; + + if(rd.left < 0) rd.left = 0; + if(rd.right > vo_screenwidth) rd.right = vo_screenwidth; + if(rd.top < 0) rd.top = 0; + if(rd.bottom > vo_screenheight) rd.bottom = vo_screenheight; + + AdjustWindowRect(&rd, WS_OVERLAPPEDWINDOW | WS_SIZEBOX, 0); + SetWindowPos(hWnd, HWND_TOPMOST, vo_dx+rd.left, vo_dy+rd.top, rd.right-rd.left, rd.bottom-rd.top, SWP_NOOWNERZORDER); } else { if(ShowCursor(FALSE)>=0)while(ShowCursor(FALSE)>=0){} @@ -184,7 +209,7 @@ aspect(&d_width, &d_height, A_NOZOOM); vo_dwidth=d_width; vo_dheight=d_height; - + window_aspect = (float)d_width / (float)d_height; if(!vo_config_count){