mirror of
https://github.com/moonlight-stream/moonlight-qt
synced 2024-11-15 07:57:19 +00:00
Fix excessive flickering when switching between full-screen and windowed on Windows
This commit is contained in:
parent
3e330b7929
commit
9ab4479fcf
1 changed files with 14 additions and 1 deletions
|
@ -1068,6 +1068,17 @@ void Session::toggleFullscreen()
|
|||
{
|
||||
bool fullScreen = !(SDL_GetWindowFlags(m_Window) & m_FullScreenFlag);
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
// Destroy the video decoder before toggling full-screen because D3D9 can try
|
||||
// to put the window back into full-screen before we've managed to destroy
|
||||
// the renderer. This leads to excessive flickering and can cause the window
|
||||
// decorations to get messed up as SDL and D3D9 fight over the window style.
|
||||
SDL_AtomicLock(&m_DecoderLock);
|
||||
delete m_VideoDecoder;
|
||||
m_VideoDecoder = nullptr;
|
||||
SDL_AtomicUnlock(&m_DecoderLock);
|
||||
#endif
|
||||
|
||||
if (fullScreen) {
|
||||
SDL_SetWindowResizable(m_Window, SDL_FALSE);
|
||||
SDL_SetWindowFullscreen(m_Window, m_FullScreenFlag);
|
||||
|
@ -1543,7 +1554,9 @@ void Session::execInternal()
|
|||
case SDL_USEREVENT:
|
||||
switch (event.user.code) {
|
||||
case SDL_CODE_FRAME_READY:
|
||||
m_VideoDecoder->renderFrameOnMainThread();
|
||||
if (m_VideoDecoder != nullptr) {
|
||||
m_VideoDecoder->renderFrameOnMainThread();
|
||||
}
|
||||
break;
|
||||
case SDL_CODE_HIDE_CURSOR:
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
|
|
Loading…
Reference in a new issue