Fix workaround for maximizing Editor window

This commit is contained in:
2024-12-25 19:45:10 +02:00
parent 37acdc29ff
commit bd81e3e89e
2 changed files with 7 additions and 14 deletions

View File

@@ -548,9 +548,11 @@ void SDLWindow::HandleEvent(SDL_Event& event)
_maximized = true;
#if PLATFORM_WINDOWS
// This shouldn't be needed anymore, but maximize blocks any resize operations
if (!_settings.HasBorder && _settings.HasSizingFrame)
{
// Borderless window doesn't maximize properly, manually force the window into correct location and size
// Borderless editor window doesn't maximize properly,
// manually force the window into correct location and size.
SDL_Rect rect;
SDL_DisplayID display = SDL_GetDisplayForWindow(_window);
SDL_GetDisplayUsableBounds(display, &rect); // Excludes taskbar etc.
@@ -560,20 +562,11 @@ void SDLWindow::HandleEvent(SDL_Event& event)
auto size = GetClientSize();
if (pos.X < rect.x || pos.Y < rect.y || size.X > rect.w || size.Y > rect.h)
{
// Disable resizable flag so SDL updates the client rectangle to expected values during WM_NCCALCSIZE
SDL_SetWindowResizable(_window, false);
SDL_MaximizeWindow(_window);
SDL_RestoreWindow(_window);
// Set the internal floating window rectangle to expected position
SetClientBounds(Rectangle((float)rect.x, (float)rect.y, (float)rect.w, (float)rect.h));
// Flush and handle the events again
::SetWindowPos((HWND)_handle, HWND_TOP, rect.x, rect.y, rect.w, rect.h, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOOWNERZORDER);
SDL_PumpEvents();
// Restore previous values
SDL_SetWindowResizable(_window, true);
SetClientBounds(_cachedClientRectangle);
_cachedClientRectangle.Size = Float2((float)rect.w, (float)rect.h);
}
}
#endif