mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2025-08-16 00:16:07 +00:00
Fix: Improve stream window resizing logic
This commit is contained in:
parent
1bf86f52d3
commit
0c8354336b
@ -1347,26 +1347,23 @@ void Session::getWindowDimensions(int& x, int& y,
|
|||||||
|
|
||||||
SDL_Rect usableBounds;
|
SDL_Rect usableBounds;
|
||||||
if (SDL_GetDisplayUsableBounds(displayIndex, &usableBounds) == 0) {
|
if (SDL_GetDisplayUsableBounds(displayIndex, &usableBounds) == 0) {
|
||||||
// Don't use more than 80% of the display to leave room for system UI
|
// If the stream resolution fits within the usable display area, use it directly
|
||||||
// and ensure the target size is not odd (otherwise one of the sides
|
if (m_StreamConfig.width <= usableBounds.w &&
|
||||||
// of the image will have a one-pixel black bar next to it).
|
m_StreamConfig.height <= usableBounds.h) {
|
||||||
SDL_Rect src, dst;
|
|
||||||
src.x = src.y = dst.x = dst.y = 0;
|
|
||||||
src.w = m_StreamConfig.width;
|
|
||||||
src.h = m_StreamConfig.height;
|
|
||||||
dst.w = ((int)SDL_ceilf(usableBounds.w * 0.80f) & ~0x1);
|
|
||||||
dst.h = ((int)SDL_ceilf(usableBounds.h * 0.80f) & ~0x1);
|
|
||||||
|
|
||||||
// Scale the window size while preserving aspect ratio
|
|
||||||
StreamUtils::scaleSourceToDestinationSurface(&src, &dst);
|
|
||||||
|
|
||||||
// If the stream window can fit within the usable drawing area with 1:1
|
|
||||||
// scaling, do that rather than filling the screen.
|
|
||||||
if (m_StreamConfig.width < dst.w && m_StreamConfig.height < dst.h) {
|
|
||||||
width = m_StreamConfig.width;
|
width = m_StreamConfig.width;
|
||||||
height = m_StreamConfig.height;
|
height = m_StreamConfig.height;
|
||||||
}
|
} else {
|
||||||
else {
|
// Otherwise, use 80% of usable bounds and preserve aspect ratio
|
||||||
|
SDL_Rect src, dst;
|
||||||
|
src.x = src.y = dst.x = dst.y = 0;
|
||||||
|
src.w = m_StreamConfig.width;
|
||||||
|
src.h = m_StreamConfig.height;
|
||||||
|
|
||||||
|
dst.w = ((int)(usableBounds.w * 0.80f)) & ~0x1; // even width
|
||||||
|
dst.h = ((int)(usableBounds.h * 0.80f)) & ~0x1; // even height
|
||||||
|
|
||||||
|
StreamUtils::scaleSourceToDestinationSurface(&src, &dst);
|
||||||
|
|
||||||
width = dst.w;
|
width = dst.w;
|
||||||
height = dst.h;
|
height = dst.h;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user