From e050ca89c7c9c06eded2cacb3c50a301883f8435 Mon Sep 17 00:00:00 2001 From: radius Date: Thu, 6 Dec 2018 10:03:48 -0500 Subject: [PATCH 1/2] make windowed size take into account window border and title height --- gfx/common/win32_common.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index f9314ada30..25552ed318 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -622,18 +622,22 @@ static LRESULT win32_handle_keyboard_event(HWND hwnd, UINT message, static void win32_set_position_from_config(void) { settings_t *settings = config_get_ptr(); + int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); + int title_bar_height = GetSystemMetrics(SM_CYCAPTION); if (!settings->bools.video_window_save_positions) return; g_win32_pos_x = settings->uints.window_position_x; g_win32_pos_y = settings->uints.window_position_y; - g_win32_pos_width = settings->uints.window_position_width; - g_win32_pos_height= settings->uints.window_position_height; + g_win32_pos_width = settings->uints.window_position_width + border_thickness * 2; + g_win32_pos_height= settings->uints.window_position_height + border_thickness * 2 + title_bar_height; } static void win32_save_position(void) { RECT rect; + int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); + int title_bar_height = GetSystemMetrics(SM_CYCAPTION); WINDOWPLACEMENT placement; settings_t *settings = config_get_ptr(); memset(&placement, 0, sizeof(placement)); @@ -655,8 +659,8 @@ static void win32_save_position(void) { settings->uints.window_position_x = g_win32_pos_x; settings->uints.window_position_y = g_win32_pos_y; - settings->uints.window_position_width = g_win32_pos_width; - settings->uints.window_position_height = g_win32_pos_height; + settings->uints.window_position_width = g_win32_pos_width - border_thickness * 2; + settings->uints.window_position_height = g_win32_pos_height - border_thickness * 2 - title_bar_height; } } } From defe82c9ceb3357c8b4f3f75b27a6d89193d1e45 Mon Sep 17 00:00:00 2001 From: radius Date: Thu, 6 Dec 2018 10:15:50 -0500 Subject: [PATCH 2/2] fix the menubar height growing issue too --- gfx/common/win32_common.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index 25552ed318..a9d96062e0 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -624,6 +624,7 @@ static void win32_set_position_from_config(void) settings_t *settings = config_get_ptr(); int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); int title_bar_height = GetSystemMetrics(SM_CYCAPTION); + int menu_bar_height = GetSystemMetrics(SM_CYMENU); if (!settings->bools.video_window_save_positions) return; @@ -638,6 +639,7 @@ static void win32_save_position(void) RECT rect; int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); int title_bar_height = GetSystemMetrics(SM_CYCAPTION); + int menu_bar_height = GetSystemMetrics(SM_CYMENU); WINDOWPLACEMENT placement; settings_t *settings = config_get_ptr(); memset(&placement, 0, sizeof(placement)); @@ -660,7 +662,7 @@ static void win32_save_position(void) settings->uints.window_position_x = g_win32_pos_x; settings->uints.window_position_y = g_win32_pos_y; settings->uints.window_position_width = g_win32_pos_width - border_thickness * 2; - settings->uints.window_position_height = g_win32_pos_height - border_thickness * 2 - title_bar_height; + settings->uints.window_position_height = g_win32_pos_height - border_thickness * 2 - title_bar_height - (settings->bools.ui_menubar_enable ? menu_bar_height : 0); } } }