From 8f3d69f3e83560b168cc43afc57ca52126b81c8d Mon Sep 17 00:00:00 2001 From: Harry Jeffery Date: Sat, 2 Dec 2017 15:55:07 +0000 Subject: Add options for window width and height Fixes #120 --- src/imv.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/imv.c b/src/imv.c index f664081..9bbd492 100644 --- a/src/imv.c +++ b/src/imv.c @@ -51,6 +51,8 @@ struct imv { bool quit; bool loading; bool fullscreen; + int initial_width; + int initial_height; bool overlay_enabled; enum upscaling_method upscaling_method; bool stay_fullscreen_on_focus_loss; @@ -147,6 +149,8 @@ struct imv *imv_create(void) imv->quit = false; imv->loading = false; imv->fullscreen = false; + imv->initial_width = 1280; + imv->initial_height = 720; imv->overlay_enabled = false; imv->upscaling_method = UPSCALING_LINEAR; imv->stay_fullscreen_on_focus_loss = false; @@ -651,16 +655,11 @@ static bool setup_window(struct imv *imv) imv->sdl_init = true; - /* width and height arbitrarily chosen. Perhaps there's a smarter way to - * set this */ - const int width = 1280; - const int height = 720; - imv->window = SDL_CreateWindow( "imv", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, - width, height, + imv->initial_width, imv->initial_height, SDL_WINDOW_RESIZABLE); if(!imv->window) { @@ -955,6 +954,15 @@ static int handle_ini_value(void *user, const char *section, const char *name, return 1; } + if(!strcmp(name, "width")) { + imv->initial_width = strtol(value, NULL, 10); + return 1; + } + if(!strcmp(name, "height")) { + imv->initial_height = strtol(value, NULL, 10); + return 1; + } + if(!strcmp(name, "overlay")) { imv->overlay_enabled = parse_bool(value); return 1; -- cgit v1.2.3