]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - vid_sdl.c
Remove a bit of cruft left in Cvar_RestoreInitState()
[xonotic/darkplaces.git] / vid_sdl.c
index 6f39dd5f72791d069c9d311bfb95e83eb618c30c..bcb2d139d7506df158665925a6a4638f229b60a1 100644 (file)
--- a/vid_sdl.c
+++ b/vid_sdl.c
@@ -1489,6 +1489,12 @@ static void VID_SetVsync_c(cvar_t *var)
                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;
@@ -1519,9 +1525,11 @@ void VID_Init (void)
        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());
+               Sys_Abort ("Failed to init SDL video subsystem: %s", SDL_GetError());
        if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0)
                Con_Printf(CON_ERROR "Failed to init SDL joystick subsystem: %s\n", SDL_GetError());
 
@@ -1720,8 +1728,7 @@ static qbool VID_InitModeGL(viddef_mode_t *mode)
        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);
@@ -1767,7 +1774,7 @@ static qbool VID_InitModeGL(viddef_mode_t *mode)
 
        context = SDL_GL_CreateContext(window);
        if (context == NULL)
-               Sys_Error("Failed to initialize OpenGL context: %s\n", SDL_GetError());
+               Sys_Abort("Failed to initialize OpenGL context: %s\n", SDL_GetError());
 
        GL_InitFunctions();
 
@@ -1782,7 +1789,7 @@ static qbool VID_InitModeGL(viddef_mode_t *mode)
                SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY);
                context = SDL_GL_CreateContext(window);
                if (context == NULL)
-                       Sys_Error("Failed to initialize OpenGL context: %s\n", SDL_GetError());
+                       Sys_Abort("Failed to initialize OpenGL context: %s\n", SDL_GetError());
        }
 #endif
 
@@ -1820,7 +1827,7 @@ qbool VID_InitMode(viddef_mode_t *mode)
        steelstorm_showing_mousecursor = Cvar_FindVar(&cvars_all, "steelstorm_showing_mousecursor", ~0);
 
        if (!SDL_WasInit(SDL_INIT_VIDEO) && SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
-               Sys_Error ("Failed to init SDL video subsystem: %s", SDL_GetError());
+               Sys_Abort ("Failed to init SDL video subsystem: %s", SDL_GetError());
 
        Cvar_SetValueQuick(&vid_touchscreen_supportshowkeyboard, SDL_HasScreenKeyboardSupport() ? 1 : 0);
        return VID_InitModeGL(mode);