diff options
author | Colin Snover | 2017-09-15 22:59:18 -0500 |
---|---|---|
committer | Colin Snover | 2017-10-15 13:24:21 -0500 |
commit | d1b77d4b68fbf1129fd84a8d411d1c12d57ba0ee (patch) | |
tree | 68c823dc0f1d81fb66234046aaced65514acbe2d /backends/platform/sdl | |
parent | cd538ffffab9e49443da4ee043916d8dc22c3c07 (diff) | |
download | scummvm-rg350-d1b77d4b68fbf1129fd84a8d411d1c12d57ba0ee.tar.gz scummvm-rg350-d1b77d4b68fbf1129fd84a8d411d1c12d57ba0ee.tar.bz2 scummvm-rg350-d1b77d4b68fbf1129fd84a8d411d1c12d57ba0ee.zip |
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.
Diffstat (limited to 'backends/platform/sdl')
-rw-r--r-- | backends/platform/sdl/sdl-window.cpp | 6 | ||||
-rw-r--r-- | backends/platform/sdl/sdl-window.h | 4 |
2 files changed, 8 insertions, 2 deletions
diff --git a/backends/platform/sdl/sdl-window.cpp b/backends/platform/sdl/sdl-window.cpp index a550fbbd40..fe27d84de2 100644 --- a/backends/platform/sdl/sdl-window.cpp +++ b/backends/platform/sdl/sdl-window.cpp @@ -155,16 +155,20 @@ bool SdlWindow::hasMouseFocus() const { #endif } -void SdlWindow::warpMouseInWindow(int x, int y) { +bool SdlWindow::warpMouseInWindow(int x, int y) { if (hasMouseFocus()) { #if SDL_VERSION_ATLEAST(2, 0, 0) if (_window) { SDL_WarpMouseInWindow(_window, x, y); + return true; } #else SDL_WarpMouse(x, y); + return true; #endif } + + return false; } void SdlWindow::iconifyWindow() { diff --git a/backends/platform/sdl/sdl-window.h b/backends/platform/sdl/sdl-window.h index 4f6d924411..e1a3499d19 100644 --- a/backends/platform/sdl/sdl-window.h +++ b/backends/platform/sdl/sdl-window.h @@ -58,8 +58,10 @@ public: /** * Warp the mouse to the specified position in window coordinates. The mouse * will only be warped if the window is focused in the window manager. + * + * @returns true if the system cursor was warped. */ - void warpMouseInWindow(int x, int y); + bool warpMouseInWindow(int x, int y); /** * Iconifies the window. |