changeset 15822:0651bf280391

keep aspect when resizing, quit MPlayer when closing the window patch by Erik Lunchpail <erik_27can at yahoo.com>
author faust3
date Sun, 26 Jun 2005 17:44:07 +0000
parents 1a3efcc32e85
children 500f49f31630
files libvo/vo_winvidix.c
diffstat 1 files changed, 27 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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){