Fix: Update Window Positions on File Load

When we create a new window at run time, we request that it be placed
at a specific size and location, but afterward we ask the OS for
details about where it was actually made and then update the window's
size and position with the correct information. Unfortunately when we
open a window when loading a blend file we do most of this, but only
update the size from the OS, not the position. There are times a window
will need to be placed somewhere different than we request and so the
window posx and posy will be incorrect until we move or resize it. This
is more likely to happen on Macs, but is possible on any platform.

Pull Request: https://projects.blender.org/blender/blender/pulls/127819
This commit is contained in:
Harley Acheson
2024-09-19 01:41:58 +02:00
committed by Harley Acheson
parent aa5385f648
commit 23d0034a1b

View File

@@ -716,6 +716,8 @@ static void wm_window_ensure_eventstate(wmWindow *win)
wm_window_update_eventstate(win);
}
static bool wm_window_update_size_position(wmWindow *win);
/* Belongs to below. */
static void wm_window_ghostwindow_add(wmWindowManager *wm,
const char *title,
@@ -779,17 +781,12 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm,
wm_window_ensure_eventstate(win);
/* Store actual window size in blender window. */
GHOST_RectangleHandle bounds = GHOST_GetClientBounds(
static_cast<GHOST_WindowHandle>(win->ghostwin));
/* WIN32: gives undefined window size when minimized. */
if (GHOST_GetWindowState(static_cast<GHOST_WindowHandle>(win->ghostwin)) !=
GHOST_kWindowStateMinimized)
{
win->sizex = GHOST_GetWidthRectangle(bounds);
win->sizey = GHOST_GetHeightRectangle(bounds);
wm_window_update_size_position(win);
}
GHOST_DisposeRectangle(bounds);
#ifndef __APPLE__
/* Set the state here, so minimized state comes up correct on windows. */