From 127113a59b70374de71f6708a3b06ce7ea918bb8 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Fri, 3 Jan 2020 17:23:48 +1100 Subject: [PATCH] [client] fixed strange resize effect due to loss of precision --- VERSION | 2 +- client/src/main.c | 23 +++++++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/VERSION b/VERSION index 9bb7fbb5..27e5a749 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -B1-49-g2196516e2b+1 \ No newline at end of file +B1-50-g49bf115c84+1 \ No newline at end of file diff --git a/client/src/main.c b/client/src/main.c index 9f36b3f9..934445c4 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -75,6 +75,17 @@ static void updatePositionInfo() { const float srcAspect = (float)state.srcSize.y / (float)state.srcSize.x; const float wndAspect = (float)state.windowH / (float)state.windowW; + bool force = true; + + if ((int)(wndAspect * 1000) == (int)(srcAspect * 1000)) + { + force = false; + state.dstRect.w = state.windowW; + state.dstRect.h = state.windowH; + state.dstRect.x = 0; + state.dstRect.y = 0; + } + else if (wndAspect < srcAspect) { state.dstRect.w = (float)state.windowH / srcAspect; @@ -89,6 +100,12 @@ static void updatePositionInfo() state.dstRect.x = 0; state.dstRect.y = (state.windowH >> 1) - (state.dstRect.h >> 1); } + + if (force && params.forceAspect) + { + state.resizeTimeout = getMicrotime() + RESIZE_TIMEOUT; + state.resizeDone = false; + } } else { @@ -101,12 +118,6 @@ static void updatePositionInfo() state.scaleX = (float)state.srcSize.y / (float)state.dstRect.h; state.scaleY = (float)state.srcSize.x / (float)state.dstRect.w; - - if (params.forceAspect) - { - state.resizeTimeout = getMicrotime() + RESIZE_TIMEOUT; - state.resizeDone = false; - } } state.lgrResize = true;