BACKENDS: Also hide mouse cursor outside game area when an engine has hidden the cursor
The only reason we show the system cursor outside the game area is to show users where their mouse is when the window is resized and the mouse is outside the game area. If the game cannot be interacted with, then the mouse also does not need to be shown in the black areas.
This commit is contained in:
parent
de2bbe3b97
commit
da0a8db704
7 changed files with 46 additions and 40 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue