aboutsummaryrefslogtreecommitdiff
path: root/backends/graphics/sdl
diff options
context:
space:
mode:
Diffstat (limited to 'backends/graphics/sdl')
-rw-r--r--backends/graphics/sdl/sdl-graphics.cpp30
-rw-r--r--backends/graphics/sdl/sdl-graphics.h2
2 files changed, 26 insertions, 6 deletions
diff --git a/backends/graphics/sdl/sdl-graphics.cpp b/backends/graphics/sdl/sdl-graphics.cpp
index ea947c1073..6ce0bc7bac 100644
--- a/backends/graphics/sdl/sdl-graphics.cpp
+++ b/backends/graphics/sdl/sdl-graphics.cpp
@@ -148,18 +148,36 @@ void SdlGraphicsManager::initSizeHint(const Graphics::ModeList &modes) {
#endif
}
+bool SdlGraphicsManager::showMouse(const bool visible) {
+ if (visible == _cursorVisible) {
+ return visible;
+ }
+
+ int showCursor = SDL_DISABLE;
+ if (visible) {
+ // _cursorX and _cursorY are currently always clipped to the active
+ // area, so we need to ask SDL where the system's mouse cursor is
+ // instead
+ int x, y;
+ SDL_GetMouseState(&x, &y);
+ if (!_activeArea.drawRect.contains(Common::Point(x, y))) {
+ showCursor = SDL_ENABLE;
+ }
+ }
+ SDL_ShowCursor(showCursor);
+
+ return WindowedGraphicsManager::showMouse(visible);
+}
+
void SdlGraphicsManager::notifyMousePosition(Common::Point &mouse) {
- int showCursor;
- if (_activeArea.drawRect.contains(mouse)) {
- showCursor = SDL_DISABLE;
- } else {
+ int showCursor = SDL_DISABLE;
+ if (!_activeArea.drawRect.contains(mouse)) {
mouse.x = CLIP<int>(mouse.x, _activeArea.drawRect.left, _activeArea.drawRect.right - 1);
mouse.y = CLIP<int>(mouse.y, _activeArea.drawRect.top, _activeArea.drawRect.bottom - 1);
if (_window->mouseIsGrabbed()) {
setSystemMousePosition(mouse.x, mouse.y);
- showCursor = SDL_DISABLE;
- } else {
+ } else if (_cursorVisible) {
showCursor = SDL_ENABLE;
}
}
diff --git a/backends/graphics/sdl/sdl-graphics.h b/backends/graphics/sdl/sdl-graphics.h
index 886070aedb..772bc88637 100644
--- a/backends/graphics/sdl/sdl-graphics.h
+++ b/backends/graphics/sdl/sdl-graphics.h
@@ -87,6 +87,8 @@ public:
*/
virtual void notifyMousePosition(Common::Point &mouse);
+ virtual bool showMouse(const bool visible) override;
+
/**
* A (subset) of the graphic manager's state. This is used when switching
* between different SDL graphic managers at runtime.