mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2025-07-02 15:55:39 +00:00
Override fullscreen mode if necessary for native resolutions to work as expected
Fixes #1244
This commit is contained in:
parent
85a9f85c54
commit
0dfa8a7b53
@ -566,6 +566,32 @@ 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
|
||||||
|
// (notched or notchless), override the fullscreen mode to ensure it works as expected.
|
||||||
|
// - SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES=0 will place the video underneath the notch
|
||||||
|
// - SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES=1 will place the video below the notch
|
||||||
|
bool shouldUseFullScreenSpaces = m_Preferences->windowMode != StreamingPreferences::WM_FULLSCREEN;
|
||||||
|
SDL_DisplayMode desktopMode;
|
||||||
|
SDL_Rect safeArea;
|
||||||
|
for (int displayIndex = 0; StreamUtils::getNativeDesktopMode(displayIndex, &desktopMode, &safeArea); displayIndex++) {
|
||||||
|
// Check if this display has a notch (safeArea != desktopMode)
|
||||||
|
if (desktopMode.h != safeArea.h || desktopMode.w != safeArea.w) {
|
||||||
|
// Check if we're trying to stream at the full native resolution (including notch)
|
||||||
|
if (m_Preferences->width == desktopMode.w && m_Preferences->height == desktopMode.h) {
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Overriding default fullscreen mode for native fullscreen resolution");
|
||||||
|
shouldUseFullScreenSpaces = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (m_Preferences->width == safeArea.w && m_Preferences->height == safeArea.h) {
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Overriding default fullscreen mode for native safe area resolution");
|
||||||
|
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,
|
||||||
@ -576,8 +602,7 @@ bool Session::initialize()
|
|||||||
// 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,
|
SDL_SetHint(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, shouldUseFullScreenSpaces ? "1" : "0");
|
||||||
m_Preferences->windowMode == StreamingPreferences::WM_FULLSCREEN ? "0" : "1");
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (SDL_InitSubSystem(SDL_INIT_VIDEO) != 0) {
|
if (SDL_InitSubSystem(SDL_INIT_VIDEO) != 0) {
|
||||||
|
@ -201,9 +201,6 @@ bool StreamUtils::getNativeDesktopMode(int displayIndex, SDL_DisplayMode* mode,
|
|||||||
uint32_t displayCount = 0;
|
uint32_t displayCount = 0;
|
||||||
CGGetActiveDisplayList(MAX_DISPLAYS, displayIds, &displayCount);
|
CGGetActiveDisplayList(MAX_DISPLAYS, displayIds, &displayCount);
|
||||||
if (displayIndex >= displayCount) {
|
if (displayIndex >= displayCount) {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
|
||||||
"Too many displays: %d vs %d",
|
|
||||||
displayIndex, displayCount);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,6 +253,9 @@ bool StreamUtils::getNativeDesktopMode(int displayIndex, SDL_DisplayMode* mode,
|
|||||||
|
|
||||||
CFRelease(modeList);
|
CFRelease(modeList);
|
||||||
|
|
||||||
|
// Special case for probing for notched displays prior to video subsystem initialization
|
||||||
|
// in Session::initialize() for Darwin only!
|
||||||
|
if (SDL_WasInit(SDL_INIT_VIDEO)) {
|
||||||
// Now find the SDL mode that matches the CG native mode
|
// Now find the SDL mode that matches the CG native mode
|
||||||
for (int i = 0; i < SDL_GetNumDisplayModes(displayIndex); i++) {
|
for (int i = 0; i < SDL_GetNumDisplayModes(displayIndex); i++) {
|
||||||
SDL_DisplayMode thisMode;
|
SDL_DisplayMode thisMode;
|
||||||
@ -267,7 +267,14 @@ bool StreamUtils::getNativeDesktopMode(int displayIndex, SDL_DisplayMode* mode,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
|
SDL_assert(SDL_WasInit(SDL_INIT_VIDEO));
|
||||||
|
|
||||||
|
if (displayIndex >= SDL_GetNumVideoDisplays()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// We need to get the true display resolution without DPI scaling (since we use High DPI).
|
// We need to get the true display resolution without DPI scaling (since we use High DPI).
|
||||||
// Windows returns the real display resolution here, even if DPI scaling is enabled.
|
// Windows returns the real display resolution here, even if DPI scaling is enabled.
|
||||||
// macOS and Wayland report a resolution that includes the DPI scaling factor. Picking
|
// macOS and Wayland report a resolution that includes the DPI scaling factor. Picking
|
||||||
|
Loading…
x
Reference in New Issue
Block a user