From bcb7bb4396dfcfd26a73e121fb9dc276728d1511 Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Mon, 7 Oct 2024 21:39:36 +0300 Subject: [PATCH] _window positioning that works on windows --- Source/Engine/Platform/SDL/SDLWindow.cpp | 20 +++++++++++++++----- Source/Engine/UI/GUI/Tooltip.cs | 4 ++-- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Source/Engine/Platform/SDL/SDLWindow.cpp b/Source/Engine/Platform/SDL/SDLWindow.cpp index 9237a66c9..bbf19c571 100644 --- a/Source/Engine/Platform/SDL/SDLWindow.cpp +++ b/Source/Engine/Platform/SDL/SDLWindow.cpp @@ -196,6 +196,10 @@ SDLWindow::SDLWindow(const CreateWindowSettings& settings) } } + Int2 oldpos2(x, y); + + // It should be noted that SDL creates the window in client-space coordinates (ignoring window decorations) + SDL_PropertiesID props = SDL_CreateProperties(); SDL_SetNumberProperty(props, "flags", flags); SDL_SetStringProperty(props, SDL_PROP_WINDOW_CREATE_TITLE_STRING, settings.Title.ToStringAnsi().Get()); @@ -242,16 +246,17 @@ 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); - Int2 newpos = GetPosition(); - LOG(Info, "new window at {}, expected: {}", newpos, oldpos); - ASSERT(newpos == oldpos); + Int2 newpos = GetClientPosition(); + //Int2 newposclient = GetClientPosition(); + LOG(Info, "new window at {}, input {}, expected: {}", newpos, oldpos, oldpos2); + ASSERT(newpos == oldpos || newpos == oldpos2); - oldpos = newpos; + /*oldpos = newpos; SetPosition(newpos); newpos = GetPosition(); LOG(Info, "new window sanity set at {}", newpos); - ASSERT(newpos == oldpos); + ASSERT(newpos == oldpos);*/ SDL_SetWindowHitTest(_window, &OnWindowHitTest, this); InitSwapChain(); @@ -952,6 +957,11 @@ void GetRelativeWindowPosition(const SDLWindow* window, Int2& relativePosition, else #endif { +#if PLATFORM_WINDOWS + //relativePosition = Int2::Zero; + return; +#endif + SDLWindow* parent; if (SDLPlatform::UsesX11()) { diff --git a/Source/Engine/UI/GUI/Tooltip.cs b/Source/Engine/UI/GUI/Tooltip.cs index 62285daa7..1ad4cb1bb 100644 --- a/Source/Engine/UI/GUI/Tooltip.cs +++ b/Source/Engine/UI/GUI/Tooltip.cs @@ -79,7 +79,7 @@ namespace FlaxEngine.GUI WrapPosition(ref mousePos, 10); locationSS = mousePos + new Float2(15, 10); var ppp = Input.MouseScreenPosition; - locationSS = new Float2(5, 5); + //locationSS = new Float2(5, 5); var bef = locationSS; // Create window @@ -231,7 +231,7 @@ namespace FlaxEngine.GUI var bef = _window.Position; WrapPosition(ref mousePos, 10); mousePos += new Float2(15, 10); - mousePos = new Float2(5, 5); + //mousePos = new Float2(5, 5); if (_window) _window.Position = mousePos;