📄 wingdi.c
字号:
#endif /* The destination coordinates need to be relative to the current * directdraw primary surface (display) */ rect_dest_clipped.left -= p_vout->p_sys->rect_display.left; rect_dest_clipped.right -= p_vout->p_sys->rect_display.left; rect_dest_clipped.top -= p_vout->p_sys->rect_display.top; rect_dest_clipped.bottom -= p_vout->p_sys->rect_display.top; /* Signal the change in size/position */ p_vout->p_sys->i_changes |= DX_POSITION_CHANGE;#undef rect_src#undef rect_src_clipped#undef rect_dest#undef rect_dest_clipped}/***************************************************************************** * Message handler for the main window *****************************************************************************/static long FAR PASCAL WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ){ vout_thread_t *p_vout; if( message == WM_CREATE ) { /* Store p_vout for future use */ p_vout = (vout_thread_t *)((CREATESTRUCT *)lParam)->lpCreateParams; SetWindowLongPtr( hWnd, GWLP_USERDATA, (LONG_PTR)p_vout ); if( p_vout ) msg_Dbg( p_vout, "create: %p", hWnd ); } else { p_vout = (vout_thread_t *)GetWindowLongPtr( hWnd, GWLP_USERDATA ); }#ifndef UNDER_CE /* Catch the screensaver and the monitor turn-off */ if( message == WM_SYSCOMMAND && ( (wParam & 0xFFF0) == SC_SCREENSAVE || (wParam & 0xFFF0) == SC_MONITORPOWER ) ) { //if( p_vout ) msg_Dbg( p_vout, "WinProc WM_SYSCOMMAND screensaver" ); return 0; /* this stops them from happening */ }#endif if( !p_vout ) { /* Hmmm mozilla does manage somehow to save the pointer to our * windowproc and still calls it after the vout has been closed. */ return DefWindowProc(hWnd, message, wParam, lParam); } if( hWnd != p_vout->p_sys->hwnd && hWnd != p_vout->p_sys->hfswnd && hWnd != p_vout->p_sys->hvideownd ) return DefWindowProc(hWnd, message, wParam, lParam); switch( message ) { case WM_WINDOWPOSCHANGED: if( hWnd == p_vout->p_sys->hwnd ) UpdateRects( p_vout, VLC_TRUE ); break;#if 0 case WM_ACTIVATE: msg_Err( p_vout, "WM_ACTIVATE: %i", wParam ); if( wParam == WA_ACTIVE || wParam == WA_CLICKACTIVE ) GXResume(); else if( wParam == WA_INACTIVE ) GXSuspend(); break;#endif case WM_KILLFOCUS: p_vout->p_sys->b_focus = VLC_FALSE; if( !p_vout->p_sys->b_parent_focus ) GXSuspend(); if( hWnd == p_vout->p_sys->hfswnd ) {#ifdef UNDER_CE HWND htbar = FindWindow( _T("HHTaskbar"), NULL ); ShowWindow( htbar, SW_SHOW );#endif } if( !p_vout->p_sys->hparent || hWnd == p_vout->p_sys->hfswnd ) { SHFullScreen( hWnd, SHFS_SHOWSIPBUTTON ); } break; case WM_SETFOCUS: p_vout->p_sys->b_focus = VLC_TRUE; GXResume(); if( p_vout->p_sys->hparent && hWnd != p_vout->p_sys->hfswnd && p_vout->b_fullscreen ) p_vout->p_sys->i_changes |= VOUT_FULLSCREEN_CHANGE; if( hWnd == p_vout->p_sys->hfswnd ) {#ifdef UNDER_CE HWND htbar = FindWindow( _T("HHTaskbar"), NULL ); ShowWindow( htbar, SW_HIDE );#endif } if( !p_vout->p_sys->hparent || hWnd == p_vout->p_sys->hfswnd ) { SHFullScreen( hWnd, SHFS_HIDESIPBUTTON ); } break; case WM_LBUTTONDOWN: p_vout->p_sys->i_changes |= VOUT_FULLSCREEN_CHANGE; break; case WM_MOUSEMOVE: break; case WM_LBUTTONUP: break; case WM_INITMENUPOPUP: p_vout->p_sys->b_video_display = VLC_FALSE; break; case WM_NOTIFY: // Redo the video display because menu can be closed // FIXME verify if p_child_window exits if( (((NMHDR *)lParam)->code) == NM_CUSTOMDRAW ) p_vout->p_sys->b_video_display = VLC_TRUE; break; /* the user wants to close the window */ case WM_CLOSE: { playlist_t * p_playlist = (playlist_t *)vlc_object_find( p_vout, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist == NULL ) return 0; playlist_Stop( p_playlist ); vlc_object_release( p_playlist ); return 0; } case WM_DESTROY: msg_Dbg( p_vout, "WinProc WM_DESTROY" ); PostQuitMessage( 0 ); break; default: return DefWindowProc( hWnd, message, wParam, lParam ); } return 0;}/***************************************************************************** * InitBuffers: initialize an offscreen bitmap for direct buffer operations. *****************************************************************************/static void InitBuffers( vout_thread_t *p_vout ){ BITMAPINFOHEADER *p_header = &p_vout->p_sys->bitmapinfo.bmiHeader; BITMAPINFO *p_info = &p_vout->p_sys->bitmapinfo; int i_pixels = p_vout->render.i_height * p_vout->render.i_width; HDC window_dc = GetDC( p_vout->p_sys->hvideownd ); /* Get screen properties */#ifdef MODULE_NAME_IS_wingapi GXDisplayProperties gx_displayprop = GXGetDisplayProperties(); p_vout->p_sys->i_depth = gx_displayprop.cBPP;#else p_vout->p_sys->i_depth = GetDeviceCaps( window_dc, PLANES ) * GetDeviceCaps( window_dc, BITSPIXEL );#endif msg_Dbg( p_vout, "GDI depth is %i", p_vout->p_sys->i_depth );#ifdef MODULE_NAME_IS_wingapi GXOpenDisplay( p_vout->p_sys->hvideownd, GX_FULLSCREEN );#else /* Initialize offscreen bitmap */ memset( p_info, 0, sizeof( BITMAPINFO ) + 3 * sizeof( RGBQUAD ) ); p_header->biSize = sizeof( BITMAPINFOHEADER ); p_header->biSizeImage = 0; p_header->biPlanes = 1; switch( p_vout->p_sys->i_depth ) { case 8: p_header->biBitCount = 8; p_header->biCompression = BI_RGB; /* FIXME: we need a palette here */ break; case 15: p_header->biBitCount = 15; p_header->biCompression = BI_BITFIELDS;//BI_RGB; ((DWORD*)p_info->bmiColors)[0] = 0x00007c00; ((DWORD*)p_info->bmiColors)[1] = 0x000003e0; ((DWORD*)p_info->bmiColors)[2] = 0x0000001f; break; case 16: p_header->biBitCount = 16; p_header->biCompression = BI_BITFIELDS;//BI_RGB; ((DWORD*)p_info->bmiColors)[0] = 0x0000f800; ((DWORD*)p_info->bmiColors)[1] = 0x000007e0; ((DWORD*)p_info->bmiColors)[2] = 0x0000001f; break; case 24: p_header->biBitCount = 24; p_header->biCompression = BI_RGB; ((DWORD*)p_info->bmiColors)[0] = 0x00ff0000; ((DWORD*)p_info->bmiColors)[1] = 0x0000ff00; ((DWORD*)p_info->bmiColors)[2] = 0x000000ff; break; case 32: p_header->biBitCount = 32; p_header->biCompression = BI_RGB; ((DWORD*)p_info->bmiColors)[0] = 0x00ff0000; ((DWORD*)p_info->bmiColors)[1] = 0x0000ff00; ((DWORD*)p_info->bmiColors)[2] = 0x000000ff; break; default: msg_Err( p_vout, "screen depth %i not supported", p_vout->p_sys->i_depth ); return; break; } p_header->biWidth = p_vout->render.i_width; p_header->biHeight = -p_vout->render.i_height; p_header->biClrImportant = 0; p_header->biClrUsed = 0; p_header->biXPelsPerMeter = 0; p_header->biYPelsPerMeter = 0; p_vout->p_sys->i_pic_pixel_pitch = p_header->biBitCount / 8; p_vout->p_sys->i_pic_pitch = p_header->biBitCount * p_header->biWidth / 8; p_vout->p_sys->off_bitmap = CreateDIBSection( window_dc, (BITMAPINFO *)p_header, DIB_RGB_COLORS, (void**)&p_vout->p_sys->p_pic_buffer, NULL, 0 ); p_vout->p_sys->off_dc = CreateCompatibleDC( window_dc ); SelectObject( p_vout->p_sys->off_dc, p_vout->p_sys->off_bitmap ); ReleaseDC( 0, window_dc );#endif}/***************************************************************************** * Control: control facility for the vout *****************************************************************************/static int Control( vout_thread_t *p_vout, int i_query, va_list args ){ unsigned int *pi_width, *pi_height; vlc_bool_t b_bool; RECT rect_window; POINT point; switch( i_query ) { case VOUT_GET_SIZE: if( p_vout->p_sys->hparent ) return vout_ControlWindow( p_vout, (void *)p_vout->p_sys->hparent, i_query, args ); pi_width = va_arg( args, unsigned int * ); pi_height = va_arg( args, unsigned int * ); GetClientRect( p_vout->p_sys->hwnd, &rect_window ); *pi_width = rect_window.right - rect_window.left; *pi_height = rect_window.bottom - rect_window.top; return VLC_SUCCESS; case VOUT_SET_SIZE: if( p_vout->p_sys->hparent ) return vout_ControlWindow( p_vout, (void *)p_vout->p_sys->hparent, i_query, args ); /* Update dimensions */ rect_window.top = rect_window.left = 0; rect_window.right = va_arg( args, unsigned int ); rect_window.bottom = va_arg( args, unsigned int ); if( !rect_window.right ) rect_window.right = p_vout->i_window_width; if( !rect_window.bottom ) rect_window.bottom = p_vout->i_window_height; AdjustWindowRect( &rect_window, p_vout->p_sys->i_window_style, 0 ); SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0, rect_window.right - rect_window.left, rect_window.bottom - rect_window.top, SWP_NOMOVE ); return VLC_SUCCESS; case VOUT_CLOSE: ShowWindow( p_vout->p_sys->hwnd, SW_HIDE ); case VOUT_REPARENT: /* Change window style, borders and title bar */ //vlc_mutex_lock( &p_vout->p_sys->lock ); p_vout->p_sys->hparent = 0; //vlc_mutex_unlock( &p_vout->p_sys->lock ); /* Retrieve the window position */ point.x = point.y = 0; ClientToScreen( p_vout->p_sys->hwnd, &point ); SetParent( p_vout->p_sys->hwnd, 0 ); p_vout->p_sys->i_window_style = WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW | WS_SIZEBOX; SetWindowLong( p_vout->p_sys->hwnd, GWL_STYLE, p_vout->p_sys->i_window_style | (i_query == VOUT_CLOSE ? 0 : WS_VISIBLE) ); SetWindowLong( p_vout->p_sys->hwnd, GWL_EXSTYLE, WS_EX_APPWINDOW ); SetWindowPos( p_vout->p_sys->hwnd, 0, point.x, point.y, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED ); return vout_vaControlDefault( p_vout, i_query, args ); case VOUT_SET_FOCUS: b_bool = va_arg( args, vlc_bool_t ); p_vout->p_sys->b_parent_focus = b_bool; if( b_bool ) GXResume(); else if( !p_vout->p_sys->b_focus ) GXSuspend(); return VLC_SUCCESS; default: return vout_vaControlDefault( p_vout, i_query, args ); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -