From d1b77d4b68fbf1129fd84a8d411d1c12d57ba0ee Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Fri, 15 Sep 2017 22:59:18 -0500 Subject: BACKENDS: Fix missing mouse events when system cursor cannot be moved Normally with SDL, a mouse motion event will be sent after the system mouse cursor has been moved by a call to SDL_WarpMouseInWindow, but if the system cursor cannot be moved (e.g. because the window does not have mouse focus), games still need to receive these mouse events so they can successfully update the mouse position internally. Otherwise, games continue to think the mouse is still in the original position and will continue to try to perform whatever action is associated with that mouse position. Refs Trac#9689. --- backends/graphics/sdl/sdl-graphics.cpp | 7 +++++++ backends/graphics/sdl/sdl-graphics.h | 5 +---- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'backends/graphics') diff --git a/backends/graphics/sdl/sdl-graphics.cpp b/backends/graphics/sdl/sdl-graphics.cpp index e6699df1cd..64ee9f7aa1 100644 --- a/backends/graphics/sdl/sdl-graphics.cpp +++ b/backends/graphics/sdl/sdl-graphics.cpp @@ -212,6 +212,13 @@ bool SdlGraphicsManager::notifyMousePosition(Common::Point &mouse) { return valid; } +void SdlGraphicsManager::setSystemMousePosition(const int x, const int y) { + assert(_window); + if (!_window->warpMouseInWindow(x, y)) { + _eventSource->fakeWarpMouse(x, y); + } +} + void SdlGraphicsManager::handleResizeImpl(const int width, const int height) { _eventSource->resetKeyboardEmulation(width - 1, height - 1); _forceRedraw = true; diff --git a/backends/graphics/sdl/sdl-graphics.h b/backends/graphics/sdl/sdl-graphics.h index 993a1c3db6..526306270b 100644 --- a/backends/graphics/sdl/sdl-graphics.h +++ b/backends/graphics/sdl/sdl-graphics.h @@ -150,10 +150,7 @@ protected: #endif } - virtual void setSystemMousePosition(const int x, const int y) override { - assert(_window); - _window->warpMouseInWindow(x, y); - } + virtual void setSystemMousePosition(const int x, const int y) override; virtual void handleResizeImpl(const int width, const int height) override; -- cgit v1.2.3