📄 wingdi.c
字号:
* CloseVideo: deactivate the GDI video output *****************************************************************************/static void CloseVideo ( vlc_object_t *p_this ){ vout_thread_t * p_vout = (vout_thread_t *)p_this; if( p_vout->p_sys->p_event ) { vlc_object_detach( p_vout->p_sys->p_event ); /* Kill Vout EventThread */ vlc_object_kill( p_vout->p_sys->p_event ); /* we need to be sure Vout EventThread won't stay stuck in * GetMessage, so we send a fake message */ if( p_vout->p_sys->hwnd ) { PostMessage( p_vout->p_sys->hwnd, WM_NULL, 0, 0); } vlc_thread_join( p_vout->p_sys->p_event ); vlc_object_release( p_vout->p_sys->p_event ); } vlc_mutex_destroy( &p_vout->p_sys->lock );#ifndef UNDER_CE /* restore screensaver system settings */ if( 0 != p_vout->p_sys->i_spi_lowpowertimeout ) { SystemParametersInfo(SPI_SETLOWPOWERTIMEOUT, p_vout->p_sys->i_spi_lowpowertimeout, NULL, 0); } if( 0 != p_vout->p_sys->i_spi_powerofftimeout ) { SystemParametersInfo(SPI_SETPOWEROFFTIMEOUT, p_vout->p_sys->i_spi_powerofftimeout, NULL, 0); } if( 0 != p_vout->p_sys->i_spi_screensavetimeout ) { SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, p_vout->p_sys->i_spi_screensavetimeout, NULL, 0); }#endif#ifdef MODULE_NAME_IS_wingapi FreeLibrary( p_vout->p_sys->gapi_dll );#endif if( p_vout->p_sys ) { free( p_vout->p_sys ); p_vout->p_sys = NULL; }}/***************************************************************************** * Init: initialize video thread output method *****************************************************************************/static int Init( vout_thread_t *p_vout ){ picture_t *p_pic; /* Initialize offscreen buffer */ InitBuffers( p_vout ); p_vout->p_sys->rect_display.left = 0; p_vout->p_sys->rect_display.top = 0; p_vout->p_sys->rect_display.right = GetSystemMetrics(SM_CXSCREEN); p_vout->p_sys->rect_display.bottom = GetSystemMetrics(SM_CYSCREEN); I_OUTPUTPICTURES = 0; /* Initialize the output structure */ switch( p_vout->p_sys->i_depth ) { case 8: p_vout->output.i_chroma = VLC_FOURCC('R','G','B','2'); p_vout->output.pf_setpalette = SetPalette; break; case 15: p_vout->output.i_chroma = VLC_FOURCC('R','V','1','5'); p_vout->output.i_rmask = 0x7c00; p_vout->output.i_gmask = 0x03e0; p_vout->output.i_bmask = 0x001f; break; case 16: p_vout->output.i_chroma = VLC_FOURCC('R','V','1','6'); p_vout->output.i_rmask = 0xf800; p_vout->output.i_gmask = 0x07e0; p_vout->output.i_bmask = 0x001f; break; case 24: p_vout->output.i_chroma = VLC_FOURCC('R','V','2','4'); p_vout->output.i_rmask = 0x00ff0000; p_vout->output.i_gmask = 0x0000ff00; p_vout->output.i_bmask = 0x000000ff; break; case 32: p_vout->output.i_chroma = VLC_FOURCC('R','V','3','2'); p_vout->output.i_rmask = 0x00ff0000; p_vout->output.i_gmask = 0x0000ff00; p_vout->output.i_bmask = 0x000000ff; break; default: msg_Err( p_vout, "screen depth %i not supported", p_vout->p_sys->i_depth ); return VLC_EGENERIC; break; } p_pic = &p_vout->p_picture[0];#ifdef MODULE_NAME_IS_wingapi p_vout->output.i_width = 0; p_vout->output.i_height = 0; p_pic->pf_lock = GAPILockSurface; p_pic->pf_unlock = GAPIUnlockSurface; Manage( p_vout ); GAPILockSurface( p_vout, p_pic ); p_vout->i_changes = 0; p_vout->output.i_width = p_vout->p_sys->render_width; p_vout->output.i_height = p_vout->p_sys->render_height;#else p_vout->output.i_width = p_vout->render.i_width; p_vout->output.i_height = p_vout->render.i_height; p_vout->fmt_out = p_vout->fmt_in; p_vout->fmt_out.i_chroma = p_vout->output.i_chroma;#endif p_vout->output.i_aspect = p_vout->render.i_aspect; p_pic->p->p_pixels = p_vout->p_sys->p_pic_buffer; p_pic->p->i_lines = p_vout->output.i_height; p_pic->p->i_visible_lines = p_vout->output.i_height; p_pic->p->i_pitch = p_vout->p_sys->i_pic_pitch; p_pic->p->i_pixel_pitch = p_vout->p_sys->i_pic_pixel_pitch; p_pic->p->i_visible_pitch = p_vout->output.i_width * p_pic->p->i_pixel_pitch; p_pic->i_planes = 1; p_pic->i_status = DESTROYED_PICTURE; p_pic->i_type = DIRECT_PICTURE; PP_OUTPUTPICTURE[ I_OUTPUTPICTURES++ ] = p_pic; /* Change the window title bar text */ PostMessage( p_vout->p_sys->hwnd, WM_VLC_CHANGE_TEXT, 0, 0 ); UpdateRects( p_vout, true ); return VLC_SUCCESS;}/***************************************************************************** * End: terminate video thread output method *****************************************************************************/static void End( vout_thread_t *p_vout ){#ifdef MODULE_NAME_IS_wingapi GXCloseDisplay();#else DeleteDC( p_vout->p_sys->off_dc ); DeleteObject( p_vout->p_sys->off_bitmap );#endif}/***************************************************************************** * Manage: handle events ***************************************************************************** * This function should be called regularly by video output thread. It manages * console events. It returns a non null value on error. *****************************************************************************/static int Manage( vout_thread_t *p_vout ){ /* If we do not control our window, we check for geometry changes * ourselves because the parent might not send us its events. */ vlc_mutex_lock( &p_vout->p_sys->lock ); if( p_vout->p_sys->hparent && !p_vout->b_fullscreen ) { RECT rect_parent; POINT point; vlc_mutex_unlock( &p_vout->p_sys->lock ); GetClientRect( p_vout->p_sys->hparent, &rect_parent ); point.x = point.y = 0; ClientToScreen( p_vout->p_sys->hparent, &point ); OffsetRect( &rect_parent, point.x, point.y ); if( !EqualRect( &rect_parent, &p_vout->p_sys->rect_parent ) ) { int i_x, i_y, i_width, i_height; p_vout->p_sys->rect_parent = rect_parent; /* This one is to force the update even if only * the position has changed */ SetWindowPos( p_vout->p_sys->hwnd, 0, 1, 1, rect_parent.right - rect_parent.left, rect_parent.bottom - rect_parent.top, 0 ); SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0, rect_parent.right - rect_parent.left, rect_parent.bottom - rect_parent.top, 0 ); vout_PlacePicture( p_vout, rect_parent.right - rect_parent.left, rect_parent.bottom - rect_parent.top, &i_x, &i_y, &i_width, &i_height ); SetWindowPos( p_vout->p_sys->hvideownd, HWND_TOP, i_x, i_y, i_width, i_height, 0 ); } } else { vlc_mutex_unlock( &p_vout->p_sys->lock ); } /* Check for cropping / aspect changes */ if( p_vout->i_changes & VOUT_CROP_CHANGE || p_vout->i_changes & VOUT_ASPECT_CHANGE ) { p_vout->i_changes &= ~VOUT_CROP_CHANGE; p_vout->i_changes &= ~VOUT_ASPECT_CHANGE; p_vout->fmt_out.i_x_offset = p_vout->fmt_in.i_x_offset; p_vout->fmt_out.i_y_offset = p_vout->fmt_in.i_y_offset; p_vout->fmt_out.i_visible_width = p_vout->fmt_in.i_visible_width; p_vout->fmt_out.i_visible_height = p_vout->fmt_in.i_visible_height; p_vout->fmt_out.i_aspect = p_vout->fmt_in.i_aspect; p_vout->fmt_out.i_sar_num = p_vout->fmt_in.i_sar_num; p_vout->fmt_out.i_sar_den = p_vout->fmt_in.i_sar_den; p_vout->output.i_aspect = p_vout->fmt_in.i_aspect; UpdateRects( p_vout, true ); } /* * Position Change */ if( p_vout->p_sys->i_changes & DX_POSITION_CHANGE ) { p_vout->p_sys->i_changes &= ~DX_POSITION_CHANGE; } /* We used to call the Win32 PeekMessage function here to read the window * messages. But since window can stay blocked into this function for a * long time (for example when you move your window on the screen), I * decided to isolate PeekMessage in another thread. */ /* * Fullscreen change */ if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE || p_vout->p_sys->i_changes & VOUT_FULLSCREEN_CHANGE ) { Win32ToggleFullscreen( p_vout ); p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE; p_vout->p_sys->i_changes &= ~VOUT_FULLSCREEN_CHANGE; } /* * Pointer change */ if( p_vout->b_fullscreen && !p_vout->p_sys->b_cursor_hidden && (mdate() - p_vout->p_sys->i_lastmoved) > p_vout->p_sys->i_mouse_hide_timeout ) { POINT point; HWND hwnd; /* Hide the cursor only if it is inside our window */ GetCursorPos( &point ); hwnd = WindowFromPoint(point); if( hwnd == p_vout->p_sys->hwnd || hwnd == p_vout->p_sys->hvideownd ) { PostMessage( p_vout->p_sys->hwnd, WM_VLC_HIDE_MOUSE, 0, 0 ); } else { p_vout->p_sys->i_lastmoved = mdate(); } } /* * "Always on top" status change */ if( p_vout->p_sys->b_on_top_change ) { vlc_value_t val; HMENU hMenu = GetSystemMenu( p_vout->p_sys->hwnd, FALSE ); var_Get( p_vout, "video-on-top", &val ); /* Set the window on top if necessary */ if( val.b_bool && !( GetWindowLong( p_vout->p_sys->hwnd, GWL_EXSTYLE ) & WS_EX_TOPMOST ) ) { CheckMenuItem( hMenu, IDM_TOGGLE_ON_TOP, MF_BYCOMMAND | MFS_CHECKED ); SetWindowPos( p_vout->p_sys->hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE ); } else /* The window shouldn't be on top */ if( !val.b_bool && ( GetWindowLong( p_vout->p_sys->hwnd, GWL_EXSTYLE ) & WS_EX_TOPMOST ) ) { CheckMenuItem( hMenu, IDM_TOGGLE_ON_TOP, MF_BYCOMMAND | MFS_UNCHECKED ); SetWindowPos( p_vout->p_sys->hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE ); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -