From 571afca835b110ace69da8a30c58b7927791f027 Mon Sep 17 00:00:00 2001 From: Peter Date: Wed, 20 Feb 2013 22:24:24 +0000 Subject: [PATCH] Correct the calculation for the Win32 window size. Account for the frame and caption size to avoid clipping the status lines. --- src/win_console.c | 22 +++++++++++++++------- src/win_generic.c | 38 ++++---------------------------------- 2 files changed, 19 insertions(+), 41 deletions(-) diff --git a/src/win_console.c b/src/win_console.c index ff0b169..d5b9cdb 100644 --- a/src/win_console.c +++ b/src/win_console.c @@ -79,6 +79,17 @@ x_show_alert(int is_fatal, const char *str) return 0; } +void get_default_window_size(LPRECT rect) +{ + rect->left = 0; + rect->top = 0; + rect->bottom = X_A2_WINDOW_HEIGHT; + if (g_win_status_debug) + rect->bottom += (MAX_STATUS_LINES * 16) + 32; + rect->right = X_A2_WINDOW_WIDTH; + AdjustWindowRect(rect, WS_TILED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, FALSE); +} + int WINAPI WinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance, @@ -95,8 +106,6 @@ main(int argc, char **argv) WNDCLASS wndclass; RECT rect; - int height; - wndclass.style = 0; wndclass.lpfnWndProc = (WNDPROC)win_event_handler; @@ -115,17 +124,16 @@ main(int argc, char **argv) exit(1); } - height = X_A2_WINDOW_HEIGHT + (MAX_STATUS_LINES * 16) + 32; -// g_main_height = height; - + // Create the window. + get_default_window_size(&rect); HWND hwnd = CreateWindowEx(WS_EX_ACCEPTFILES, "gsport", "GSport - Apple //gs Emulator", WS_TILED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, - X_A2_WINDOW_WIDTH, height, + rect.right, rect.bottom, NULL, NULL, GetModuleHandle(NULL), NULL); - printf("g_hwnd_main = %p, height = %d\n", hwnd, height); + printf("g_hwnd_main = %p, height = %d\n", hwnd, rect.bottom); GetWindowRect(hwnd, &rect); printf("...rect is: %ld, %ld, %ld, %ld\n", rect.left, rect.top, rect.right, rect.bottom); diff --git a/src/win_generic.c b/src/win_generic.c index a542969..87e5c1d 100644 --- a/src/win_generic.c +++ b/src/win_generic.c @@ -829,39 +829,6 @@ x_hide_pointer(int do_hide) } } -void -init_window(HWND hwnd,BOOL initFlag) { - RECT rect; - RECT wrect; - int adjx,adjy; - GetClientRect(hwnd,&rect); - GetWindowRect(hwnd,&wrect); - adjx=(wrect.right-wrect.left)-(rect.right-rect.left); - adjy=(wrect.bottom-wrect.top)-(rect.bottom-rect.top); - - int win_height= X_A2_WINDOW_HEIGHT; - - if (g_win_status_debug) { - win_height+=(MAX_STATUS_LINES * 16) + 32; - } - - if (initFlag) { - SetWindowPos(hwnd,NULL, - g_main_window_saved_rect.left, - g_main_window_saved_rect.top, - X_A2_WINDOW_WIDTH+adjx, - win_height+adjy, - SWP_NOACTIVATE | SWP_NOZORDER); - } else { - SetWindowPos(hwnd,HWND_NOTOPMOST, - g_main_window_saved_rect.left, - g_main_window_saved_rect.top, - X_A2_WINDOW_WIDTH+adjx, - win_height+adjy, - SWP_SHOWWINDOW); - } -} - void x_full_screen(int do_full) { @@ -910,7 +877,10 @@ x_full_screen(int do_full) style=GetWindowLong(g_hwnd_main,GWL_STYLE); style |= WS_CAPTION; SetWindowLong(g_hwnd_main,GWL_STYLE,style); - init_window(g_hwnd_main,FALSE); + SetWindowPos(g_hwnd_main, HWND_TOPMOST, + g_main_window_saved_rect.top, g_main_window_saved_rect.left, + g_main_window_saved_rect.right - g_main_window_saved_rect.left, g_main_window_saved_rect.bottom - g_main_window_saved_rect.top, + SWP_SHOWWINDOW); g_win_fullscreen_state=!g_win_fullscreen_state; } }