]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - vid_glx.c
curl: longer URLs
[xonotic/darkplaces.git] / vid_glx.c
index d3faef0f1d69a1acf456cad38da0af967aba19b8..26f441b42c39b9596e848250f64b92d1077a955c 100644 (file)
--- a/vid_glx.c
+++ b/vid_glx.c
@@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
+#include <X11/XKBlib.h> // TODO possibly ifdef this out on non-supporting systems... Solaris (as always)?
 #include <GL/glx.h>
 
 #include "quakedef.h"
@@ -251,7 +252,14 @@ static Cursor CreateNullCursor(Display *display, Window root)
 
 void VID_SetMouse(qboolean fullscreengrab, qboolean relative, qboolean hidecursor)
 {
+       static int originalmouseparms_num;
+       static int originalmouseparms_denom;
+       static int originalmouseparms_threshold;
+       static qboolean restore_spi;
+
+#if !defined(__APPLE__) && !defined(SUNOS)
        qboolean usedgamouse;
+#endif
 
        if (!vidx11_display || !win)
                return;
@@ -262,8 +270,8 @@ void VID_SetMouse(qboolean fullscreengrab, qboolean relative, qboolean hidecurso
        if (!mouse_avail)
                fullscreengrab = relative = hidecursor = false;
 
-       usedgamouse = relative && vid_dgamouse.integer;
 #if !defined(__APPLE__) && !defined(SUNOS)
+       usedgamouse = relative && vid_dgamouse.integer;
        if (!vid_x11_dgasupported)
                usedgamouse = false;
        if (fullscreengrab && vid_usingmouse && (vid_usingdgamouse != usedgamouse))
@@ -309,6 +317,20 @@ void VID_SetMouse(qboolean fullscreengrab, qboolean relative, qboolean hidecurso
 #endif
                                XWarpPointer(vidx11_display, None, win, 0, 0, 0, 0, vid.width / 2, vid.height / 2);
 
+// COMMANDLINEOPTION: X11 Input: -noforcemparms disables setting of mouse parameters (not used with DGA, windows only)
+#if !defined(__APPLE__) && !defined(SUNOS)
+                       if (!COM_CheckParm ("-noforcemparms") && !usedgamouse)
+#else
+                       if (!COM_CheckParm ("-noforcemparms"))
+#endif
+                       {
+                               XGetPointerControl(vidx11_display, &originalmouseparms_num, &originalmouseparms_denom, &originalmouseparms_threshold);
+                               XChangePointerControl (vidx11_display, true, false, 1, 1, -1); // TODO maybe change threshold here, or remove this comment
+                               restore_spi = true;
+                       }
+                       else
+                               restore_spi = false;
+
                        cl_ignoremousemoves = 2;
                        vid_usingmouse = true;
                }
@@ -323,6 +345,11 @@ void VID_SetMouse(qboolean fullscreengrab, qboolean relative, qboolean hidecurso
                        vid_usingdgamouse = false;
 #endif
                        cl_ignoremousemoves = 2;
+
+                       if (restore_spi)
+                               XChangePointerControl (vidx11_display, true, true, originalmouseparms_num, originalmouseparms_denom, originalmouseparms_threshold);
+                       restore_spi = false;
+
                        vid_usingmouse = false;
                }
        }
@@ -405,7 +432,7 @@ static void HandleEvents(void)
                                                in_mouse_x += event.xmotion.x - in_windowmouse_x;
                                                in_mouse_y += event.xmotion.y - in_windowmouse_y;
                                                //if (abs(vid.width/2 - event.xmotion.x) + abs(vid.height/2 - event.xmotion.y))
-                                               if (abs(vid.width/2 - event.xmotion.x) > vid.width / 4 || abs(vid.height/2 - event.xmotion.y) > vid.height / 4)
+                                               if (vid_stick_mouse.integer || abs(vid.width/2 - event.xmotion.x) > vid.width / 4 || abs(vid.height/2 - event.xmotion.y) > vid.height / 4)
                                                        dowarp = true;
                                        }
                                }
@@ -698,6 +725,9 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate
                return false;
        }
 
+       // make autorepeat send keypress/keypress/.../keyrelease instead of intervening keyrelease
+       XkbSetDetectableAutoRepeat(vidx11_display, true, NULL);
+
        vidx11_screen = DefaultScreen(vidx11_display);
        root = RootWindow(vidx11_display, vidx11_screen);
 
@@ -724,13 +754,6 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate
 
        VID_BuildGLXAttrib(attrib, bpp == 32, stereobuffer, samples);
        visinfo = qglXChooseVisual(vidx11_display, vidx11_screen, attrib);
-       if (!visinfo && (samples == 1))
-       {
-                /* Some Mesa drivers reject sample buffers with 1 sample, so try
-                 * entirely without one */
-               VID_BuildGLXAttrib(attrib, bpp == 32, stereobuffer, 0);
-               visinfo = qglXChooseVisual(vidx11_display, vidx11_screen, attrib);
-       }
        if (!visinfo)
        {
                Con_Print("Couldn't get an RGB, Double-buffered, Depth visual\n");