From 3a1a0c88717efbc40b4f0c6ab6628f3e9e98fad8 Mon Sep 17 00:00:00 2001 From: Ronald Kinard Date: Fri, 25 Jul 2014 23:47:14 -0500 Subject: [PATCH] sdl2: fix mouse grabbing in windowed Should now ignore all motion events and not warp the mouse when the window is out of focus. --- src/sdl2/i_video.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/sdl2/i_video.c b/src/sdl2/i_video.c index 21c60cb22..c984a28e6 100644 --- a/src/sdl2/i_video.c +++ b/src/sdl2/i_video.c @@ -853,9 +853,12 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt) } event.type = ev_mouse; - D_PostEvent(&event); - HalfWarpMouse(wwidth, wheight); + if (SDL_GetMouseFocus() == window && SDL_GetKeyboardFocus() == window) + { + D_PostEvent(&event); + HalfWarpMouse(wwidth, wheight); + } } static void Impl_HandleMouseButtonEvent(SDL_MouseButtonEvent evt, Uint32 type)