diff --git a/PortabilityLayer/WindowManager.cpp b/PortabilityLayer/WindowManager.cpp index d63668d..5b034e7 100644 --- a/PortabilityLayer/WindowManager.cpp +++ b/PortabilityLayer/WindowManager.cpp @@ -2,8 +2,10 @@ #include "DisplayDeviceManager.h" #include "HostDisplayDriver.h" +#include "HostLogDriver.h" #include "IGpDisplayDriver.h" #include "IGpDisplayDriverSurface.h" +#include "IGpLogDriver.h" #include "PLCore.h" #include "PLEventQueue.h" #include "PLStandardColors.h" @@ -1434,6 +1436,11 @@ namespace PortabilityLayer void WindowManagerImpl::HandleScreenResolutionChange(uint32_t prevWidth, uint32_t prevHeight, uint32_t newWidth, uint32_t newHeight) { + IGpLogDriver *logger = PortabilityLayer::HostLogDriver::GetInstance(); + + if (logger) + logger->Printf(IGpLogDriver::Category_Information, "WindowManagerImpl: Resizing from %ix%i to %ix%i", static_cast(prevWidth), static_cast(prevHeight), static_cast(newWidth), static_cast(newHeight)); + const uint32_t menuBarHeight = PortabilityLayer::MenuManager::GetInstance()->GetMenuBarHeight(); const bool menuIsTouchScreen = PortabilityLayer::MenuManager::GetInstance()->IsMenuTouchScreenStyle(); @@ -1444,6 +1451,9 @@ namespace PortabilityLayer const Rect surfaceRect = window->GetDrawSurface()->m_port.GetRect(); + if (logger) + logger->Printf(IGpLogDriver::Category_Information, "Auto window reposition: Pos: %i,%i Size %i,%i", static_cast(window->GetPosition().m_x), static_cast(window->GetPosition().m_y), static_cast(surfaceRect.Width()), static_cast(surfaceRect.Height())); + uint32_t paddedWidth = surfaceRect.Width() + chromePadding[WindowChromeSides::kLeft] + chromePadding[WindowChromeSides::kRight]; uint32_t paddedHeight = surfaceRect.Height() + chromePadding[WindowChromeSides::kTop] + chromePadding[WindowChromeSides::kBottom]; @@ -1478,7 +1488,7 @@ namespace PortabilityLayer else { uint32_t heightWithoutMenu = surfaceRect.Height() - menuBarHeight; - if (currentY + static_cast(paddedHeight) >= heightWithoutMenu) + if (currentY + static_cast(paddedHeight) >= static_cast(heightWithoutMenu)) newY = currentY; else { @@ -1496,6 +1506,9 @@ namespace PortabilityLayer newX = std::max(0, std::min(newX, newWidth - 1)); newY = std::max(0, std::min(newY, newHeight - 1)); + if (logger) + logger->Printf(IGpLogDriver::Category_Information, "New position: %i,%i", static_cast(newX), static_cast(newY)); + window->SetPosition(Vec2i(newX, newY)); } }