From 6dab25105583e5931034ddb2bf49ef08cecb120d Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 7 Feb 2021 10:49:29 -0600 Subject: [PATCH] Don't overwrite window mode settings when switching between WM and non-WM environments --- app/gui/SettingsView.qml | 46 ++++++++++++++++++++------------------- app/streaming/session.cpp | 17 +++++++++++---- app/streaming/session.h | 1 + 3 files changed, 38 insertions(+), 26 deletions(-) diff --git a/app/gui/SettingsView.qml b/app/gui/SettingsView.qml index f3f70d12..53c99009 100644 --- a/app/gui/SettingsView.qml +++ b/app/gui/SettingsView.qml @@ -525,6 +525,11 @@ Flickable { AutoResizingComboBox { // ignore setting the index at first, and actually set it when the component is loaded Component.onCompleted: { + if (!visible) { + // Do nothing if the control won't even be visible + return + } + // Set the recommended option based on the OS for (var i = 0; i < windowModeListModel.count; i++) { var thisWm = windowModeListModel.get(i).val; @@ -537,15 +542,13 @@ Flickable { currentIndex = 0 - if (SystemProperties.hasWindowManager && !SystemProperties.rendererAlwaysFullScreen) { - var savedWm = StreamingPreferences.windowMode - for (var i = 0; i < windowModeListModel.count; i++) { - var thisWm = windowModeListModel.get(i).val; - if (savedWm === thisWm) { - currentIndex = i - break - } - } + var savedWm = StreamingPreferences.windowMode + for (var i = 0; i < windowModeListModel.count; i++) { + var thisWm = windowModeListModel.get(i).val; + if (savedWm === thisWm) { + currentIndex = i + break + } } activated(currentIndex) @@ -792,20 +795,19 @@ Flickable { AutoResizingComboBox { // ignore setting the index at first, and actually set it when the component is loaded Component.onCompleted: { - if (SystemProperties.hasWindowManager) { - var saved_uidisplaymode = StreamingPreferences.uiDisplayMode - currentIndex = 0 - for (var i = 0; i < uiDisplayModeListModel.count; i++) { - var el_uidisplaymode = uiDisplayModeListModel.get(i).val; - if (saved_uidisplaymode === el_uidisplaymode) { - currentIndex = i - break - } - } + if (!visible) { + // Do nothing if the control won't even be visible + return } - else { - // Full-screen is always selected when there is no window manager - currentIndex = 2 + + var saved_uidisplaymode = StreamingPreferences.uiDisplayMode + currentIndex = 0 + for (var i = 0; i < uiDisplayModeListModel.count; i++) { + var el_uidisplaymode = uiDisplayModeListModel.get(i).val; + if (saved_uidisplaymode === el_uidisplaymode) { + currentIndex = i + break + } } activated(currentIndex) diff --git a/app/streaming/session.cpp b/app/streaming/session.cpp index f19d89e4..ff1121dd 100644 --- a/app/streaming/session.cpp +++ b/app/streaming/session.cpp @@ -340,6 +340,10 @@ bool Session::populateDecoderProperties(SDL_Window* window) m_StreamConfig.colorSpace = decoder->getDecoderColorspace(); + if (decoder->isAlwaysFullScreen()) { + m_IsFullScreen = true; + } + delete decoder; return true; @@ -347,6 +351,7 @@ bool Session::populateDecoderProperties(SDL_Window* window) Session::Session(NvComputer* computer, NvApp& app, StreamingPreferences *preferences) : m_Preferences(preferences ? preferences : new StreamingPreferences(this)), + m_IsFullScreen(m_Preferences->windowMode != StreamingPreferences::WM_WINDOWED || !WMUtils::isRunningWindowManager()), m_Computer(computer), m_App(app), m_Window(nullptr), @@ -506,8 +511,12 @@ bool Session::initialize() { default: case StreamingPreferences::WM_FULLSCREEN_DESKTOP: - m_FullScreenFlag = SDL_WINDOW_FULLSCREEN_DESKTOP; - break; + // Only use full-screen desktop mode if we're running a window manager + if (WMUtils::isRunningWindowManager()) { + m_FullScreenFlag = SDL_WINDOW_FULLSCREEN_DESKTOP; + break; + } + // Fall-through case StreamingPreferences::WM_FULLSCREEN: m_FullScreenFlag = SDL_WINDOW_FULLSCREEN; break; @@ -817,7 +826,7 @@ void Session::getWindowDimensions(int& x, int& y, } } - fullScreen = (m_Preferences->windowMode != StreamingPreferences::WM_WINDOWED); + fullScreen = m_IsFullScreen; } SDL_Rect usableBounds; @@ -1212,7 +1221,7 @@ void Session::exec(int displayOriginX, int displayOriginY) // For non-full screen windows, call getWindowDimensions() // again after creating a window to allow it to account // for window chrome size. - if (m_Preferences->windowMode == StreamingPreferences::WM_WINDOWED) { + if (!m_IsFullScreen) { getWindowDimensions(x, y, width, height); // We must set the size before the position because centering diff --git a/app/streaming/session.h b/app/streaming/session.h index f372a651..b30952ae 100644 --- a/app/streaming/session.h +++ b/app/streaming/session.h @@ -133,6 +133,7 @@ private: int drSubmitDecodeUnit(PDECODE_UNIT du); StreamingPreferences* m_Preferences; + bool m_IsFullScreen; STREAM_CONFIGURATION m_StreamConfig; DECODER_RENDERER_CALLBACKS m_VideoCallbacks; AUDIO_RENDERER_CALLBACKS m_AudioCallbacks;