aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/sdl
diff options
context:
space:
mode:
authorColin Snover2017-10-15 13:26:39 -0500
committerColin Snover2017-10-15 13:26:39 -0500
commit7d8d2f80fbc9cf96b3bd03b85a9722b576d23adc (patch)
treea35cf3cd386219e8c945ba8aacc3e20c442fbf69 /backends/platform/sdl
parent7fc86195343adf962054fd52605c3a3cc8b501e9 (diff)
parent4757c24c683c2f2b8e3b55aa8d7a767aad9e947e (diff)
downloadscummvm-rg350-7d8d2f80fbc9cf96b3bd03b85a9722b576d23adc.tar.gz
scummvm-rg350-7d8d2f80fbc9cf96b3bd03b85a9722b576d23adc.tar.bz2
scummvm-rg350-7d8d2f80fbc9cf96b3bd03b85a9722b576d23adc.zip
Merge branch 'graphics-backends-improvements'
Diffstat (limited to 'backends/platform/sdl')
-rw-r--r--backends/platform/sdl/sdl-window.cpp18
-rw-r--r--backends/platform/sdl/sdl-window.h13
2 files changed, 23 insertions, 8 deletions
diff --git a/backends/platform/sdl/sdl-window.cpp b/backends/platform/sdl/sdl-window.cpp
index 75cf813638..fe27d84de2 100644
--- a/backends/platform/sdl/sdl-window.cpp
+++ b/backends/platform/sdl/sdl-window.cpp
@@ -135,8 +135,10 @@ void SdlWindow::toggleMouseGrab() {
#else
if (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_OFF) {
SDL_WM_GrabInput(SDL_GRAB_ON);
+ _inputGrabState = true;
} else {
SDL_WM_GrabInput(SDL_GRAB_OFF);
+ _inputGrabState = false;
}
#endif
}
@@ -153,14 +155,20 @@ bool SdlWindow::hasMouseFocus() const {
#endif
}
-void SdlWindow::warpMouseInWindow(uint x, uint y) {
+bool SdlWindow::warpMouseInWindow(int x, int y) {
+ if (hasMouseFocus()) {
#if SDL_VERSION_ATLEAST(2, 0, 0)
- if (_window && hasMouseFocus()) {
- SDL_WarpMouseInWindow(_window, x, y);
- }
+ if (_window) {
+ SDL_WarpMouseInWindow(_window, x, y);
+ return true;
+ }
#else
- SDL_WarpMouse(x, y);
+ 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 d75e811f56..e1a3499d19 100644
--- a/backends/platform/sdl/sdl-window.h
+++ b/backends/platform/sdl/sdl-window.h
@@ -56,9 +56,12 @@ public:
bool hasMouseFocus() const;
/**
- * Warp the mouse to the specified position in window coordinates.
+ * 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(uint x, uint y);
+ bool warpMouseInWindow(int x, int y);
/**
* Iconifies the window.
@@ -73,6 +76,11 @@ public:
*/
bool getSDLWMInformation(SDL_SysWMinfo *info) const;
+ bool mouseIsGrabbed() const { return _inputGrabState; }
+
+private:
+ bool _inputGrabState;
+
#if SDL_VERSION_ATLEAST(2, 0, 0)
public:
/**
@@ -108,7 +116,6 @@ private:
*/
int _lastX, _lastY;
- bool _inputGrabState;
Common::String _windowCaption;
#endif
};