From 9e82927f50b059442b2e672b50a7969c0b378f27 Mon Sep 17 00:00:00 2001 From: rt Date: Sun, 30 Sep 2018 01:57:33 +0200 Subject: [PATCH] fix #6046 #5326 #5222 #4663 one small step for Spring --- rts/Game/UI/MouseHandler.cpp | 9 +++++++++ rts/Game/UI/MouseHandler.h | 1 + 2 files changed, 10 insertions(+) diff --git a/rts/Game/UI/MouseHandler.cpp b/rts/Game/UI/MouseHandler.cpp index 26a4d184876..e8a9ccb7f96 100644 --- a/rts/Game/UI/MouseHandler.cpp +++ b/rts/Game/UI/MouseHandler.cpp @@ -216,6 +216,14 @@ void CMouseHandler::MouseMove(int x, int y, int dx, int dy) lastx = std::abs(x); lasty = std::abs(y); + // switching to MMB-mode while user is moving mouse can generate + // a spurious event in the opposite direction (if cursor happens + // to pass the center pixel) which would cause a camera position + // jump, so always ignore one SDL_MOUSEMOTION after entering it + dx *= (1 - ignoreMove); + dy *= (1 - ignoreMove); + + ignoreMove = false; // MouseInput passes negative coordinates when cursor leaves the window offscreen = (x < 0 && y < 0); @@ -691,6 +699,7 @@ void CMouseHandler::ToggleMiddleClickScroll() locked = !locked; mmbScroll = !mmbScroll; + ignoreMove = mmbScroll; } diff --git a/rts/Game/UI/MouseHandler.h b/rts/Game/UI/MouseHandler.h index 5b5550122c3..769464293b3 100644 --- a/rts/Game/UI/MouseHandler.h +++ b/rts/Game/UI/MouseHandler.h @@ -109,6 +109,7 @@ class CMouseHandler bool hwHideCursor = true; bool hardwareCursor = false; bool invertMouse = false; + bool ignoreMove = false; float cursorScale = 1.0f; float dragScrollThreshold = 0.0f;