win32: initial position: center with borders

Previously, the initial positioning and fit ignored the borders, and
centered the content (the video itself) at the working area.

Now, the initial positioning centers the window, by subtracting the
borders (if needed) from the target area for the initial fit/position.

While this does mean that the initial maximum content area is now
smaller than before, ultimately this has no impact on the window size,
because fit_on_screen is called later and, if needed, further shrinks
the window to fit the borders too - but without centering the window.

So the net impact of this commit is only the initial positioning (same
size as before), which now centers the window instead of the content.

Note that on Windows 10 the borders include invisible areas at the
sides and bottom of the window (for mouse edge-drag), so visibly the
window is nearer to the top than to the bottom, but these are the
metrics we have (fit_on_screen uses the same border size values).

On Windows 7 it looks perfectly centered.
This commit is contained in:
Avi Halachmi (:avih) 2021-08-13 00:49:09 +03:00 committed by avih
parent 73f16b5431
commit 8fb4fd9a18
1 changed files with 2 additions and 0 deletions

View File

@ -1419,6 +1419,8 @@ static void gui_thread_reconfig(void *ptr)
struct vo *vo = w32->vo;
RECT r = get_working_area(w32);
if (!w32->current_fs && !IsMaximized(w32->window) && w32->opts->border)
subtract_window_borders(w32, w32->window, &r);
struct mp_rect screen = { r.left, r.top, r.right, r.bottom };
struct vo_win_geometry geo;