Fix workaround for maximizing Editor window
This commit is contained in:
@@ -60,10 +60,10 @@ bool SDLPlatform::Init()
|
||||
SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1"); // Fixes context menu focus issues when clicking unfocused menus
|
||||
SDL_SetHint(SDL_HINT_WINDOWS_ERASE_BACKGROUND_MODE, "0");
|
||||
SDL_SetHint(SDL_HINT_TIMER_RESOLUTION, "0"); // Already handled during platform initialization
|
||||
SDL_SetHint("SDL_BORDERLESS_RESIZABLE_STYLE", "1"); // Allow borderless windows to be resizable on Windows
|
||||
SDL_SetHint("SDL_BORDERLESS_RESIZABLE_STYLE", "1"); // Allow borderless windows to be resizable on Windows, currently breaks maximize window functionality
|
||||
SDL_SetHint(SDL_HINT_MOUSE_RELATIVE_WARP_MOTION, "0");
|
||||
SDL_SetHint(SDL_HINT_MOUSE_RELATIVE_CURSOR_VISIBLE, "1"); // Needed for tracking mode
|
||||
SDL_SetHint(SDL_HINT_MOUSE_RELATIVE_MODE_CENTER, "1");
|
||||
SDL_SetHint(SDL_HINT_MOUSE_RELATIVE_MODE_CENTER, "1"); // Is this needed?
|
||||
|
||||
//SDL_SetHint(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, "1"); // Disables raw mouse input
|
||||
SDL_SetHint(SDL_HINT_WINDOWS_RAW_KEYBOARD, "1");
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user