⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 events.c

📁 VLC Player Source Code
💻 C
📖 第 1 页 / 共 3 页
字号:
        ** with colorkey.        ** For non-overlay, vout will paint the whole window at        ** regular interval, therefore dirty regions can be ignored        ** to minimize repaint.        */            if( !p_vout->p_sys->b_using_overlay )            {                ValidateRect(hwnd, NULL);            }            // fall through to default#else        /*        ** For OpenGL and Direct3D, vout will update the whole        ** window at regular interval, therefore dirty region        ** can be ignored to minimize repaint.        */        case WM_ERASEBKGND:            /* nothing to erase */            return 1;        case WM_PAINT:            /* nothing to repaint */            ValidateRect(hwnd, NULL);            // fall through#endif        default:            return DefWindowProc(hwnd, message, wParam, lParam);        }    }    switch( message )    {    case WM_WINDOWPOSCHANGED:        UpdateRects( p_vout, true );        return 0;    /* the user wants to close the window */    case WM_CLOSE:    {        playlist_t * p_playlist = pl_Yield( p_vout );        if( p_playlist )        {            playlist_Stop( p_playlist );            pl_Release( p_vout );        }        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_PAINT:    case WM_NCPAINT:    case WM_ERASEBKGND:        return DefWindowProc(hwnd, message, wParam, lParam);    case WM_KILLFOCUS:#ifdef MODULE_NAME_IS_wingapi        p_vout->p_sys->b_focus = false;        if( !p_vout->p_sys->b_parent_focus ) GXSuspend();#endif#ifdef UNDER_CE        if( hWnd == p_vout->p_sys->hfswnd )        {            HWND htbar = FindWindow( _T("HHTaskbar"), NULL );            ShowWindow( htbar, SW_SHOW );        }        if( !p_vout->p_sys->hparent ||            hWnd == p_vout->p_sys->hfswnd )        {            SHFullScreen( hWnd, SHFS_SHOWSIPBUTTON );        }#endif        return 0;    case WM_SETFOCUS:#ifdef MODULE_NAME_IS_wingapi        p_vout->p_sys->b_focus = true;        GXResume();#endif#ifdef UNDER_CE        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 )        {            HWND htbar = FindWindow( _T("HHTaskbar"), NULL );            ShowWindow( htbar, SW_HIDE );        }        if( !p_vout->p_sys->hparent ||            hWnd == p_vout->p_sys->hfswnd )        {            SHFullScreen( hWnd, SHFS_HIDESIPBUTTON );        }#endif        return 0;    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 },    { VK_BROWSER_BACK, KEY_BROWSER_BACK },    { VK_BROWSER_FORWARD, KEY_BROWSER_FORWARD },    { VK_BROWSER_REFRESH, KEY_BROWSER_REFRESH },    { VK_BROWSER_STOP, KEY_BROWSER_STOP },    { VK_BROWSER_SEARCH, KEY_BROWSER_SEARCH },    { VK_BROWSER_FAVORITES, KEY_BROWSER_FAVORITES },    { VK_BROWSER_HOME, KEY_BROWSER_HOME },    { VK_VOLUME_MUTE, KEY_VOLUME_MUTE },    { VK_VOLUME_DOWN, KEY_VOLUME_DOWN },    { VK_VOLUME_UP, KEY_VOLUME_UP },    { VK_MEDIA_NEXT_TRACK, KEY_MEDIA_NEXT_TRACK },    { VK_MEDIA_PREV_TRACK, KEY_MEDIA_PREV_TRACK },    { VK_MEDIA_STOP, KEY_MEDIA_STOP },    { VK_MEDIA_PLAY_PAUSE, KEY_MEDIA_PLAY_PAUSE },    { 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 ){    unsigned int *pi_width, *pi_height;    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:        /* Retrieve the window position */        point.x = point.y = 0;        ClientToScreen( p_vout->p_sys->hwnd, &point );        HWND d = 0;        if( i_query == VOUT_REPARENT ) d = (HWND)va_arg( args, int );        if( !d )        {            vlc_mutex_lock( &p_vout->p_sys->lock );            p_vout->p_sys->hparent = 0;            vlc_mutex_unlock( &p_vout->p_sys->lock );            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 );        }        else        {            vlc_mutex_lock( &p_vout->p_sys->lock );            p_vout->p_sys->hparent = d;            vlc_mutex_unlock( &p_vout->p_sys->lock );            SetParent( p_vout->p_sys->hwnd, d );            p_vout->p_sys->i_window_style = WS_CLIPCHILDREN;            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 );            /* Retrieve the parent size */            RECT  rect;            GetClientRect( d, &rect );            SetWindowPos( p_vout->p_sys->hwnd, d, point.x, point.y, rect.right, rect.bottom,                          SWP_FRAMECHANGED );        }        return vout_vaControlDefault( p_vout, i_query, args );    case VOUT_SET_STAY_ON_TOP:        if( p_vout->p_sys->hparent && !var_GetBool( p_vout, "fullscreen" ) )            return vout_ControlWindow( p_vout,                    (void *)p_vout->p_sys->hparent, i_query, args );        p_vout->p_sys->b_on_top_change = true;        return VLC_SUCCESS;#ifdef MODULE_NAME_IS_wingapi    case VOUT_SET_FOCUS:        b_bool = (bool) va_arg( args, int );        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;#endif    default:        return vout_vaControlDefault( p_vout, i_query, args );    }}/* Internal wrapper over GetWindowPlacement / SetWindowPlacement */static void SetWindowState(HWND hwnd, int nShowCmd){    WINDOWPLACEMENT window_placement;    window_placement.length = sizeof(WINDOWPLACEMENT);    GetWindowPlacement( hwnd, &window_placement );    window_placement.showCmd = nShowCmd;    SetWindowPlacement( hwnd, &window_placement );    SetWindowPos( hwnd, 0, 0, 0, 0, 0,        SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED);}/* Internal wrapper to call vout_ControlWindow for hparent */static void ControlParentWindow( vout_thread_t *p_vout, int i_query, ... ){    va_list args;    va_start( args, i_query );    vout_ControlWindow( p_vout,        (void *)p_vout->p_sys->hparent, i_query, args );    va_end( args );}void Win32ToggleFullscreen( vout_thread_t *p_vout ){    HWND hwnd = (p_vout->p_sys->hparent && p_vout->p_sys->hfswnd) ?        p_vout->p_sys->hfswnd : p_vout->p_sys->hwnd;    p_vout->b_fullscreen = ! p_vout->b_fullscreen;    if( p_vout->b_fullscreen )    {        msg_Dbg( p_vout, "entering fullscreen mode" );        /* Change window style, no borders and no title bar */        int i_style = WS_CLIPCHILDREN | WS_VISIBLE;        SetWindowLong( hwnd, GWL_STYLE, i_style );        if( p_vout->p_sys->hparent )        {            /* Retrieve current window position so fullscreen will happen            * on the right screen */            POINT point = {0,0};            RECT rect;            ClientToScreen( p_vout->p_sys->hwnd, &point );            GetClientRect( p_vout->p_sys->hwnd, &rect );            SetWindowPos( hwnd, 0, point.x, point.y,                          rect.right, rect.bottom,                          SWP_NOZORDER|SWP_FRAMECHANGED );        }        /* Maximize window */        SetWindowState( hwnd, SW_SHOWMAXIMIZED );        if( p_vout->p_sys->hparent )        {            RECT rect;            GetClientRect( hwnd, &rect );            SetParent( p_vout->p_sys->hwnd, hwnd );            SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,                          rect.right, rect.bottom,                          SWP_NOZORDER|SWP_FRAMECHANGED );            HWND topLevelParent = GetAncestor( p_vout->p_sys->hparent, GA_ROOT );            ShowWindow( topLevelParent, SW_HIDE );        }        SetForegroundWindow( hwnd );    }    else    {        msg_Dbg( p_vout, "leaving fullscreen mode" );        /* Change window style, no borders and no title bar */        SetWindowLong( hwnd, GWL_STYLE, p_vout->p_sys->i_window_style );        /* Normal window */        SetWindowState( hwnd, SW_SHOWNORMAL );        if( p_vout->p_sys->hparent )        {            RECT rect;            GetClientRect( p_vout->p_sys->hparent, &rect );            SetParent( p_vout->p_sys->hwnd, p_vout->p_sys->hparent );            SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,                          rect.right, rect.bottom,                          SWP_NOZORDER|SWP_FRAMECHANGED );            HWND topLevelParent = GetAncestor( p_vout->p_sys->hparent, GA_ROOT );            ShowWindow( topLevelParent, SW_SHOW );            SetForegroundWindow( p_vout->p_sys->hparent );            ShowWindow( hwnd, SW_HIDE );        }        /* Make sure the mouse cursor is displayed */        PostMessage( p_vout->p_sys->hwnd, WM_VLC_SHOW_MOUSE, 0, 0 );    }    vlc_value_t val;    /* Update the object variable and trigger callback */    val.b_bool = p_vout->b_fullscreen;    var_Set( p_vout, "fullscreen", val );}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -