fixed win32 window sizes
This commit is contained in:
parent
def04a9361
commit
d35c30c81c
1 changed files with 12 additions and 1 deletions
|
|
@ -216,6 +216,7 @@ PGPL_Window *pgpl_window_create(const char *title, uint32_t width,
|
||||||
y, width, height, NULL, NULL, window->wc.hInstance, NULL);
|
y, width, height, NULL, NULL, window->wc.hInstance, NULL);
|
||||||
|
|
||||||
if (window->hwnd == NULL) {
|
if (window->hwnd == NULL) {
|
||||||
|
pgpl_log_message(PGPL_LOG_LEVEL_ERROR, "Couldn't create win32 Window!");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -228,6 +229,11 @@ PGPL_Window *pgpl_window_create(const char *title, uint32_t width,
|
||||||
|
|
||||||
window->wgl_context = wglCreateContext(window->hdc);
|
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;
|
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,
|
void pgpl_window_set_size(PGPL_Window *window, uint32_t width,
|
||||||
uint32_t height) {
|
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) {
|
void pgpl_window_get_position(PGPL_Window *window, int32_t *x, int32_t *y) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue