From 3b5d4e2c0fc76dc1e8774279b5b6f018239ef21e Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Wed, 27 May 2020 20:38:27 +0300 Subject: [PATCH] client rect adjustment (windows) --- Makefile | 2 +- miniglut.c | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index accf05a..c10d2af 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ src = miniglut.c test.c obj = $(src:.c=.o) bin = test -CFLAGS = -pedantic -Wall -g +CFLAGS = -pedantic -Wall -O3 sys ?= $(shell uname -s | sed 's/MINGW.*/mingw/') ifeq ($(sys), mingw) diff --git a/miniglut.c b/miniglut.c index 346b1d4..669d81e 100644 --- a/miniglut.c +++ b/miniglut.c @@ -87,7 +87,7 @@ static void sys_exit(int status); static int sys_write(int fd, const void *buf, int count); -static int init_x, init_y, init_width = 256, init_height = 256; +static int init_x = -1, init_y, init_width = 256, init_height = 256; static unsigned int init_mode; static struct ctx_info ctx_info; @@ -140,6 +140,12 @@ void glutInit(int *argc, char **argv) if(!RegisterClassEx(&wc)) { panic("Failed to register \"MiniGLUT\" window class\n"); } + + if(init_x == -1) { + get_screen_size(&init_x, &init_y); + init_x >>= 3; + init_y >>= 3; + } #endif } @@ -1043,9 +1049,16 @@ static void create_window(const char *title) { int pixfmt; PIXELFORMATDESCRIPTOR pfd = {0}; + RECT rect; + + rect.left = init_x; + rect.top = init_y; + rect.right = init_x + init_width; + rect.bottom = init_y + init_height; + AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, 0); - if(!(win = CreateWindow("MiniGLUT", title, WS_OVERLAPPEDWINDOW, init_x, init_y, - init_width, init_height, 0, 0, hinst, 0))) { + if(!(win = CreateWindow("MiniGLUT", title, WS_OVERLAPPEDWINDOW, rect.left, rect.top, + rect.right - rect.left, rect.bottom - rect.top, 0, 0, hinst, 0))) { panic("Failed to create window\n"); } dc = GetDC(win); -- 1.7.10.4