[MPlayer-dev-eng] [PATCH] directx, typo, fs

Joey Parrish joey at nicewarrior.org
Wed Apr 2 09:13:03 CEST 2003


Hello,

Attached below is a patch for vo_directx.c.  It's a patch I've just
added to my cygwin packages, and it seemed clean enough to submit for
approval.  It does the following:

1) moves the fullscreen toggling code into a function called toggle_fs
2) fixes a small typo in the keystroke handling code
3) when directx window hears ALT+ENTER, toggles fullscreen status

I could have done this by pushing 'f' to mplayer's input buffer, but
since a user may have other keybindings for 'f', this seemed bad.  I
tried to figure out how to add support for ALT+whatever in keycodes.h,
but the only such keys I found to have unique codes are ALT+0 through
ALT+9 (0x140-0x149, IIRC).  All others generated two codes in
succession, such as ALT+k producing 'k',0x1b for any letter like 'k'.
Because of this, I just decided that having ALT+ENTER for fullscreen
could probably be okay as a directx-specific feature.  (Directx, unlike
linux console, gives a unique way to identify this.)

It's a common keybinding for windows video players IMHO, so I'm going
to include it in my packages anyway for the sake of those who've never
used mplayer on linux and wouldn't know to hit 'f'.  I hope you find
this useful enough to commit, and if not I'll still have it in my
package's patch set, no hurt feelings.

-----
Off-topic, but related to cygwin packages:

I haven't been running the main branch on cygwin.  Does anyone notice if
there is a performance boost when using osdep/timer-win over
linux/timer-lx under cygwin?  Would it be worth patching my 0_90 sources
to backport it?

And I've also noticed that a few ifdef MINGW lines have popped up in
main branch.  Is mplayer getting closer to being able to compile with
only mingw?  I haven't tried it in months.

Thanks,
--Joey
-------------- next part --------------
diff -ur 0_90.poo/libvo/vo_directx.c 0_90.dev/libvo/vo_directx.c
--- 0_90.poo/libvo/vo_directx.c	2003-03-24 19:46:16.000000000 -0600
+++ 0_90.dev/libvo/vo_directx.c	2003-04-02 01:02:58.000000000 -0600
@@ -726,6 +726,59 @@
 	return 0;
 }
 
+void toggle_fs()
+{
+	if(vm)
+	{
+		mp_msg(MSGT_VO, MSGL_ERR,"<vo_directx><ERROR>currently we do not allow to switch from exclusive to windowed mode\n");
+	}
+	else
+	{
+		WINDOWPLACEMENT window_placement;
+		uint32_t width = 0;   /*default: restore to the size it had before maximizing*/
+		uint32_t height = 0;
+		window_placement.length = sizeof(WINDOWPLACEMENT);
+		GetWindowPlacement(hWnd, &window_placement);
+		if(fs)   /*go to windowed*/  
+		{
+			fs = 0;  
+			/*prevent the screen being filled with garbage*/
+			window_placement.showCmd = SW_SHOWMINIMIZED;
+			SetWindowPlacement(hWnd,&window_placement);
+			/*change style and restore the window*/ 
+			SetWindowLong(hWnd,GWL_STYLE,WS_OVERLAPPEDWINDOW|WS_SIZEBOX);
+			window_placement.showCmd = SW_RESTORE;
+			SetWindowPlacement(hWnd,&window_placement );
+			/*restore backgroundcolor*/
+			SetClassLongA(hWnd,GCL_HBRBACKGROUND,(int)CreateSolidBrush(windowcolor));
+			/*never ever make a big window*/
+			if(((window_placement.rcNormalPosition.bottom - window_placement.rcNormalPosition.top)==GetSystemMetrics(SM_CYSCREEN))
+			  &&((window_placement.rcNormalPosition.right - window_placement.rcNormalPosition.left)==GetSystemMetrics(SM_CXSCREEN)))
+			{
+				width = d_image_width;
+				height = d_image_height;
+			}
+			/*show cursor again*/
+			ShowCursor(TRUE);
+		}
+		else    /*go to fullscreen*/
+		{
+			fs = 1;
+			/*remove decoration and maximize*/
+			SetWindowLong(hWnd,GWL_STYLE,0);       
+			window_placement.showCmd = SW_SHOWMAXIMIZED;      
+			SetWindowPlacement(hWnd,&window_placement);
+			/*make the window really black*/
+			SetClassLongA(hWnd,GCL_HBRBACKGROUND,(int)CreateSolidBrush(RGB(0,0,0)));
+			/*hide mouse cursor in fullscreen mode*/
+			if(ShowCursor(FALSE)<0);
+			else while(ShowCursor(FALSE)>=0)mp_msg(MSGT_VO, MSGL_DBG3,"<vo_directx>ShowCursor(FALSE)>=0\n");
+		}
+		RedrawWindow(hWnd,NULL,NULL,RDW_INVALIDATE|RDW_ERASE|RDW_INTERNALPAINT);
+		Directx_ManageDisplay(width,height);
+	}
+}
+
 //function handles input
 static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 {
@@ -786,7 +839,7 @@
 		        case VK_HOME:
 					{mplayer_put_key(KEY_HOME);break;}
 		        case VK_END:
-					{mplayer_put_key(VK_END);break;}
+					{mplayer_put_key(KEY_END);break;}
 		        case VK_PRIOR:
 			        {mplayer_put_key(KEY_PAGE_UP);break;}
 		        case VK_NEXT:
@@ -801,6 +854,17 @@
 			mplayer_put_key(wParam);
 			break;
 		}
+        case WM_SYSCHAR:
+		{
+			// toggle fullscreen if we see alt+enter
+			if (wParam == 13) {
+				toggle_fs();
+				return 0;
+				// return, otherwise DefWindowProc wants to
+				// make the windows "ding" sound... why?
+			}
+			break;
+		}
 		
     }
 	return DefWindowProc(hWnd, message, wParam, lParam);
@@ -1139,58 +1203,8 @@
 	case VOCTRL_DRAW_IMAGE:
         return put_image(data);
     case VOCTRL_FULLSCREEN:
-		{
-	        if(vm)
-			{
-				mp_msg(MSGT_VO, MSGL_ERR,"<vo_directx><ERROR>currently we do not allow to switch from exclusive to windowed mode\n");
-			}
-	        else
-			{
-				WINDOWPLACEMENT window_placement;
-				uint32_t width = 0;   /*default: restore to the size it had before maximizing*/
-				uint32_t height = 0;
-				window_placement.length = sizeof(WINDOWPLACEMENT);
-                GetWindowPlacement(hWnd, &window_placement);
-				if(fs)   /*go to windowed*/  
-				{
-					fs = 0;  
-		            /*prevent the screen being filled with garbage*/
-		            window_placement.showCmd = SW_SHOWMINIMIZED; 		   
-		            SetWindowPlacement(hWnd,&window_placement);
-		            /*change style and restore the window*/ 
-					SetWindowLong(hWnd,GWL_STYLE,WS_OVERLAPPEDWINDOW|WS_SIZEBOX);
-					window_placement.showCmd = SW_RESTORE;
-		    		SetWindowPlacement(hWnd,&window_placement );
-        			/*restore backgroundcolor*/
-		    		SetClassLongA(hWnd,GCL_HBRBACKGROUND,(int)CreateSolidBrush(windowcolor));
-					/*never ever make a big window*/
-					if(((window_placement.rcNormalPosition.bottom - window_placement.rcNormalPosition.top)==GetSystemMetrics(SM_CYSCREEN))
-					  &&((window_placement.rcNormalPosition.right - window_placement.rcNormalPosition.left)==GetSystemMetrics(SM_CXSCREEN)))
-					{
-						width = d_image_width;
-						height = d_image_height;
-					}
-                    /*show cursor again*/
-					ShowCursor(TRUE);
-				}
-		        else    /*go to fullscreen*/
-				{
-					fs = 1;
-		            /*remove decoration and maximize*/
-		            SetWindowLong(hWnd,GWL_STYLE,0);       
-		            window_placement.showCmd = SW_SHOWMAXIMIZED;      
-		            SetWindowPlacement(hWnd,&window_placement);
-					/*make the window really black*/
-					SetClassLongA(hWnd,GCL_HBRBACKGROUND,(int)CreateSolidBrush(RGB(0,0,0)));
-                    /*hide mouse cursor in fullscreen mode*/
-					if(ShowCursor(FALSE)<0);
-					else while(ShowCursor(FALSE)>=0)mp_msg(MSGT_VO, MSGL_DBG3,"<vo_directx>ShowCursor(FALSE)>=0\n");
-				}
-                RedrawWindow(hWnd,NULL,NULL,RDW_INVALIDATE|RDW_ERASE|RDW_INTERNALPAINT);
-				Directx_ManageDisplay(width,height);
-			}
-		    return VO_TRUE;
-		}
+	toggle_fs();
+	return VO_TRUE;
     };
     return VO_NOTIMPL;
 }


More information about the MPlayer-dev-eng mailing list