]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - vid_glx.c
Added snd_channellayout to configure the speaker layout dynamically (0: auto, 1:...
[xonotic/darkplaces.git] / vid_glx.c
index eab081aad9cc7f655986244d7e6b12ce2fe4fb79..04d6516ac50c4294fff924d9877747a822c4393f 100644 (file)
--- a/vid_glx.c
+++ b/vid_glx.c
@@ -17,12 +17,6 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
 
-//#include <termios.h>
-//#include <sys/ioctl.h>
-//#include <sys/stat.h>
-//#include <sys/vt.h>
-//#include <stdarg.h>
-//#include <stdio.h>
 #include <signal.h>
 
 #include <dlfcn.h>
@@ -93,6 +87,8 @@ static qboolean mouse_avail = true;
 static qboolean vid_usingmouse = false;
 static qboolean vid_usingvsync = false;
 static qboolean vid_usevsync = false;
+static qboolean vid_x11_hardwaregammasupported = false;
+static int vid_x11_gammarampsize = 0;
 static float   mouse_x, mouse_y;
 static int p_mouse_x, p_mouse_y;
 
@@ -197,6 +193,7 @@ static int XLateKey(XKeyEvent *ev, char *ascii)
 
                case XK_Alt_L:
                case XK_Meta_L:
+               case XK_ISO_Level3_Shift:
                case XK_Alt_R:
                case XK_Meta_R: key = K_ALT;                    break;
 
@@ -561,7 +558,6 @@ void InitSig(void)
 
 void VID_Finish (qboolean allowmousegrab)
 {
-       int rampsize;
        qboolean vid_usemouse;
 
        vid_usevsync = vid_vsync.integer && !cls.timedemo && gl_videosyncavailable;
@@ -572,9 +568,9 @@ void VID_Finish (qboolean allowmousegrab)
                        Con_Print("glXSwapIntervalSGI didn't accept the vid_vsync change, it will take effect on next vid_restart (GLX_SGI_swap_control does not allow turning off vsync)\n");
        }
 
-// handle the mouse state when windowed if that's changed
+       // handle the mouse state when windowed if that's changed
        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_activewindow)
                vid_usemouse = false;
@@ -584,13 +580,16 @@ void VID_Finish (qboolean allowmousegrab)
 
        if (r_render.integer)
        {
+               CHECKGLERROR
                if (r_speeds.integer || gl_finish.integer)
-                       qglFinish();
-               qglXSwapBuffers(vidx11_display, win);
+               {
+                       qglFinish();CHECKGLERROR
+               }
+               qglXSwapBuffers(vidx11_display, win);CHECKGLERROR
        }
 
-       if(XF86VidModeGetGammaRampSize(vidx11_display, vidx11_screen, &rampsize))
-               VID_UpdateGamma(false, rampsize);
+       if (vid_x11_hardwaregammasupported)
+               VID_UpdateGamma(false, vid_x11_gammarampsize);
 }
 
 int VID_SetGamma(unsigned short *ramps, int rampsize)
@@ -837,12 +836,27 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate
        vid_usingvsync = false;
        vid_hidden = false;
        vid_activewindow = true;
+       vid_x11_hardwaregammasupported = XF86VidModeGetGammaRampSize(vidx11_display, vidx11_screen, &vid_x11_gammarampsize) != 0;
        GL_Init();
        return true;
 }
 
 void Sys_SendKeyEvents(void)
 {
+       static qboolean sound_active = true;
+
+       // 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;
+       }
+
        HandleEvents();
 }