_works
This commit is contained in:
@@ -43,6 +43,8 @@ namespace
|
||||
|
||||
void* GetNativeWindowPointer(SDL_Window* window);
|
||||
SDL_HitTestResult OnWindowHitTest(SDL_Window* win, const SDL_Point* area, void* data);
|
||||
Int2 GetSDLWindowPosition(const SDLWindow* window);
|
||||
void GetRelativeWindowPosition(const SDLWindow* window, Int2& relativePosition, bool clienttoscreen = true);
|
||||
|
||||
class SDLDropFilesData : public IGuiData
|
||||
{
|
||||
@@ -166,9 +168,11 @@ SDLWindow::SDLWindow(const CreateWindowSettings& settings)
|
||||
{//(_settings.Type == WindowType::Tooltip || _settings.Type == WindowType::Popup)
|
||||
//if (_settings.Type == WindowType::Tooltip || _settings.Type == WindowType::Popup)
|
||||
{
|
||||
auto parentPosition = _settings.Parent->ClientToScreen(Float2::Zero);
|
||||
x -= Math::TruncToInt(parentPosition.X);
|
||||
y -= Math::TruncToInt(parentPosition.Y);
|
||||
Int2 parentPosition = GetSDLWindowPosition(_settings.Parent);
|
||||
GetRelativeWindowPosition(_settings.Parent, parentPosition, false);
|
||||
//auto parentPosition = _settings.Parent->ClientToScreen(Float2::Zero);
|
||||
x -= parentPosition.X;
|
||||
y -= parentPosition.Y;
|
||||
}
|
||||
}
|
||||
else if (_settings.Parent != nullptr)
|
||||
@@ -179,9 +183,16 @@ SDLWindow::SDLWindow(const CreateWindowSettings& settings)
|
||||
}
|
||||
if (SDLPlatform::UsesX11() && _settings.Parent != Engine::MainWindow)
|
||||
{
|
||||
auto monitorBounds = Platform::GetMonitorBounds(Float2::Minimum);
|
||||
x -= (int)monitorBounds.GetLeft();
|
||||
y -= (int)monitorBounds.GetTop();
|
||||
if (_settings.Parent->GetSettings().Type == WindowType::Tooltip || _settings.Parent->GetSettings().Type == WindowType::Popup)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
auto monitorBounds = Platform::GetMonitorBounds(Float2::Minimum);
|
||||
x -= (int)monitorBounds.GetLeft();
|
||||
y -= (int)monitorBounds.GetTop();
|
||||
}
|
||||
}
|
||||
|
||||
SDL_PropertiesID props = SDL_CreateProperties();
|
||||
@@ -228,6 +239,8 @@ SDLWindow::SDLWindow(const CreateWindowSettings& settings)
|
||||
SDL_GetWindowSizeInPixels(_window, &rect.w, &rect.h);
|
||||
_cachedClientRectangle = Rectangle((float)rect.x, (float)rect.y, (float)rect.w, (float)rect.h);
|
||||
|
||||
LOG(Info, "new window at {}, expected: {}, {}", _cachedClientRectangle.GetTopLeft(), x, y);
|
||||
|
||||
SDL_SetWindowHitTest(_window, &OnWindowHitTest, this);
|
||||
InitSwapChain();
|
||||
|
||||
@@ -491,7 +504,7 @@ void SDLWindow::HandleEvent(SDL_Event& event)
|
||||
{
|
||||
_cachedClientRectangle.Location = Float2(static_cast<float>(event.window.data1), static_cast<float>(event.window.data2));
|
||||
#if PLATFORM_LINUX
|
||||
if (SDLPlatform::UsesX11())
|
||||
if (SDLPlatform::UsesX11() && !SDLPlatform::UsesXWayland())
|
||||
{
|
||||
// X11 doesn't report any mouse events when mouse is over the caption area, send a simulated event instead...
|
||||
Float2 mousePosition;
|
||||
@@ -842,8 +855,9 @@ Int2 GetSDLWindowPosition(const SDLWindow* window)
|
||||
{
|
||||
if (window->GetSettings().Type == WindowType::Tooltip || window->GetSettings().Type == WindowType::Popup)
|
||||
{
|
||||
auto monitorBounds = Platform::GetMonitorBounds(Float2::Minimum);
|
||||
position += Int2(monitorBounds.GetTopLeft());
|
||||
SDL_GetWindowPosition(window->GetSettings().Parent->GetSDLWindow(), &position.X, &position.Y);
|
||||
//auto monitorBounds = Platform::GetMonitorBounds(Float2::Minimum);
|
||||
//position += Int2(monitorBounds.GetTopLeft());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -855,7 +869,7 @@ Int2 GetSDLWindowPosition(const SDLWindow* window)
|
||||
return position;
|
||||
}
|
||||
|
||||
void GetRelativeWindowPosition(const SDLWindow* window, Int2& relativePosition, bool clienttoscreen = true)
|
||||
void GetRelativeWindowPosition(const SDLWindow* window, Int2& relativePosition, bool clienttoscreen)
|
||||
{
|
||||
// The relative positioning of windows are very inconsistent in different platforms.
|
||||
// On Windows and X11: The child position is relative to parent windows only for tooltip and popup windows.
|
||||
@@ -868,6 +882,7 @@ void GetRelativeWindowPosition(const SDLWindow* window, Int2& relativePosition,
|
||||
}*/
|
||||
|
||||
#if PLATFORM_LINUX
|
||||
//clienttoscreen = false;
|
||||
if (SDLPlatform::UsesX11())
|
||||
{
|
||||
// This is correct for ClientToScreen (mouse position transformation)
|
||||
|
||||
Reference in New Issue
Block a user