_refix x11 popu positioning
Some checks failed
Build Android / Game (Android, Release ARM64) (push) Has been cancelled
Build iOS / Game (iOS, Release ARM64) (push) Has been cancelled
Build Linux / Editor (Linux, Development x64) (push) Has been cancelled
Build Linux / Game (Linux, Release x64) (push) Has been cancelled
Build macOS / Editor (Mac, Development ARM64) (push) Has been cancelled
Build macOS / Game (Mac, Release ARM64) (push) Has been cancelled
Build Windows / Editor (Windows, Development x64) (push) Has been cancelled
Build Windows / Game (Windows, Release x64) (push) Has been cancelled
Cooker / Cook (Mac) (push) Has been cancelled
Tests / Tests (Linux) (push) Has been cancelled
Tests / Tests (Windows) (push) Has been cancelled
Some checks failed
Build Android / Game (Android, Release ARM64) (push) Has been cancelled
Build iOS / Game (iOS, Release ARM64) (push) Has been cancelled
Build Linux / Editor (Linux, Development x64) (push) Has been cancelled
Build Linux / Game (Linux, Release x64) (push) Has been cancelled
Build macOS / Editor (Mac, Development ARM64) (push) Has been cancelled
Build macOS / Game (Mac, Release ARM64) (push) Has been cancelled
Build Windows / Editor (Windows, Development x64) (push) Has been cancelled
Build Windows / Game (Windows, Release x64) (push) Has been cancelled
Cooker / Cook (Mac) (push) Has been cancelled
Tests / Tests (Linux) (push) Has been cancelled
Tests / Tests (Windows) (push) Has been cancelled
This commit is contained in:
@@ -33,7 +33,7 @@
|
||||
#endif
|
||||
#elif PLATFORM_LINUX
|
||||
#include "Engine/Platform/Linux/IncludeX11.h"
|
||||
#define X11_WINDOW_POSITION_WORKAROUND 1
|
||||
#define X11_WINDOW_POSITION_WORKAROUND 1 // Popup windows report wrong position?
|
||||
#endif
|
||||
|
||||
#define DefaultDPI 96
|
||||
@@ -211,7 +211,7 @@ SDLWindow::SDLWindow(const CreateWindowSettings& settings)
|
||||
}
|
||||
}
|
||||
|
||||
LOG(Info, "{}x{}, parent: {}", x, y, _settings.Parent != nullptr ? _settings.Parent->GetTitle() : String("null"));
|
||||
//LOG(Info, "{}x{}, parent: {}", x, y, _settings.Parent != nullptr ? _settings.Parent->GetTitle() : String("null"));
|
||||
|
||||
// The SDL window position is always relative to the parent window
|
||||
|
||||
@@ -323,7 +323,7 @@ SDLWindow::SDLWindow(const CreateWindowSettings& settings)
|
||||
|
||||
Int2 newpos = GetClientPosition();
|
||||
Int2 newposclient = GetSDLWindowPosition(this);
|
||||
LOG(Info, "new window at {}, input {}, expected: {}", newposclient, oldpos, oldpos2);
|
||||
//LOG(Info, "new window at {}, input {}, expected: {}", newposclient, oldpos, oldpos2);
|
||||
//ASSERT(newpos == oldpos || newpos == oldpos2);
|
||||
|
||||
/*oldpos = newpos;
|
||||
@@ -1020,28 +1020,19 @@ Int2 GetSDLWindowPosition(const SDLWindow* window)
|
||||
if (SDLPlatform::UsesX11())
|
||||
{
|
||||
#if X11_WINDOW_POSITION_WORKAROUND
|
||||
if (window->GetSettings().Type == WindowType::Tooltip || window->GetSettings().Type == WindowType::Popup)
|
||||
if (/*window->GetSettings().Type == WindowType::Tooltip ||*/ window->GetSettings().Type == WindowType::Popup)
|
||||
{
|
||||
auto oldPos = position;
|
||||
auto parent = window->GetSettings().Parent;
|
||||
while (parent->GetSettings().Parent != nullptr)
|
||||
while (parent != nullptr)
|
||||
{
|
||||
Int2 rootParentPosition = GetSDLWindowPosition(parent);
|
||||
//SDL_GetWindowPosition(window->GetSettings().Parent->GetSDLWindow(), &parentPosition.X, &parentPosition.Y);
|
||||
Int2 rootParentPosition;
|
||||
//rootParentPosition = GetSDLWindowPosition(parent);
|
||||
SDL_GetWindowPosition(parent->GetSDLWindow(), &rootParentPosition.X, &rootParentPosition.Y);
|
||||
position += rootParentPosition;
|
||||
parent = parent->GetSettings().Parent;
|
||||
}
|
||||
Int2 rootParentPosition = GetSDLWindowPosition(parent);
|
||||
//SDL_GetWindowPosition(window->GetSettings().Parent->GetSDLWindow(), &parentPosition.X, &parentPosition.Y);
|
||||
position += rootParentPosition;
|
||||
auto monitorBounds = Platform::GetMonitorBounds(Float2::Minimum);
|
||||
//position += Int2(monitorBounds.GetTopLeft());
|
||||
//auto monitorBounds = Platform::GetMonitorBounds(Float2::Minimum);
|
||||
//position += Int2(monitorBounds.GetTopLeft());
|
||||
}
|
||||
else
|
||||
{
|
||||
//auto monitorBounds = Platform::GetMonitorBounds(Float2::Minimum);
|
||||
//position -= Int2(monitorBounds.GetTopLeft());
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1071,41 +1062,19 @@ void SetSDLWindowPosition(SDLWindow* window, const int x, const int y)
|
||||
if (SDLPlatform::UsesX11())
|
||||
{
|
||||
#if X11_WINDOW_POSITION_WORKAROUND
|
||||
if (window->GetSettings().Type == WindowType::Tooltip || window->GetSettings().Type == WindowType::Popup)
|
||||
if (/*window->GetSettings().Type == WindowType::Tooltip ||*/ window->GetSettings().Type == WindowType::Popup)
|
||||
{
|
||||
Int2 position(x, y);
|
||||
auto parent = window->GetSettings().Parent;
|
||||
while (parent->GetSettings().Parent != nullptr)
|
||||
while (parent != nullptr)
|
||||
{
|
||||
Int2 rootParentPosition = GetSDLWindowPosition(parent);
|
||||
//SDL_GetWindowPosition(window->GetSettings().Parent->GetSDLWindow(), &parentPosition.X, &parentPosition.Y);
|
||||
Int2 rootParentPosition;
|
||||
SDL_GetWindowPosition(parent->GetSDLWindow(), &rootParentPosition.X, &rootParentPosition.Y);
|
||||
position -= rootParentPosition;
|
||||
parent = parent->GetSettings().Parent;
|
||||
}
|
||||
Int2 rootParentPosition = GetSDLWindowPosition(parent);
|
||||
//SDL_GetWindowPosition(window->GetSettings().Parent->GetSDLWindow(), &parentPosition.X, &parentPosition.Y);
|
||||
position -= rootParentPosition;
|
||||
auto monitorBounds = Platform::GetMonitorBounds(Float2::Minimum);
|
||||
//position += Int2(monitorBounds.GetTopLeft());
|
||||
//auto monitorBounds = Platform::GetMonitorBounds(Float2::Minimum);
|
||||
//position += Int2(monitorBounds.GetTopLeft());
|
||||
|
||||
SDL_SetWindowPosition(window->GetSDLWindow(), position.X, position.Y);
|
||||
|
||||
SDL_SyncWindow(window->GetSDLWindow());
|
||||
|
||||
Int2 newpos;
|
||||
Int2 newpos2 = GetSDLWindowPosition(window);
|
||||
SDL_GetWindowPosition(window->GetSDLWindow(), &newpos.X, &newpos.Y);
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
//auto monitorBounds = Platform::GetMonitorBounds(Float2::Minimum);
|
||||
//position -= Int2(monitorBounds.GetTopLeft());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (SDLPlatform::UsesWayland())
|
||||
@@ -1233,23 +1202,57 @@ void SetRelativeWindowPosition(const WindowType windowType, SDLWindow* theParent
|
||||
#if PLATFORM_LINUX
|
||||
if (SDLPlatform::UsesX11())
|
||||
{
|
||||
/**/
|
||||
if (windowType != WindowType::Tooltip && windowType != WindowType::Popup)
|
||||
{
|
||||
/*auto parentPosition = theParent->ClientToScreen(Float2::Zero);
|
||||
xRel -= Math::TruncToInt(parentPosition.X);
|
||||
yRel -= Math::TruncToInt(parentPosition.Y);
|
||||
|
||||
auto parentType = theParent->GetSettings().Type;
|
||||
auto parentParent = theParent->GetSettings().Parent;
|
||||
if (parentParent != nullptr)
|
||||
{
|
||||
//if (parentType != WindowType::Popup && parentType != WindowType::Tooltip)
|
||||
{
|
||||
auto parentParentType = parentParent->GetSettings().Type;
|
||||
//if (parentParentType != WindowType::Popup && parentParentType != WindowType::Tooltip)
|
||||
{
|
||||
auto parentParentPosition = parentParent->ClientToScreen(Float2::Zero);
|
||||
xRel -= Math::TruncToInt(parentParentPosition.X);
|
||||
yRel -= Math::TruncToInt(parentParentPosition.Y);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
SDLWindow* parent = theParent;
|
||||
while (parent != nullptr)
|
||||
{
|
||||
if (parent->GetSettings().Type != WindowType::Tooltip && parent->GetSettings().Type != WindowType::Popup)
|
||||
//if (parent->GetSettings().Type != WindowType::Tooltip && parent->GetSettings().Type != WindowType::Popup)
|
||||
//if (false)
|
||||
{
|
||||
Int2 parentPosition = GetSDLWindowPosition(parent);
|
||||
//Int2 parentPosition;
|
||||
//SDL_GetWindowPosition(parent->GetSDLWindow(), &parentPosition.X, &parentPosition.Y);
|
||||
xRel -= parentPosition.X;
|
||||
yRel -= parentPosition.Y;
|
||||
break;
|
||||
//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);
|
||||
//Int2 parentPosition;
|
||||
//SDL_GetWindowPosition(parent->GetSDLWindow(), &parentPosition.X, &parentPosition.Y);
|
||||
xRel -= parentPosition.X;
|
||||
yRel -= parentPosition.Y;
|
||||
}*/
|
||||
}
|
||||
else if (SDLPlatform::UsesWayland())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user