From c1fe9f2a89718b8027ff7d212cf1ff450fce93a7 Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 14 Mar 2017 00:21:49 +0100 Subject: [PATCH] Avoid warping the mouse cursor more than necessary Apparently, the SDL_WarpMouseInWindow can be very expensive (anywhere from 0.1-5ms) due to XSync() in the implementation. This was causing no-grab=1 configurations to suffer from terrible stuttering when turning the view. --- components/sdlutil/sdlinputwrapper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/sdlutil/sdlinputwrapper.cpp b/components/sdlutil/sdlinputwrapper.cpp index 204680b445..c88210b0ac 100644 --- a/components/sdlutil/sdlinputwrapper.cpp +++ b/components/sdlutil/sdlinputwrapper.cpp @@ -329,8 +329,8 @@ InputWrapper::InputWrapper(SDL_Window* window, osg::ref_ptr v SDL_GetWindowSize(mSDLWindow, &width, &height); - const int FUDGE_FACTOR_X = width; - const int FUDGE_FACTOR_Y = height; + const int FUDGE_FACTOR_X = width/4; + const int FUDGE_FACTOR_Y = height/4; //warp the mouse if it's about to go outside the window if(evt.x - FUDGE_FACTOR_X < 0 || evt.x + FUDGE_FACTOR_X > width