]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - vid_sdl.c
- the Linux sound modules (ALSA and OSS) are now write-based, instead of
[xonotic/darkplaces.git] / vid_sdl.c
index 0df9e422a0b1649ca1d809584d86c9c1bdc23d13..c3cfda10a498ba8b0891a70512c0477b391d26ff 100644 (file)
--- a/vid_sdl.c
+++ b/vid_sdl.c
@@ -181,7 +181,7 @@ static unsigned int tbl_sdltoquake[] =
        0,                      //SDLK_LMETA    = 310,
        0,                      //SDLK_LSUPER   = 311,          /* Left "Windows" key */
        0,                      //SDLK_RSUPER   = 312,          /* Right "Windows" key */
-       0,                      //SDLK_MODE             = 313,          /* "Alt Gr" key */
+       K_ALT,                  //SDLK_MODE             = 313,          /* "Alt Gr" key */
        0,                      //SDLK_COMPOSE  = 314,          /* Multi-key compose key */
        0,                      //SDLK_HELP             = 315,
        0,                      //SDLK_PRINT    = 316,
@@ -279,6 +279,7 @@ static keynum_t buttonremap[18] =
 
 void Sys_SendKeyEvents( void )
 {
+       static qboolean sound_active = true;
        SDL_Event event;
 
        while( SDL_PollEvent( &event ) )
@@ -308,6 +309,18 @@ void Sys_SendKeyEvents( void )
                                        Key_Event( buttonremap[event.button.button - 1], 0, false );
                                break;
                }
+
+       // enable/disable sound on focus gain/loss
+       if (!vid_activewindow && sound_active)
+       {
+               S_BlockSound ();
+               sound_active = false;
+       }
+       else if (vid_activewindow && !sound_active)
+       {
+               S_UnblockSound ();
+               sound_active = true;
+       }
 }
 
 /////////////////
@@ -488,10 +501,6 @@ void VID_Finish (qboolean allowmousegrab)
        Uint8 appstate;
        qboolean vid_usemouse;
 
-       if (r_speeds.integer || gl_finish.integer)
-               qglFinish();
-       SDL_GL_SwapBuffers();
-
        //react on appstate changes
        appstate = SDL_GetAppState();
 
@@ -503,7 +512,7 @@ void VID_Finish (qboolean allowmousegrab)
                vid_activewindow = true;
 
        vid_usemouse = false;
-       if( allowmousegrab && vid_mouse.integer && !key_consoleactive && !cls.demoplayback )
+       if( allowmousegrab && vid_mouse.integer && !key_consoleactive && (key_dest != key_game || !cls.demoplayback) )
                vid_usemouse = true;
        if( vid_isfullscreen )
                vid_usemouse = true;
@@ -513,4 +522,14 @@ void VID_Finish (qboolean allowmousegrab)
        IN_Activate(vid_usemouse);
 
        VID_UpdateGamma(false, 256);
+
+       if (r_render.integer && !vid_hidden)
+       {
+               CHECKGLERROR
+               if (r_speeds.integer || gl_finish.integer)
+               {
+                       qglFinish();CHECKGLERROR
+               }
+               SDL_GL_SwapBuffers();
+       }
 }