diff -Naur -wbBE -X ignore_list main-cvs/libvo/vo_directx.c main-devel/libvo/vo_directx.c --- main-cvs/libvo/vo_directx.c 2005-02-28 10:07:23.000000000 +0800 +++ main-devel/libvo/vo_directx.c 2005-05-11 10:43:16.000000000 +0800 @@ -41,6 +41,9 @@ # define WM_XBUTTONDBLCLK 0x020D #endif +#define WNDCLASSNAME_WINDOWED "MPlayer - The Movie Player" +#define WNDCLASSNAME_FULLSCREEN "MPlayer - Fullscreen" + static LPDIRECTDRAWCOLORCONTROL g_cc = NULL; //color control interface static LPDIRECTDRAW7 g_lpdd = NULL; //DirectDraw Object static LPDIRECTDRAWSURFACE7 g_lpddsPrimary = NULL; //Primary Surface: viewport through the Desktop @@ -53,6 +56,10 @@ static RECT rs; //rect of our source image static HWND hWnd=NULL; //handle to the window static HWND hWndFS=NULL; //fullscreen window +static HBRUSH colorbrush = NULL; // Handle to colorkey brush +static HBRUSH blackbrush = NULL; // Handle to black brush +static HICON mplayericon = NULL; // Handle to mplayer icon +static HCURSOR mplayercursor = NULL; // Handle to mplayer cursor static uint32_t image_width, image_height; //image width and height static uint32_t d_image_width, d_image_height; //image width and height zoomed static uint8_t *image=NULL; //image data @@ -345,8 +352,22 @@ g_lpddsPrimary = NULL; mp_msg(MSGT_VO, MSGL_DBG3,"primary released\n"); if(hWndFS)DestroyWindow(hWndFS); - if(hWnd != NULL)DestroyWindow(hWnd); + hWndFS = NULL; + if((WinID == -1) && hWnd) DestroyWindow(hWnd); + hWnd = NULL; mp_msg(MSGT_VO, MSGL_DBG3,"window destroyed\n"); + UnregisterClass(WNDCLASSNAME_WINDOWED, GetModuleHandle(NULL)); + UnregisterClass(WNDCLASSNAME_FULLSCREEN, GetModuleHandle(NULL)); + mp_msg(MSGT_VO, MSGL_DBG3,"window classes unregistered\n"); + if (mplayericon) DestroyIcon(mplayericon); + mplayericon = NULL; + if (mplayercursor) DestroyCursor(mplayercursor); + mplayercursor = NULL; + if (blackbrush) DeleteObject(blackbrush); + blackbrush = NULL; + if (colorbrush) DeleteObject(colorbrush); + colorbrush = NULL; + mp_msg(MSGT_VO, MSGL_DBG3,"GDI resources deleted\n"); if (g_lpdd != NULL){ if(vidmode)g_lpdd->lpVtbl->RestoreDisplayMode(g_lpdd); g_lpdd->lpVtbl->Release(g_lpdd); @@ -521,8 +542,11 @@ aspect(&width,&height,A_ZOOM); rd.left=(vo_screenwidth-width)/2; rd.top=(vo_screenheight-height)/2; + if (WinID == -1) + { if(ShowCursor(FALSE)>=0)while(ShowCursor(FALSE)>=0){} } + } else if (WinID != -1 && vo_geometry) { POINT pt; pt.x = vo_dx; @@ -562,8 +586,11 @@ } else height=tmpheight; } + if (WinID == -1) + { while(ShowCursor(TRUE)<=0){} } + } rd.right=rd.left+width; rd.bottom=rd.top+height; @@ -985,7 +1012,6 @@ static uint32_t preinit(const char *arg) { HINSTANCE hInstance = GetModuleHandle(NULL); - HICON mplayericon=NULL; char exedir[MAX_PATH]; WNDCLASS wc; if(arg) @@ -1002,33 +1028,38 @@ mplayericon = ExtractIcon( hInstance, exedir, 0 ); } if(!mplayericon)mplayericon=LoadIcon(NULL,IDI_APPLICATION); + mplayercursor = LoadCursor(NULL, IDC_ARROW); monitor_rect.right=GetSystemMetrics(SM_CXSCREEN); monitor_rect.bottom=GetSystemMetrics(SM_CYSCREEN); windowcolor = vo_colorkey; + colorbrush = CreateSolidBrush(windowcolor); + blackbrush = (HBRUSH)GetStockObject(BLACK_BRUSH); + mp_msg(MSGT_VO, MSGL_DBG3,"GDI resources created\n"); wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; - wc.hCursor = LoadCursor(NULL,IDC_ARROW); + wc.hCursor = mplayercursor; wc.hIcon = mplayericon; - wc.hbrBackground = CreateSolidBrush(vidmode?RGB(0,0,0):windowcolor); - wc.lpszClassName = "MPlayer - The Movie Player"; + wc.hbrBackground = vidmode ? blackbrush : colorbrush; + wc.lpszClassName = WNDCLASSNAME_WINDOWED; wc.lpszMenuName = NULL; RegisterClass(&wc); if (WinID != -1) hWnd = WinID; else hWnd = CreateWindowEx(vidmode?WS_EX_TOPMOST:0, - "MPlayer - The Movie Player","",(vidmode)?WS_POPUP:WS_OVERLAPPEDWINDOW| WS_SIZEBOX, + WNDCLASSNAME_WINDOWED,"",(vidmode)?WS_POPUP:WS_OVERLAPPEDWINDOW| WS_SIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, 100, 100,NULL,NULL,hInstance,NULL); - wc.hbrBackground = CreateSolidBrush(RGB(0,0,0)); - wc.lpszClassName = "MPlayer - Fullscreen"; + wc.hbrBackground = blackbrush; + wc.lpszClassName = WNDCLASSNAME_FULLSCREEN; RegisterClass(&wc); + mp_msg(MSGT_VO, MSGL_DBG3,"window classes registered\n"); if (Directx_InitDirectDraw()!= 0)return 1; //init DirectDraw - if(!vidmode)hWndFS = CreateWindow("MPlayer - Fullscreen","MPlayer Fullscreen",WS_POPUP,monitor_rect.left,monitor_rect.top,monitor_rect.right-monitor_rect.left,monitor_rect.bottom-monitor_rect.top,hWnd,NULL,hInstance,NULL); + if(!vidmode)hWndFS = CreateWindow(WNDCLASSNAME_FULLSCREEN,"MPlayer Fullscreen",WS_POPUP,monitor_rect.left,monitor_rect.top,monitor_rect.right-monitor_rect.left,monitor_rect.bottom-monitor_rect.top,hWnd,NULL,hInstance,NULL); mp_msg(MSGT_VO, MSGL_DBG3 ,"initial mplayer windows created\n"); if (Directx_CheckPrimaryPixelformat()!=0)return 1;