From 364af7c6307770e48db89ad11a21724e78634e9f Mon Sep 17 00:00:00 2001 From: maniak1349 Date: Sat, 21 May 2016 22:34:53 +0300 Subject: 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). --- video/out/w32_common.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'video/out/w32_common.c') 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 -- cgit v1.2.3