diff --git a/src/window/window-win32.c b/src/window/window-win32.c index 6e3eb2d..e246be1 100644 --- a/src/window/window-win32.c +++ b/src/window/window-win32.c @@ -216,6 +216,7 @@ PGPL_Window *pgpl_window_create(const char *title, uint32_t width, y, width, height, NULL, NULL, window->wc.hInstance, NULL); if (window->hwnd == NULL) { + pgpl_log_message(PGPL_LOG_LEVEL_ERROR, "Couldn't create win32 Window!"); return NULL; } @@ -228,6 +229,11 @@ PGPL_Window *pgpl_window_create(const char *title, uint32_t width, window->wgl_context = wglCreateContext(window->hdc); + /* Adjust size, because window creation subtracts window decorations. This + * could be done here as well, but that would be code repetition, so I will + * simply call the function that already does it. */ + pgpl_window_set_size(window, width, height); + return window; } @@ -271,7 +277,12 @@ void pgpl_window_get_size(PGPL_Window *window, uint32_t *width, void pgpl_window_set_size(PGPL_Window *window, uint32_t width, uint32_t height) { - SetWindowPos(window->hwnd, NULL, 0, 0, width, height, SWP_NOMOVE); + int border_x = GetSystemMetrics(SM_CXSIZEFRAME) * 2; + int border_y = + GetSystemMetrics(SM_CYSIZEFRAME) * 2 + GetSystemMetrics(SM_CYCAPTION); + + SetWindowPos(window->hwnd, NULL, 0, 0, width + border_x, height + border_y, + SWP_NOMOVE); } void pgpl_window_get_position(PGPL_Window *window, int32_t *x, int32_t *y) {