From b6cb8535a52d4292ad17f15101e9c098575fd679 Mon Sep 17 00:00:00 2001 From: elasota Date: Sun, 1 Nov 2020 13:48:00 -0500 Subject: [PATCH] Fix wrong source export window position on Android --- GpApp/SourceExport.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/GpApp/SourceExport.cpp b/GpApp/SourceExport.cpp index 427c468..87d473d 100644 --- a/GpApp/SourceExport.cpp +++ b/GpApp/SourceExport.cpp @@ -4,7 +4,9 @@ #include "GpBuildVersion.h" #include "GpIOStream.h" #include "HostDirectoryCursor.h" +#include "HostDisplayDriver.h" #include "HostFileSystem.h" +#include "IGpDisplayDriver.h" #include "MemoryManager.h" #include "PLCore.h" #include "PLStandardColors.h" @@ -134,8 +136,14 @@ static void InitSourceExportWindow(SourceExportState *state) ForceSyncFrame(); PLSysCalls::Sleep(1); - int32_t lsX = (thisMac.fullScreen.Width() - kLoadScreenWidth) / 2; - int32_t lsY = (thisMac.fullScreen.Height() - kLoadScreenHeight) / 2; + // We have to use this instead of thisMac.fullScreen because the resolution may change during the sleep call, especially on Android displays where + // the status bar dismissal causes a major change in the virtual resolution. + unsigned int displayWidth = 0; + unsigned int displayHeight = 0; + PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(&displayWidth, &displayHeight); + + int32_t lsX = (static_cast(displayWidth) - kLoadScreenWidth) / 2; + int32_t lsY = (static_cast(displayHeight) - kLoadScreenHeight) / 2; const Rect loadScreenRect = Rect::Create(lsY, lsX, lsY + kLoadScreenHeight, lsX + kLoadScreenWidth);