📄 events.c
字号:
rect_dest_clipped.left, rect_dest_clipped.top, rect_dest_clipped.right, rect_dest_clipped.bottom );#endif /* the 2 following lines are to fix a bug when clicking on the desktop */ if( (rect_dest_clipped.right - rect_dest_clipped.left)==0 || (rect_dest_clipped.bottom - rect_dest_clipped.top)==0 ) { SetRectEmpty( &rect_src_clipped ); return; } /* src image dimensions */ rect_src.left = 0; rect_src.top = 0; rect_src.right = p_vout->render.i_width; rect_src.bottom = p_vout->render.i_height; /* Clip the source image */ rect_src_clipped.left = (rect_dest_clipped.left - rect_dest.left) * p_vout->render.i_width / (rect_dest.right - rect_dest.left); rect_src_clipped.right = p_vout->render.i_width - (rect_dest.right - rect_dest_clipped.right) * p_vout->render.i_width / (rect_dest.right - rect_dest.left); rect_src_clipped.top = (rect_dest_clipped.top - rect_dest.top) * p_vout->render.i_height / (rect_dest.bottom - rect_dest.top); rect_src_clipped.bottom = p_vout->render.i_height - (rect_dest.bottom - rect_dest_clipped.bottom) * p_vout->render.i_height / (rect_dest.bottom - rect_dest.top); /* Apply overlay hardware constraints */ if( p_vout->p_sys->b_using_overlay ) { if( p_vout->p_sys->i_align_src_boundary ) rect_src_clipped.left = ( rect_src_clipped.left + p_vout->p_sys->i_align_src_boundary / 2 ) & ~p_vout->p_sys->i_align_src_boundary; if( p_vout->p_sys->i_align_src_size ) rect_src_clipped.right = (( rect_src_clipped.right - rect_src_clipped.left + p_vout->p_sys->i_align_src_size / 2 ) & ~p_vout->p_sys->i_align_src_size) + rect_src_clipped.left; }#if 0 msg_Dbg( p_vout, "DirectXUpdateRects image_src_clipped" " coords: %i,%i,%i,%i", rect_src_clipped.left, rect_src_clipped.top, rect_src_clipped.right, rect_src_clipped.bottom );#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; if( p_vout->p_sys->b_using_overlay ) E_(DirectXUpdateOverlay)( p_vout ); /* 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}/***************************************************************************** * DirectXEventProc: This is the window event processing function. ***************************************************************************** * On Windows, when you create a window you have to attach an event processing * function to it. The aim of this function is to manage "Queued Messages" and * "Nonqueued Messages". * Queued Messages are those picked up and retransmitted by vout_Manage * (using the GetMessage and DispatchMessage functions). * Nonqueued Messages are those that Windows will send directly to this * procedure (like WM_DESTROY, WM_WINDOWPOSCHANGED...) *****************************************************************************/static long FAR PASCAL DirectXEventProc( 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 ); } else { p_vout = (vout_thread_t *)GetWindowLongPtr( hwnd, GWLP_USERDATA ); } /* Catch the screensaver and the monitor turn-off */ if( message == WM_SYSCOMMAND && ( wParam == SC_SCREENSAVE || wParam == SC_MONITORPOWER ) ) { //if( p_vout ) msg_Dbg( p_vout, "WinProc WM_SYSCOMMAND screensaver" ); return 0; /* this stops them from happening */ } 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->hvideownd ) return DefWindowProc(hwnd, message, wParam, lParam); switch( message ) { case WM_WINDOWPOSCHANGED: E_(DirectXUpdateRects)( p_vout, VLC_TRUE ); return 0; /* 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; } /* the window has been closed so shut down everything now */ case WM_DESTROY: msg_Dbg( p_vout, "WinProc WM_DESTROY" ); /* just destroy the window */ PostQuitMessage( 0 ); return 0; case WM_SYSCOMMAND: switch (wParam) { case IDM_TOGGLE_ON_TOP: /* toggle the "on top" status */ { vlc_value_t val; msg_Dbg( p_vout, "WinProc WM_SYSCOMMAND: IDM_TOGGLE_ON_TOP"); /* Change the current value */ var_Get( p_vout, "video-on-top", &val ); val.b_bool = !val.b_bool; var_Set( p_vout, "video-on-top", val ); return 0; } } break; case WM_VLC_CREATE_VIDEO_WIN: /* Create video sub-window */ p_vout->p_sys->hvideownd = CreateWindow( _T("VLC DirectX video"), _T(""), /* window class */ WS_CHILD | WS_VISIBLE, /* window style */ CW_USEDEFAULT, CW_USEDEFAULT, /* default coordinates */ CW_USEDEFAULT, CW_USEDEFAULT, hwnd, /* parent window */ NULL, GetModuleHandle(NULL), (LPVOID)p_vout ); /* send p_vout to WM_CREATE */ if( !p_vout->p_sys->hvideownd ) msg_Warn( p_vout, "Can't create video sub-window" ); else msg_Dbg( p_vout, "Created video sub-window" ); break; case WM_PAINT: case WM_NCPAINT: case WM_ERASEBKGND: /* We do not want to relay these messages to the parent window * because we rely on the background color for the overlay. */ return DefWindowProc(hwnd, message, wParam, lParam); break; default: //msg_Dbg( p_vout, "WinProc WM Default %i", message ); break; } /* Let windows handle the message */ return DefWindowProc(hwnd, message, wParam, lParam);}static struct{ int i_dxkey; int i_vlckey;} dxkeys_to_vlckeys[] ={ { VK_F1, KEY_F1 }, { VK_F2, KEY_F2 }, { VK_F3, KEY_F3 }, { VK_F4, KEY_F4 }, { VK_F5, KEY_F5 }, { VK_F6, KEY_F6 }, { VK_F7, KEY_F7 }, { VK_F8, KEY_F8 }, { VK_F9, KEY_F9 }, { VK_F10, KEY_F10 }, { VK_F11, KEY_F11 }, { VK_F12, KEY_F12 }, { VK_RETURN, KEY_ENTER }, { VK_SPACE, KEY_SPACE }, { VK_ESCAPE, KEY_ESC }, { VK_LEFT, KEY_LEFT }, { VK_RIGHT, KEY_RIGHT }, { VK_UP, KEY_UP }, { VK_DOWN, KEY_DOWN }, { VK_HOME, KEY_HOME }, { VK_END, KEY_END }, { VK_PRIOR, KEY_PAGEUP }, { VK_NEXT, KEY_PAGEDOWN }, { VK_INSERT, KEY_INSERT }, { VK_DELETE, KEY_DELETE }, { VK_CONTROL, 0 }, { VK_SHIFT, 0 }, { VK_MENU, 0 }, { 0, 0 }};static int DirectXConvertKey( int i_key ){ int i; for( i = 0; dxkeys_to_vlckeys[i].i_dxkey != 0; i++ ) { if( dxkeys_to_vlckeys[i].i_dxkey == i_key ) { return dxkeys_to_vlckeys[i].i_vlckey; } } return 0;}/***************************************************************************** * Control: control facility for the vout *****************************************************************************/static int Control( vout_thread_t *p_vout, int i_query, va_list args ){ double f_arg; RECT rect_window; POINT point; switch( i_query ) { case VOUT_SET_ZOOM: if( p_vout->p_sys->hparent ) return vout_ControlWindow( p_vout, (void *)p_vout->p_sys->hparent, i_query, args ); f_arg = va_arg( args, double ); /* Update dimensions */ rect_window.top = rect_window.left = 0; rect_window.right = p_vout->i_window_width * f_arg; rect_window.bottom = p_vout->i_window_height * f_arg; 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_STAY_ON_TOP: if( p_vout->p_sys->hparent ) return vout_ControlWindow( p_vout, (void *)p_vout->p_sys->hparent, i_query, args ); p_vout->p_sys->b_on_top_change = VLC_TRUE; return VLC_SUCCESS; default: return vout_vaControlDefault( p_vout, i_query, args ); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -