mirror of
https://github.com/moonlight-stream/moonlight-qt
synced 2024-12-17 14:43:09 +00:00
Avoid white flash when starting streaming on Windows
This commit is contained in:
parent
245f242fb8
commit
e45b6b9b85
1 changed files with 35 additions and 5 deletions
|
@ -1443,12 +1443,23 @@ void Session::execInternal()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_SysWMinfo info;
|
||||||
|
SDL_VERSION(&info.version);
|
||||||
|
|
||||||
|
if (SDL_GetWindowWMInfo(m_Window, &info) && info.subsystem == SDL_SYSWM_WINDOWS) {
|
||||||
|
RECT clientRect;
|
||||||
|
HBRUSH blackBrush;
|
||||||
|
|
||||||
|
// Draw a black background (otherwise our window will be bright white).
|
||||||
|
//
|
||||||
|
// TODO: Remove when SDL does this itself
|
||||||
|
blackBrush = CreateSolidBrush(0);
|
||||||
|
GetClientRect(info.info.win.window, &clientRect);
|
||||||
|
FillRect(info.info.win.hdc, &clientRect, blackBrush);
|
||||||
|
DeleteObject(blackBrush);
|
||||||
|
|
||||||
// If dark mode is enabled, propagate that to our SDL window
|
// If dark mode is enabled, propagate that to our SDL window
|
||||||
if (darkModeEnabled) {
|
if (darkModeEnabled) {
|
||||||
SDL_SysWMinfo info;
|
|
||||||
|
|
||||||
SDL_VERSION(&info.version);
|
|
||||||
if (SDL_GetWindowWMInfo(m_Window, &info) && info.subsystem == SDL_SYSWM_WINDOWS) {
|
|
||||||
if (FAILED(DwmSetWindowAttribute(info.info.win.window, DWMWA_USE_IMMERSIVE_DARK_MODE, &darkModeEnabled, sizeof(darkModeEnabled)))) {
|
if (FAILED(DwmSetWindowAttribute(info.info.win.window, DWMWA_USE_IMMERSIVE_DARK_MODE, &darkModeEnabled, sizeof(darkModeEnabled)))) {
|
||||||
DwmSetWindowAttribute(info.info.win.window, DWMWA_USE_IMMERSIVE_DARK_MODE_OLD, &darkModeEnabled, sizeof(darkModeEnabled));
|
DwmSetWindowAttribute(info.info.win.window, DWMWA_USE_IMMERSIVE_DARK_MODE_OLD, &darkModeEnabled, sizeof(darkModeEnabled));
|
||||||
}
|
}
|
||||||
|
@ -1487,6 +1498,25 @@ void Session::execInternal()
|
||||||
// Enter full screen if requested
|
// Enter full screen if requested
|
||||||
if (m_IsFullScreen) {
|
if (m_IsFullScreen) {
|
||||||
SDL_SetWindowFullscreen(m_Window, m_FullScreenFlag);
|
SDL_SetWindowFullscreen(m_Window, m_FullScreenFlag);
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
SDL_SysWMinfo info;
|
||||||
|
SDL_VERSION(&info.version);
|
||||||
|
|
||||||
|
// Draw a black background again after entering full-screen to avoid visual artifacts
|
||||||
|
// where the old window decorations were before.
|
||||||
|
//
|
||||||
|
// TODO: Remove when SDL does this itself
|
||||||
|
if (SDL_GetWindowWMInfo(m_Window, &info) && info.subsystem == SDL_SYSWM_WINDOWS) {
|
||||||
|
RECT clientRect;
|
||||||
|
HBRUSH blackBrush;
|
||||||
|
|
||||||
|
blackBrush = CreateSolidBrush(0);
|
||||||
|
GetClientRect(info.info.win.window, &clientRect);
|
||||||
|
FillRect(info.info.win.hdc, &clientRect, blackBrush);
|
||||||
|
DeleteObject(blackBrush);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool needsFirstEnterCapture = false;
|
bool needsFirstEnterCapture = false;
|
||||||
|
|
Loading…
Reference in a new issue