diff options
author | Johannes Schickel | 2011-02-19 20:40:45 +0100 |
---|---|---|
committer | Johannes Schickel | 2011-02-19 20:46:47 +0100 |
commit | 9954eb5a996a137a9a26abb766212e3fa471e3fe (patch) | |
tree | d22f135536ce4713cfb77687382ab02a0a30dc83 | |
parent | 3aba54b8b0c6d5272d9b485738804a9f8bfaaa87 (diff) | |
download | scummvm-rg350-9954eb5a996a137a9a26abb766212e3fa471e3fe.tar.gz scummvm-rg350-9954eb5a996a137a9a26abb766212e3fa471e3fe.tar.bz2 scummvm-rg350-9954eb5a996a137a9a26abb766212e3fa471e3fe.zip |
OPENGL: Get rid of adjustMouseEvent.
Rather than that I introduced a function which converts hardware screen
coordinates to overlay / game screen coordinates.
The logic which converts mouse movement events with hardware screen
coordinates to overlay / game screen coordinates is now inside notifyEvent.
This is still broken design, since one should not abuse an observer for that.
-rw-r--r-- | backends/graphics/opengl/opengl-graphics.cpp | 62 | ||||
-rw-r--r-- | backends/graphics/opengl/opengl-graphics.h | 9 |
2 files changed, 38 insertions, 33 deletions
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp index cee80f9dc0..a1b2e00f51 100644 --- a/backends/graphics/opengl/opengl-graphics.cpp +++ b/backends/graphics/opengl/opengl-graphics.cpp @@ -1165,40 +1165,33 @@ uint OpenGLGraphicsManager::getAspectRatio() { return _videoMode.screenWidth * 10000 / _videoMode.screenHeight; } -void OpenGLGraphicsManager::adjustMouseEvent(const Common::Event &event) { - if (!event.synthetic) { - Common::Event newEvent(event); - newEvent.synthetic = true; - - if (_videoMode.mode == OpenGL::GFX_NORMAL) { - if (_videoMode.hardwareWidth != _videoMode.overlayWidth) - newEvent.mouse.x = newEvent.mouse.x * _videoMode.overlayWidth / _videoMode.hardwareWidth; - if (_videoMode.hardwareHeight != _videoMode.overlayHeight) - newEvent.mouse.y = newEvent.mouse.y * _videoMode.overlayHeight / _videoMode.hardwareHeight; - - if (!_overlayVisible) { - newEvent.mouse.x /= _videoMode.scaleFactor; - newEvent.mouse.y /= _videoMode.scaleFactor; - } +void OpenGLGraphicsManager::adjustMousePosition(int16 &x, int16 &y) { + if (_videoMode.mode == OpenGL::GFX_NORMAL) { + if (_videoMode.hardwareWidth != _videoMode.overlayWidth) + x = x * _videoMode.overlayWidth / _videoMode.hardwareWidth; + if (_videoMode.hardwareHeight != _videoMode.overlayHeight) + y = y * _videoMode.overlayHeight / _videoMode.hardwareHeight; + + if (!_overlayVisible) { + x /= _videoMode.scaleFactor; + y /= _videoMode.scaleFactor; + } + } else { + x -= _displayX; + y -= _displayY; + + if (_overlayVisible) { + if (_displayWidth != _videoMode.overlayWidth) + x = x * _videoMode.overlayWidth / _displayWidth; + if (_displayHeight != _videoMode.overlayHeight) + y = y * _videoMode.overlayHeight / _displayHeight; } else { - newEvent.mouse.x -= _displayX; - newEvent.mouse.y -= _displayY; - - if (_overlayVisible) { - if (_displayWidth != _videoMode.overlayWidth) - newEvent.mouse.x = newEvent.mouse.x * _videoMode.overlayWidth / _displayWidth; - if (_displayHeight != _videoMode.overlayHeight) - newEvent.mouse.y = newEvent.mouse.y * _videoMode.overlayHeight / _displayHeight; - } else { - if (_displayWidth != _videoMode.screenWidth) - newEvent.mouse.x = newEvent.mouse.x * _videoMode.screenWidth / _displayWidth; - if (_displayHeight != _videoMode.screenHeight) - newEvent.mouse.y = newEvent.mouse.y * _videoMode.screenHeight / _displayHeight; - } + if (_displayWidth != _videoMode.screenWidth) + x = x * _videoMode.screenWidth / _displayWidth; + if (_displayHeight != _videoMode.screenHeight) + y = y * _videoMode.screenHeight / _displayHeight; } - - g_system->getEventManager()->pushEvent(newEvent); } } @@ -1215,7 +1208,12 @@ bool OpenGLGraphicsManager::notifyEvent(const Common::Event &event) { case Common::EVENT_LBUTTONUP: case Common::EVENT_RBUTTONUP: case Common::EVENT_MBUTTONUP: - adjustMouseEvent(event); + if (!event.synthetic) { + Common::Event newEvent(event); + newEvent.synthetic = true; + adjustMousePosition(newEvent.mouse.x, newEvent.mouse.y); + g_system->getEventManager()->pushEvent(newEvent); + } return !event.synthetic; default: diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h index 30b19d5d70..b4084e8e41 100644 --- a/backends/graphics/opengl/opengl-graphics.h +++ b/backends/graphics/opengl/opengl-graphics.h @@ -272,7 +272,14 @@ protected: virtual void refreshCursor(); virtual void refreshCursorScale(); - virtual void adjustMouseEvent(const Common::Event &event); + /** + * Adjusts hardware screen coordinates to either overlay or game screen + * coordinates depending on whether the overlay is visible or not. + * + * @param x X coordinate of the mouse position. + * @param y Y coordinate of the mouse position. + */ + virtual void adjustMousePosition(int16 &x, int16 &y); virtual void setMousePos(int x, int y); // |