_works 0,0 primary screen, returned positions correct but visually wrong
This commit is contained in:
@@ -855,7 +855,11 @@ Int2 GetSDLWindowPosition(const SDLWindow* window)
|
||||
{
|
||||
if (window->GetSettings().Type == WindowType::Tooltip || window->GetSettings().Type == WindowType::Popup)
|
||||
{
|
||||
SDL_GetWindowPosition(window->GetSettings().Parent->GetSDLWindow(), &position.X, &position.Y);
|
||||
Int2 parentPosition = GetSDLWindowPosition(window->GetSettings().Parent);
|
||||
//SDL_GetWindowPosition(window->GetSettings().Parent->GetSDLWindow(), &parentPosition.X, &parentPosition.Y);
|
||||
position -= parentPosition;
|
||||
auto monitorBounds = Platform::GetMonitorBounds(Float2::Minimum);
|
||||
//position -= Int2(monitorBounds.GetTopLeft());
|
||||
//auto monitorBounds = Platform::GetMonitorBounds(Float2::Minimum);
|
||||
//position += Int2(monitorBounds.GetTopLeft());
|
||||
}
|
||||
@@ -982,15 +986,16 @@ void SetRelativeWindowPosition(const SDLWindow* window, Int2& relativePosition)
|
||||
SDLWindow* parent = window->GetSettings().Parent;
|
||||
while (parent != nullptr)
|
||||
{
|
||||
if (parent->GetSettings().Parent == nullptr || (parent->GetSettings().Type != WindowType::Tooltip && parent->GetSettings().Type != WindowType::Popup))
|
||||
break;
|
||||
if (parent->GetSettings().Type != WindowType::Tooltip && parent->GetSettings().Type != WindowType::Popup)
|
||||
{
|
||||
Int2 parentPosition = GetSDLWindowPosition(parent);
|
||||
relativePosition -= parentPosition;
|
||||
//break;
|
||||
}
|
||||
//if (parent->GetSettings().Parent == nullptr || (parent->GetSettings().Type != WindowType::Tooltip && parent->GetSettings().Type != WindowType::Popup))
|
||||
// break;
|
||||
parent = parent->GetSettings().Parent;
|
||||
}
|
||||
if (parent != nullptr)
|
||||
{
|
||||
Int2 parentPosition = GetSDLWindowPosition(parent);
|
||||
relativePosition += parentPosition;
|
||||
}
|
||||
}
|
||||
else if (SDLPlatform::UsesWayland())
|
||||
{
|
||||
@@ -1053,9 +1058,19 @@ void SDLWindow::SetPosition(const Float2& position)
|
||||
// The position is relative to the parent window
|
||||
Int2 relativePosition(static_cast<int>(position.X), static_cast<int>(position.Y));
|
||||
relativePosition += topLeftBorder;
|
||||
GetRelativeWindowPosition(this, relativePosition);
|
||||
SetRelativeWindowPosition(this, relativePosition);
|
||||
|
||||
SDL_SetWindowPosition(_window, relativePosition.X, relativePosition.Y);
|
||||
SDL_SyncWindow(_window);
|
||||
|
||||
Int2 newPos;
|
||||
SDL_GetWindowPosition(_window, &newPos.X, &newPos.Y);
|
||||
if (!(newPos.X == relativePosition.X && newPos.Y == relativePosition.Y))
|
||||
ASSERT(false);
|
||||
|
||||
newPos = GetPosition();
|
||||
if (!(newPos.X == relativePosition.X && newPos.Y == relativePosition.Y))
|
||||
ASSERT(false);
|
||||
}
|
||||
|
||||
void SDLWindow::SetClientPosition(const Float2& position)
|
||||
|
||||
Reference in New Issue
Block a user