aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarry Jeffery <harry@exec64.co.uk>2017-12-02 15:55:07 +0000
committerHarry Jeffery <harry@exec64.co.uk>2017-12-02 15:55:20 +0000
commit8f3d69f3e83560b168cc43afc57ca52126b81c8d (patch)
tree8ad1d3cd0608413a86eb3fd76daf81596d52efa0
parentd6992c20800d2f9dc579274690ab8350bdccf60a (diff)
downloadimv-8f3d69f3e83560b168cc43afc57ca52126b81c8d.tar.gz
Add options for window width and height
Fixes #120
-rw-r--r--doc/imv.5.txt6
-rw-r--r--src/imv.c20
2 files changed, 20 insertions, 6 deletions
diff --git a/doc/imv.5.txt b/doc/imv.5.txt
index 14a31b9..cb12eb3 100644
--- a/doc/imv.5.txt
+++ b/doc/imv.5.txt
@@ -31,6 +31,12 @@ The *[options]* section accepts the following settings:
*fullscreen* = <true|false>::
Start imv fullscreen. Defaults to 'false'.
+*width* = <width>::
+ Initial width of the imv window. Defaults to 1280.
+
+*height* = <height>::
+ Initial height of the imv window. Defaults to 720.
+
*list_files_at_exit* = <true|false>::
Print open files to stdout at exit, each on a separate line.
Defaults to 'false'.
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;