From: havoc Date: Sun, 18 May 2008 02:12:14 +0000 (+0000) Subject: fix problem with glx mouse not grabbing in nexuiz menu X-Git-Tag: xonotic-v0.1.0preview~2233 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=9aa95e15769aad35656137e5099f50ade2dfe571;p=xonotic%2Fdarkplaces.git fix problem with glx mouse not grabbing in nexuiz menu fix glx mouse warp problem, now produces an extra xmotion event sent to itself to indicate the warp happened before any real motions come in git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8300 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/vid_glx.c b/vid_glx.c index 8467bd7a..d3faef0f 100644 --- a/vid_glx.c +++ b/vid_glx.c @@ -256,6 +256,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 +404,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 +494,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); } }