mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2025-07-01 15:26:09 +00:00
Abstract window creation into compat function
This commit is contained in:
parent
a37020b974
commit
d1f3b98a1f
@ -232,3 +232,21 @@ void SDLC_LeaveFullscreen(SDL_Window* window)
|
|||||||
{
|
{
|
||||||
SDL_SetWindowFullscreen(window, 0);
|
SDL_SetWindowFullscreen(window, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_Window* SDLC_CreateWindowWithFallback(const char *title,
|
||||||
|
int x, int y, int w, int h,
|
||||||
|
Uint32 requiredFlags,
|
||||||
|
Uint32 optionalFlags)
|
||||||
|
{
|
||||||
|
SDL_Window* window = SDL_CreateWindow(title, x, y, w, h, requiredFlags | optionalFlags);
|
||||||
|
if (!window) {
|
||||||
|
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Failed to create window with optional flags: %s",
|
||||||
|
SDL_GetError());
|
||||||
|
|
||||||
|
// Try the fallback flags now
|
||||||
|
window = SDL_CreateWindow(title, x, y, w, h, requiredFlags);
|
||||||
|
}
|
||||||
|
|
||||||
|
return window;
|
||||||
|
}
|
||||||
|
@ -97,6 +97,11 @@ bool SDLC_IsFullscreenDesktop(SDL_Window* window);
|
|||||||
void SDLC_EnterFullscreen(SDL_Window* window, bool exclusive);
|
void SDLC_EnterFullscreen(SDL_Window* window, bool exclusive);
|
||||||
void SDLC_LeaveFullscreen(SDL_Window* window);
|
void SDLC_LeaveFullscreen(SDL_Window* window);
|
||||||
|
|
||||||
|
SDL_Window* SDLC_CreateWindowWithFallback(const char *title,
|
||||||
|
int x, int y, int w, int h,
|
||||||
|
Uint32 requiredFlags,
|
||||||
|
Uint32 optionalFlags);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -139,21 +139,15 @@ void SystemProperties::querySdlVideoInfoInternal()
|
|||||||
// We call the internal variant because we're already in a safe thread context.
|
// We call the internal variant because we're already in a safe thread context.
|
||||||
refreshDisplaysInternal();
|
refreshDisplaysInternal();
|
||||||
|
|
||||||
SDL_Window* testWindow = SDL_CreateWindow("", 0, 0, 1280, 720,
|
SDL_Window* testWindow = SDLC_CreateWindowWithFallback("", 0, 0, 1280, 720,
|
||||||
SDL_WINDOW_HIDDEN | StreamUtils::getPlatformWindowFlags());
|
SDL_WINDOW_HIDDEN,
|
||||||
|
StreamUtils::getPlatformWindowFlags());
|
||||||
if (!testWindow) {
|
if (!testWindow) {
|
||||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"Failed to create test window with platform flags: %s",
|
"Failed to create window for hardware decode test: %s",
|
||||||
SDL_GetError());
|
SDL_GetError());
|
||||||
|
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||||
testWindow = SDL_CreateWindow("", 0, 0, 1280, 720, SDL_WINDOW_HIDDEN);
|
return;
|
||||||
if (!testWindow) {
|
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
|
||||||
"Failed to create window for hardware decode test: %s",
|
|
||||||
SDL_GetError());
|
|
||||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Session::getDecoderInfo(testWindow, hasHardwareAcceleration, rendererAlwaysFullScreen, supportsHdr, maximumResolution);
|
Session::getDecoderInfo(testWindow, hasHardwareAcceleration, rendererAlwaysFullScreen, supportsHdr, maximumResolution);
|
||||||
|
@ -618,21 +618,15 @@ bool Session::initialize()
|
|||||||
getWindowDimensions(x, y, width, height);
|
getWindowDimensions(x, y, width, height);
|
||||||
|
|
||||||
// Create a hidden window to use for decoder initialization tests
|
// Create a hidden window to use for decoder initialization tests
|
||||||
SDL_Window* testWindow = SDL_CreateWindow("", x, y, width, height,
|
SDL_Window* testWindow = SDLC_CreateWindowWithFallback("", x, y, width, height,
|
||||||
SDL_WINDOW_HIDDEN | StreamUtils::getPlatformWindowFlags());
|
SDL_WINDOW_HIDDEN,
|
||||||
|
StreamUtils::getPlatformWindowFlags());
|
||||||
if (!testWindow) {
|
if (!testWindow) {
|
||||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"Failed to create test window with platform flags: %s",
|
"Failed to create window for hardware decode test: %s",
|
||||||
SDL_GetError());
|
SDL_GetError());
|
||||||
|
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||||
testWindow = SDL_CreateWindow("", x, y, width, height, SDL_WINDOW_HIDDEN);
|
return false;
|
||||||
if (!testWindow) {
|
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
|
||||||
"Failed to create window for hardware decode test: %s",
|
|
||||||
SDL_GetError());
|
|
||||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qInfo() << "Server GPU:" << m_Computer->gpuModel;
|
qInfo() << "Server GPU:" << m_Computer->gpuModel;
|
||||||
@ -1835,34 +1829,23 @@ void Session::execInternal()
|
|||||||
std::string windowName = QString(m_Computer->name + " - Moonlight").toStdString();
|
std::string windowName = QString(m_Computer->name + " - Moonlight").toStdString();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_Window = SDL_CreateWindow(windowName.c_str(),
|
m_Window = SDLC_CreateWindowWithFallback(windowName.c_str(),
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
defaultWindowFlags | StreamUtils::getPlatformWindowFlags());
|
defaultWindowFlags,
|
||||||
|
StreamUtils::getPlatformWindowFlags());
|
||||||
if (!m_Window) {
|
if (!m_Window) {
|
||||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"SDL_CreateWindow() failed with platform flags: %s",
|
"SDL_CreateWindow() failed: %s",
|
||||||
SDL_GetError());
|
SDL_GetError());
|
||||||
|
|
||||||
m_Window = SDL_CreateWindow(windowName.c_str(),
|
delete m_InputHandler;
|
||||||
x,
|
m_InputHandler = nullptr;
|
||||||
y,
|
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||||
width,
|
QThreadPool::globalInstance()->start(new DeferredSessionCleanupTask(this));
|
||||||
height,
|
return;
|
||||||
defaultWindowFlags);
|
|
||||||
if (!m_Window) {
|
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
|
||||||
"SDL_CreateWindow() failed: %s",
|
|
||||||
SDL_GetError());
|
|
||||||
|
|
||||||
delete m_InputHandler;
|
|
||||||
m_InputHandler = nullptr;
|
|
||||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
|
||||||
QThreadPool::globalInstance()->start(new DeferredSessionCleanupTask(this));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// HACK: Remove once proper Dark Mode support lands in SDL
|
// HACK: Remove once proper Dark Mode support lands in SDL
|
||||||
|
Loading…
x
Reference in New Issue
Block a user