From a07b7d41e4b6cd90388d592c5f372c4d156d0ab2 Mon Sep 17 00:00:00 2001 From: elasota Date: Sun, 1 Nov 2020 13:47:22 -0500 Subject: [PATCH] Fix broken window repositioning on mobile --- PortabilityLayer/WindowManager.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/PortabilityLayer/WindowManager.cpp b/PortabilityLayer/WindowManager.cpp index 5b034e7..75f5153 100644 --- a/PortabilityLayer/WindowManager.cpp +++ b/PortabilityLayer/WindowManager.cpp @@ -1471,6 +1471,9 @@ namespace PortabilityLayer int32_t currentY = window->GetPosition().m_y; if (!menuIsTouchScreen) { + if (logger) + logger->Printf(IGpLogDriver::Category_Information, "currentY: %i menuBarHeight: %i", static_cast(currentY), static_cast(menuBarHeight)); + if (currentY < static_cast(menuBarHeight)) newY = currentY; else @@ -1481,13 +1484,21 @@ namespace PortabilityLayer { uint32_t prevClearanceY = prevHeight - paddedHeight - menuBarHeight; uint32_t newClearanceY = newHeight - paddedHeight - menuBarHeight; + + if (logger) + logger->Printf(IGpLogDriver::Category_Information, "prevClearanceY: %i newClearanceY: %i", static_cast(prevClearanceY), static_cast(newClearanceY)); + newY = (static_cast(currentY) - static_cast(menuBarHeight) - chromePadding[WindowChromeSides::kTop]) * static_cast(newClearanceY) / static_cast(prevClearanceY) + menuBarHeight + chromePadding[WindowChromeSides::kTop]; } } } else { - uint32_t heightWithoutMenu = surfaceRect.Height() - menuBarHeight; + uint32_t heightWithoutMenu = std::max(prevHeight, menuBarHeight) - menuBarHeight; + + if (logger) + logger->Printf(IGpLogDriver::Category_Information, "currentY: %i paddedHeight: %i heightWithoutMenu: %i", static_cast(currentY), static_cast(paddedHeight), static_cast(heightWithoutMenu)); + if (currentY + static_cast(paddedHeight) >= static_cast(heightWithoutMenu)) newY = currentY; else @@ -1498,6 +1509,10 @@ namespace PortabilityLayer { uint32_t prevClearanceY = prevHeight - paddedHeight - menuBarHeight; uint32_t newClearanceY = newHeight - paddedHeight - menuBarHeight; + + if (logger) + logger->Printf(IGpLogDriver::Category_Information, "prevClearanceY: %i newClearanceY: %i", static_cast(prevClearanceY), static_cast(newClearanceY)); + newY = (static_cast(currentY) - static_cast(menuBarHeight) - chromePadding[WindowChromeSides::kTop]) * static_cast(newClearanceY) / static_cast(prevClearanceY) + chromePadding[WindowChromeSides::kTop]; } }