From d9d1a7c603386716638e6a62a7cc97d02e3d1e53 Mon Sep 17 00:00:00 2001 From: Harry Jeffery Date: Tue, 28 Nov 2017 22:45:28 +0000 Subject: Add stay_fullscreen_on_focus_loss option Fixes #103 --- files/imv_config | 3 +++ src/imv.c | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/files/imv_config b/files/imv_config index 08afc48..fc0f4b2 100644 --- a/files/imv_config +++ b/files/imv_config @@ -32,6 +32,9 @@ # Font to use for the overlay # overlay_font = Monospace:24 +# Stay fullscreen when we lose focus +# stay_fullscreen_on_focus_loss = true + # Disable imv's builtin binds so they don't conflict with the ones in this config suppress_default_binds = true diff --git a/src/imv.c b/src/imv.c index 1968401..9f6562b 100644 --- a/src/imv.c +++ b/src/imv.c @@ -46,6 +46,7 @@ struct imv { bool fullscreen; bool overlay_enabled; bool nearest_neighbour; + bool stay_fullscreen_on_focus_loss; bool need_redraw; bool need_rescale; bool recursive_load; @@ -135,6 +136,7 @@ struct imv *imv_create(void) imv->fullscreen = false; imv->overlay_enabled = false; imv->nearest_neighbour = false; + imv->stay_fullscreen_on_focus_loss = false; imv->need_redraw = true; imv->need_rescale = true; imv->recursive_load = false; @@ -611,6 +613,10 @@ static bool setup_window(struct imv *imv) SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, imv->nearest_neighbour ? "0" : "1"); + /* allow fullscreen to be maintained even when focus is lost */ + SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, + imv->stay_fullscreen_on_focus_loss ? "0" : "1"); + /* construct a chequered background image */ if(imv->background_type == BACKGROUND_CHEQUERED) { imv->background_image = create_chequered(imv->renderer); @@ -897,6 +903,11 @@ static int handle_ini_value(void *user, const char *section, const char *name, return 1; } + if(!strcmp(name, "stay_fullscreen_on_focus_loss")) { + imv->stay_fullscreen_on_focus_loss = parse_bool(value); + return 1; + } + if(!strcmp(name, "recursive")) { imv->recursive_load = parse_bool(value); return 1; -- cgit v1.2.3