Allow use of old fullscreen mode on macOS by setting I_WANT_BUGGY_FULLSCREEN=1

This commit is contained in:
Cameron Gutman 2024-06-09 15:46:24 -05:00
parent b59de38e0b
commit d7bc735edc

View File

@ -566,43 +566,45 @@ Session::Session(NvComputer* computer, NvApp& app, StreamingPreferences *prefere
bool Session::initialize() bool Session::initialize()
{ {
#ifdef Q_OS_DARWIN #ifdef Q_OS_DARWIN
// If we have a notch and the user specified one of the two native display modes if (qEnvironmentVariableIntValue("I_WANT_BUGGY_FULLSCREEN") == 0) {
// (notched or notchless), override the fullscreen mode to ensure it works as expected. // If we have a notch and the user specified one of the two native display modes
// - SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES=0 will place the video underneath the notch // (notched or notchless), override the fullscreen mode to ensure it works as expected.
// - SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES=1 will place the video below the notch // - SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES=0 will place the video underneath the notch
bool shouldUseFullScreenSpaces = m_Preferences->windowMode != StreamingPreferences::WM_FULLSCREEN; // - SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES=1 will place the video below the notch
SDL_DisplayMode desktopMode; bool shouldUseFullScreenSpaces = m_Preferences->windowMode != StreamingPreferences::WM_FULLSCREEN;
SDL_Rect safeArea; SDL_DisplayMode desktopMode;
for (int displayIndex = 0; StreamUtils::getNativeDesktopMode(displayIndex, &desktopMode, &safeArea); displayIndex++) { SDL_Rect safeArea;
// Check if this display has a notch (safeArea != desktopMode) for (int displayIndex = 0; StreamUtils::getNativeDesktopMode(displayIndex, &desktopMode, &safeArea); displayIndex++) {
if (desktopMode.h != safeArea.h || desktopMode.w != safeArea.w) { // Check if this display has a notch (safeArea != desktopMode)
// Check if we're trying to stream at the full native resolution (including notch) if (desktopMode.h != safeArea.h || desktopMode.w != safeArea.w) {
if (m_Preferences->width == desktopMode.w && m_Preferences->height == desktopMode.h) { // Check if we're trying to stream at the full native resolution (including notch)
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, if (m_Preferences->width == desktopMode.w && m_Preferences->height == desktopMode.h) {
"Overriding default fullscreen mode for native fullscreen resolution"); SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
shouldUseFullScreenSpaces = false; "Overriding default fullscreen mode for native fullscreen resolution");
break; shouldUseFullScreenSpaces = false;
} break;
else if (m_Preferences->width == safeArea.w && m_Preferences->height == safeArea.h) { }
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, else if (m_Preferences->width == safeArea.w && m_Preferences->height == safeArea.h) {
"Overriding default fullscreen mode for native safe area resolution"); SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
shouldUseFullScreenSpaces = true; "Overriding default fullscreen mode for native safe area resolution");
break; shouldUseFullScreenSpaces = true;
break;
}
} }
} }
}
// Using modesetting on modern versions of macOS is extremely unreliable // Using modesetting on modern versions of macOS is extremely unreliable
// and leads to hangs, deadlocks, and other nasty stuff. The only time // and leads to hangs, deadlocks, and other nasty stuff. The only time
// people seem to use it is to get the full screen on notched Macs, // people seem to use it is to get the full screen on notched Macs,
// which setting SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES=1 also accomplishes // which setting SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES=1 also accomplishes
// with much less headache. // with much less headache.
// //
// https://github.com/moonlight-stream/moonlight-qt/issues/973 // https://github.com/moonlight-stream/moonlight-qt/issues/973
// https://github.com/moonlight-stream/moonlight-qt/issues/999 // https://github.com/moonlight-stream/moonlight-qt/issues/999
// https://github.com/moonlight-stream/moonlight-qt/issues/1211 // https://github.com/moonlight-stream/moonlight-qt/issues/1211
// https://github.com/moonlight-stream/moonlight-qt/issues/1218 // https://github.com/moonlight-stream/moonlight-qt/issues/1218
SDL_SetHint(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, shouldUseFullScreenSpaces ? "1" : "0"); SDL_SetHint(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, shouldUseFullScreenSpaces ? "1" : "0");
}
#endif #endif
if (SDL_InitSubSystem(SDL_INIT_VIDEO) != 0) { if (SDL_InitSubSystem(SDL_INIT_VIDEO) != 0) {
@ -790,8 +792,13 @@ bool Session::initialize()
// Fall-through // Fall-through
case StreamingPreferences::WM_FULLSCREEN: case StreamingPreferences::WM_FULLSCREEN:
#ifdef Q_OS_DARWIN #ifdef Q_OS_DARWIN
// Don't use "real" fullscreen on macOS. See comments above. if (qEnvironmentVariableIntValue("I_WANT_BUGGY_FULLSCREEN") == 0) {
m_FullScreenFlag = SDL_WINDOW_FULLSCREEN_DESKTOP; // Don't use "real" fullscreen on macOS by default. See comments above.
m_FullScreenFlag = SDL_WINDOW_FULLSCREEN_DESKTOP;
}
else {
m_FullScreenFlag = SDL_WINDOW_FULLSCREEN;
}
#else #else
m_FullScreenFlag = SDL_WINDOW_FULLSCREEN; m_FullScreenFlag = SDL_WINDOW_FULLSCREEN;
#endif #endif