[Scummvm-cvs-logs] scummvm master -> 32d0e4c15fb33f80db194087850466664a43516a

lordhoto lordhoto at gmail.com
Sat Feb 19 20:48:10 CET 2011


This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
3aba54b8b0 OPENGL: Fix documentation of OpenGLGraphicsManager::MousePos.
9954eb5a99 OPENGL: Get rid of adjustMouseEvent.
32d0e4c15f OPENGLSDL: Avoid warping in warpMouse when the logical coordinates did not change.


Commit: 3aba54b8b0c6d5272d9b485738804a9f8bfaaa87
    https://github.com/scummvm/scummvm/commit/3aba54b8b0c6d5272d9b485738804a9f8bfaaa87
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2011-02-19T11:46:47-08:00

Commit Message:
OPENGL: Fix documentation of OpenGLGraphicsManager::MousePos.

Changed paths:
    backends/graphics/opengl/opengl-graphics.h



diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h
index 27c850f..30b19d5 100644
--- a/backends/graphics/opengl/opengl-graphics.h
+++ b/backends/graphics/opengl/opengl-graphics.h
@@ -239,8 +239,7 @@ protected:
 	// Mouse
 	//
 	struct MousePos {
-		// The mouse position, using either virtual (game) or real
-		// (overlay) coordinates.
+		// The mouse position in hardware screen coordinates.
 		int16 x, y;
 
 		// The size and hotspot of the original cursor image.


Commit: 9954eb5a996a137a9a26abb766212e3fa471e3fe
    https://github.com/scummvm/scummvm/commit/9954eb5a996a137a9a26abb766212e3fa471e3fe
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2011-02-19T11:46:47-08:00

Commit Message:
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.

Changed paths:
    backends/graphics/opengl/opengl-graphics.cpp
    backends/graphics/opengl/opengl-graphics.h



diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index cee80f9..a1b2e00 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 30b19d5..b4084e8 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);
 
 	//


Commit: 32d0e4c15fb33f80db194087850466664a43516a
    https://github.com/scummvm/scummvm/commit/32d0e4c15fb33f80db194087850466664a43516a
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2011-02-19T11:46:47-08:00

Commit Message:
OPENGLSDL: Avoid warping in warpMouse when the logical coordinates did not change.

This fixes a slight move of the mouse cursor when the hardware mouse position
is at a subpixel from the logical coordinates.

Changed paths:
    backends/graphics/openglsdl/openglsdl-graphics.cpp



diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index b10c94b..c7ce0aa 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.cpp
+++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp
@@ -195,6 +195,18 @@ void OpenGLSdlGraphicsManager::warpMouse(int x, int y) {
 	int scaledX = x;
 	int scaledY = y;
 
+	int16 currentX = _cursorState.x;
+	int16 currentY = _cursorState.y;
+
+	adjustMousePosition(currentX, currentY);
+
+	// Do not adjust the real screen position, when the current game / overlay
+	// coordinates match the requested coordinates. This avoids a slight
+	// movement which might occur otherwise when the mouse is at a subpixel
+	// position.
+	if (x == currentX && y == currentY)
+		return;
+
 	if (_videoMode.mode == OpenGL::GFX_NORMAL) {
 		if (_videoMode.hardwareWidth != _videoMode.overlayWidth)
 			scaledX = scaledX * _videoMode.hardwareWidth / _videoMode.overlayWidth;






More information about the Scummvm-git-logs mailing list