extern cvar_t vid_vsync;
extern cvar_t vid_mouse;
extern cvar_t vid_mouse_clickthrough;
+extern cvar_t vid_minimize_on_focus_loss;
extern cvar_t vid_grabkeyboard;
extern cvar_t vid_touchscreen;
extern cvar_t vid_touchscreen_showkeyboard;
Con_Printf(CON_ERROR "ERROR: can't %s vsync because %s\n", vsyncwanted ? "activate" : "deactivate", SDL_GetError());
}
+static void VID_SetHints_c(cvar_t *var)
+{
+ SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, vid_mouse_clickthrough.integer ? "1" : "0");
+ SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, vid_minimize_on_focus_loss.integer ? "1" : "0");
+}
+
void VID_Init (void)
{
SDL_version version;
Cvar_RegisterCallback(&vid_resizable, VID_ChangeDisplay_c);
Cvar_RegisterCallback(&vid_borderless, VID_ChangeDisplay_c);
Cvar_RegisterCallback(&vid_vsync, VID_SetVsync_c);
+ Cvar_RegisterCallback(&vid_mouse_clickthrough, VID_SetHints_c);
+ Cvar_RegisterCallback(&vid_minimize_on_focus_loss, VID_SetHints_c);
if (SDL_Init(SDL_INIT_VIDEO) < 0)
Sys_Error ("Failed to init SDL video subsystem: %s", SDL_GetError());
SDL_SetHint(SDL_HINT_WINDOWS_DPI_AWARENESS, "1");
#endif
- if (vid_mouse_clickthrough.integer)
- SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1");
+ VID_SetHints_c(NULL);
SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute (SDL_GL_RED_SIZE, 8);
cvar_t vid_vsync = {CF_CLIENT | CF_ARCHIVE, "vid_vsync", "0", "sync to vertical blank, prevents 'tearing' (seeing part of one frame and part of another on the screen at the same time) at the cost of latency, 1 always syncs and -1 is adaptive (stops syncing if the framerate drops, unsupported by some platforms), automatically disabled when doing timedemo benchmarks"};
cvar_t vid_mouse = {CF_CLIENT | CF_ARCHIVE, "vid_mouse", "1", "whether to use the mouse in windowed mode (fullscreen always does)"};
cvar_t vid_mouse_clickthrough = {CF_CLIENT | CF_ARCHIVE, "vid_mouse_clickthrough", "0", "mouse behavior in windowed mode: 0 = click to focus, 1 = allow interaction even if the window is not focused (click-through behaviour, can be useful when using third-party game overlays)"};
+cvar_t vid_minimize_on_focus_loss = {CF_CLIENT | CF_ARCHIVE, "vid_minimize_on_focus_loss", "0", "whether to minimize the fullscreen window if it loses focus (such as by alt+tab)"};
cvar_t vid_grabkeyboard = {CF_CLIENT | CF_ARCHIVE, "vid_grabkeyboard", "0", "whether to grab the keyboard when mouse is active (prevents use of volume control keys, music player keys, etc on some keyboards)"};
cvar_t vid_minwidth = {CF_CLIENT, "vid_minwidth", "0", "minimum vid_width that is acceptable (to be set in default.cfg in mods)"};
cvar_t vid_minheight = {CF_CLIENT, "vid_minheight", "0", "minimum vid_height that is acceptable (to be set in default.cfg in mods)"};
Cvar_RegisterVariable(&vid_vsync);
Cvar_RegisterVariable(&vid_mouse);
Cvar_RegisterVariable(&vid_mouse_clickthrough);
+ Cvar_RegisterVariable(&vid_minimize_on_focus_loss);
Cvar_RegisterVariable(&vid_grabkeyboard);
Cvar_RegisterVariable(&vid_touchscreen);
Cvar_RegisterVariable(&vid_touchscreen_showkeyboard);