mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-12-14 12:09:36 +00:00
Fix display resolution desynchronizing with auto-position
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "DialogManager.h"
|
||||
#include "IconLoader.h"
|
||||
#include "IGpDisplayDriver.h"
|
||||
#include "IGpLogDriver.h"
|
||||
#include "IGpSystemServices.h"
|
||||
#include "ResourceManager.h"
|
||||
#include "QDPixMap.h"
|
||||
@@ -830,8 +831,11 @@ namespace PortabilityLayer
|
||||
|
||||
void DialogManagerImpl::PositionWindow(Window *window, const Rect &rect) const
|
||||
{
|
||||
unsigned int displayWidth, displayHeight;
|
||||
PLDrivers::GetDisplayDriver()->GetDisplayResolution(&displayWidth, &displayHeight);
|
||||
IGpLogDriver *logger = PLDrivers::GetLogDriver();
|
||||
|
||||
Vec2i displayResolution = WindowManager::GetInstance()->GetDisplayResolution();
|
||||
unsigned int displayWidth = displayResolution.m_x;
|
||||
unsigned int displayHeight = displayResolution.m_y;
|
||||
|
||||
const unsigned int halfDisplayHeight = displayHeight / 2;
|
||||
const unsigned int quarterDisplayWidth = displayHeight / 4;
|
||||
@@ -840,6 +844,9 @@ namespace PortabilityLayer
|
||||
const uint16_t dialogWidth = rect.Width();
|
||||
const uint16_t dialogHeight = rect.Height();
|
||||
|
||||
if (logger)
|
||||
logger->Printf(IGpLogDriver::Category_Information, "Auto positioning window size %ix%i on display size %ix%i", static_cast<int>(dialogWidth), static_cast<int>(dialogHeight), static_cast<int>(displayWidth), static_cast<int>(displayHeight));
|
||||
|
||||
Vec2i newPosition;
|
||||
|
||||
newPosition.m_x = (static_cast<int32_t>(displayWidth) - static_cast<int32_t>(dialogWidth)) / 2;
|
||||
@@ -860,6 +867,9 @@ namespace PortabilityLayer
|
||||
else
|
||||
newPosition.m_y = (static_cast<int32_t>(displayHeight) - static_cast<int32_t>(dialogHeight)) / 2;
|
||||
|
||||
if (logger)
|
||||
logger->Printf(IGpLogDriver::Category_Information, "Positioned at %i,%i", static_cast<int>(newPosition.m_x), static_cast<int>(newPosition.m_y));
|
||||
|
||||
window->SetPosition(newPosition);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user