mirror of
https://github.com/moonlight-stream/moonlight-qt
synced 2024-12-14 05:12:27 +00:00
Count the window chrome size in our placement decision and fix sizing after full-screen toggle
This commit is contained in:
parent
4c507f1179
commit
7b235743cb
1 changed files with 38 additions and 2 deletions
|
@ -412,6 +412,22 @@ void Session::getWindowDimensions(bool fullScreen,
|
||||||
height = usableBounds.h;
|
height = usableBounds.h;
|
||||||
x = usableBounds.x;
|
x = usableBounds.x;
|
||||||
y = usableBounds.y;
|
y = usableBounds.y;
|
||||||
|
|
||||||
|
if (m_Window != nullptr) {
|
||||||
|
int top, left, bottom, right;
|
||||||
|
|
||||||
|
if (SDL_GetWindowBordersSize(m_Window, &top, &left, &bottom, &right) < 0) {
|
||||||
|
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Unable to get window border size");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
x += left;
|
||||||
|
y += top;
|
||||||
|
|
||||||
|
width -= left + right;
|
||||||
|
height -= top + bottom;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
@ -431,12 +447,22 @@ void Session::toggleFullscreen()
|
||||||
|
|
||||||
int x, y, width, height;
|
int x, y, width, height;
|
||||||
|
|
||||||
|
// If we're leaving full screen, toggle out before setting our size and position
|
||||||
|
// that way we have accurate display size metrics (not the size our stream changed it to).
|
||||||
|
if (!fullScreen) {
|
||||||
|
SDL_SetWindowFullscreen(m_Window, 0);
|
||||||
|
}
|
||||||
|
|
||||||
getWindowDimensions(fullScreen, x, y, width, height);
|
getWindowDimensions(fullScreen, x, y, width, height);
|
||||||
|
|
||||||
|
if (x != SDL_WINDOWPOS_UNDEFINED || y != SDL_WINDOWPOS_UNDEFINED) {
|
||||||
SDL_SetWindowPosition(m_Window, x, y);
|
SDL_SetWindowPosition(m_Window, x, y);
|
||||||
|
}
|
||||||
SDL_SetWindowSize(m_Window, width, height);
|
SDL_SetWindowSize(m_Window, width, height);
|
||||||
|
|
||||||
SDL_SetWindowFullscreen(m_Window, fullScreen ? SDL_WINDOW_FULLSCREEN : 0);
|
if (fullScreen) {
|
||||||
|
SDL_SetWindowFullscreen(m_Window, SDL_WINDOW_FULLSCREEN);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::exec()
|
void Session::exec()
|
||||||
|
@ -516,6 +542,16 @@ void Session::exec()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For non-full screen windows, call getWindowDimensions()
|
||||||
|
// again after creating a window to allow it to account
|
||||||
|
// for window chrome size.
|
||||||
|
if (!m_Preferences.fullScreen) {
|
||||||
|
getWindowDimensions(false, x, y, width, height);
|
||||||
|
|
||||||
|
SDL_SetWindowPosition(m_Window, x, y);
|
||||||
|
SDL_SetWindowSize(m_Window, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
QByteArray hostnameStr = m_Computer->activeAddress.toLatin1();
|
QByteArray hostnameStr = m_Computer->activeAddress.toLatin1();
|
||||||
QByteArray siAppVersion = m_Computer->appVersion.toLatin1();
|
QByteArray siAppVersion = m_Computer->appVersion.toLatin1();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue