]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - vid_glx.c
independent volume control for the 8 entity channels
[xonotic/darkplaces.git] / vid_glx.c
index 8467bd7a7b19c208349278bdce2169373ebcd16f..4050a1c8f531ca5b90cf4bf2d05ecb2371ef628d 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"
@@ -256,6 +257,9 @@ void VID_SetMouse(qboolean fullscreengrab, qboolean relative, qboolean hidecurso
        if (!vidx11_display || !win)
                return;
 
+       if (relative)
+               fullscreengrab = true;
+
        if (!mouse_avail)
                fullscreengrab = relative = hidecursor = false;
 
@@ -401,8 +405,8 @@ 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 (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)
                                                        dowarp = true;
                                        }
                                }
@@ -491,9 +495,16 @@ static void HandleEvents(void)
        if (dowarp)
        {
                /* move the mouse to the window center again */
-               in_windowmouse_x = (int)(vid.width / 2);
-               in_windowmouse_y = (int)(vid.height / 2);
-               XWarpPointer(vidx11_display, None, win, 0, 0, 0, 0, (int)in_windowmouse_x, (int)in_windowmouse_y);
+               // we'll catch the warp motion by its send_event flag, updating the
+               // stored mouse position without adding any delta motion
+               XEvent event;
+               event.type = MotionNotify;
+               event.xmotion.display = vidx11_display;
+               event.xmotion.window = win;
+               event.xmotion.x = vid.width / 2;
+               event.xmotion.y = vid.height / 2;
+               XSendEvent(vidx11_display, win, False, PointerMotionMask, &event);
+               XWarpPointer(vidx11_display, None, win, 0, 0, 0, 0, vid.width / 2, vid.height / 2);
        }
 }
 
@@ -688,6 +699,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);