mirror of
https://github.com/moonlight-stream/moonlight-qt
synced 2025-01-09 09:48:43 +00:00
Improve state propagation between Qt and SDL windows
This commit is contained in:
parent
75eb921a04
commit
610e07d4bd
1 changed files with 26 additions and 2 deletions
|
@ -1624,12 +1624,23 @@ void Session::execInternal()
|
||||||
// If we're starting in windowed mode and the Moonlight GUI is maximized or
|
// If we're starting in windowed mode and the Moonlight GUI is maximized or
|
||||||
// minimized, match that with the streaming window.
|
// minimized, match that with the streaming window.
|
||||||
if (!m_IsFullScreen && m_QtWindow != nullptr) {
|
if (!m_IsFullScreen && m_QtWindow != nullptr) {
|
||||||
if (m_QtWindow->windowState() & Qt::WindowMaximized) {
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
||||||
|
// Qt 5.10+ can propagate multiple states together
|
||||||
|
if (m_QtWindow->windowStates() & Qt::WindowMaximized) {
|
||||||
defaultWindowFlags |= SDL_WINDOW_MAXIMIZED;
|
defaultWindowFlags |= SDL_WINDOW_MAXIMIZED;
|
||||||
}
|
}
|
||||||
else if (m_QtWindow->windowState() & Qt::WindowMinimized) {
|
if (m_QtWindow->windowStates() & Qt::WindowMinimized) {
|
||||||
defaultWindowFlags |= SDL_WINDOW_MINIMIZED;
|
defaultWindowFlags |= SDL_WINDOW_MINIMIZED;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
// Qt 5.9 only supports a single state at a time
|
||||||
|
if (m_QtWindow->windowState() == Qt::WindowMaximized) {
|
||||||
|
defaultWindowFlags |= SDL_WINDOW_MAXIMIZED;
|
||||||
|
}
|
||||||
|
else if (m_QtWindow->windowState() == Qt::WindowMinimized) {
|
||||||
|
defaultWindowFlags |= SDL_WINDOW_MINIMIZED;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// We use only the computer name on macOS to match Apple conventions where the
|
// We use only the computer name on macOS to match Apple conventions where the
|
||||||
|
@ -2171,6 +2182,19 @@ DispatchDeferredCleanup:
|
||||||
m_VideoDecoder = nullptr;
|
m_VideoDecoder = nullptr;
|
||||||
SDL_AtomicUnlock(&m_DecoderLock);
|
SDL_AtomicUnlock(&m_DecoderLock);
|
||||||
|
|
||||||
|
// Propagate state changes from the SDL window back to the Qt window
|
||||||
|
//
|
||||||
|
// NB: We're making a conscious decision not to propagate the maximized
|
||||||
|
// or normal state of the window here. The thinking is that users may
|
||||||
|
// routinely maximize the streaming window simply to view the stream
|
||||||
|
// in a larger window, but they don't necessarily want the UI in such
|
||||||
|
// a large window.
|
||||||
|
if (!m_IsFullScreen && m_QtWindow != nullptr && m_Window != nullptr) {
|
||||||
|
if (SDL_GetWindowFlags(m_Window) & SDL_WINDOW_MINIMIZED) {
|
||||||
|
m_QtWindow->setWindowState(Qt::WindowMinimized);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// This must be called after the decoder is deleted, because
|
// This must be called after the decoder is deleted, because
|
||||||
// the renderer may want to interact with the window
|
// the renderer may want to interact with the window
|
||||||
SDL_DestroyWindow(m_Window);
|
SDL_DestroyWindow(m_Window);
|
||||||
|
|
Loading…
Reference in a new issue