aboutsummaryrefslogtreecommitdiff
path: root/backends/graphics/sdl/sdl-graphics.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'backends/graphics/sdl/sdl-graphics.cpp')
-rw-r--r--backends/graphics/sdl/sdl-graphics.cpp36
1 files changed, 29 insertions, 7 deletions
diff --git a/backends/graphics/sdl/sdl-graphics.cpp b/backends/graphics/sdl/sdl-graphics.cpp
index a181582235..ea947c1073 100644
--- a/backends/graphics/sdl/sdl-graphics.cpp
+++ b/backends/graphics/sdl/sdl-graphics.cpp
@@ -28,15 +28,11 @@
#include "graphics/scaler/aspect.h"
SdlGraphicsManager::SdlGraphicsManager(SdlEventSource *source, SdlWindow *window)
- : _eventSource(source), _window(window)
+ : _eventSource(source), _window(window), _hwScreen(nullptr)
#if SDL_VERSION_ATLEAST(2, 0, 0)
, _allowWindowSizeReset(false), _hintedWidth(0), _hintedHeight(0), _lastFlags(0)
#endif
- {
-}
-
-SdlGraphicsManager::~SdlGraphicsManager() {
-}
+{}
void SdlGraphicsManager::activateManager() {
_eventSource->setGraphicsManager(this);
@@ -46,7 +42,7 @@ void SdlGraphicsManager::deactivateManager() {
_eventSource->setGraphicsManager(0);
}
-SdlGraphicsManager::State SdlGraphicsManager::getState() {
+SdlGraphicsManager::State SdlGraphicsManager::getState() const {
State state;
state.screenWidth = getWidth();
@@ -152,6 +148,32 @@ void SdlGraphicsManager::initSizeHint(const Graphics::ModeList &modes) {
#endif
}
+void SdlGraphicsManager::notifyMousePosition(Common::Point &mouse) {
+ int showCursor;
+ if (_activeArea.drawRect.contains(mouse)) {
+ showCursor = SDL_DISABLE;
+ } else {
+ 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 {
+ showCursor = SDL_ENABLE;
+ }
+ }
+
+ SDL_ShowCursor(showCursor);
+ setMousePosition(mouse.x, mouse.y);
+ mouse = convertWindowToVirtual(mouse.x, mouse.y);
+}
+
+void SdlGraphicsManager::handleResizeImpl(const int width, const int height) {
+ _eventSource->resetKeyboardEmulation(width - 1, height - 1);
+ _forceRedraw = true;
+}
+
#if SDL_VERSION_ATLEAST(2, 0, 0)
bool SdlGraphicsManager::createOrUpdateWindow(int width, int height, const Uint32 flags) {
if (!_window) {