diff options
author | maniak1349 <maniak1349@gmail.com> | 2016-05-21 22:34:53 +0300 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-05-22 14:31:37 +0200 |
commit | 364af7c6307770e48db89ad11a21724e78634e9f (patch) | |
tree | e88dc0801a0c5108deb4921f2f215adc5560ceff | |
parent | 981048e041bb96ca3028be507f3cd7f9d0a833b3 (diff) |
w32_common: center window on original window center on resize to fit screen
Center the window on the original window center instead of the screen center
when the window has been resized due to requested window size exceeding the
size of the screen.
If user moved the window, he probably did it for the reason and he probably
don't want it to get back to the center of the screen when he is resizing it
(with window-scale for example).
-rw-r--r-- | video/out/w32_common.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/video/out/w32_common.c b/video/out/w32_common.c index e3b1914494..56d0e2ed6b 100644 --- a/video/out/w32_common.c +++ b/video/out/w32_common.c @@ -1103,17 +1103,20 @@ static void reinit_window_state(struct vo_w32_state *w32) // Save new size w32->dw = n_w; w32->dh = n_h; + // Get old window center + long o_cx = r.left + (r.right - r.left) / 2; + long o_cy = r.top + (r.bottom - r.top) / 2; // Add window borders to the new window size r = (RECT){.right = n_w, .bottom = n_h}; add_window_borders(w32->window, &r); // Get top and left border size for client area position calculation long b_top = -r.top; long b_left = -r.left; - // Center the final window + // Center the final window around the old window center n_w = r.right - r.left; n_h = r.bottom - r.top; - r.left = w32->screenrc.x0 + screen_w / 2 - n_w / 2; - r.top = w32->screenrc.y0 + screen_h / 2 - n_h / 2; + r.left = o_cx - n_w / 2; + r.top = o_cy - n_h / 2; r.right = r.left + n_w; r.bottom = r.top + n_h; // Save new client area position |