[Scummvm-git-logs] scummvm master -> 76d73419c07644728d46dcc4077a1381e6a258a9

sev- sev at scummvm.org
Mon Mar 9 12:47:40 UTC 2020


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

Summary:
76d73419c0 GPH/LINUXMOTO: Fix drawing the mouse cursor


Commit: 76d73419c07644728d46dcc4077a1381e6a258a9
    https://github.com/scummvm/scummvm/commit/76d73419c07644728d46dcc4077a1381e6a258a9
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2020-03-09T13:47:34+01:00

Commit Message:
GPH/LINUXMOTO: Fix drawing the mouse cursor

Changed paths:
    backends/graphics/gph/gph-graphics.cpp
    backends/graphics/linuxmotosdl/linuxmotosdl-graphics.cpp


diff --git a/backends/graphics/gph/gph-graphics.cpp b/backends/graphics/gph/gph-graphics.cpp
index 434b779e74..3a9e0dad98 100644
--- a/backends/graphics/gph/gph-graphics.cpp
+++ b/backends/graphics/gph/gph-graphics.cpp
@@ -119,7 +119,7 @@ void GPHGraphicsManager::initSize(uint w, uint h, const Graphics::PixelFormat *f
 }
 
 void GPHGraphicsManager::drawMouse() {
-	if (!_cursorVisible || !_mouseSurface) {
+	if (!_cursorVisible || !_mouseSurface || !_mouseCurState.w || !_mouseCurState.h) {
 		_mouseBackup.x = _mouseBackup.y = _mouseBackup.w = _mouseBackup.h = 0;
 		return;
 	}
@@ -128,12 +128,14 @@ void GPHGraphicsManager::drawMouse() {
 	int scale;
 	int hotX, hotY;
 
+	const Common::Point virtualCursor = convertWindowToVirtual(_cursorX, _cursorY);
+
 	if (_videoMode.mode == GFX_HALF && !_overlayVisible) {
-		dst.x = _cursorX / 2;
-		dst.y = _cursorY / 2;
+		dst.x = virtualCursor.x / 2;
+		dst.y = virtualCursor.y / 2;
 	} else {
-		dst.x = _cursorX;
-		dst.y = _cursorY;
+		dst.x = virtualCursor.x;
+		dst.y = virtualCursor.y;
 	}
 
 	if (!_overlayVisible) {
@@ -161,10 +163,8 @@ void GPHGraphicsManager::drawMouse() {
 	// We draw the pre-scaled cursor image, so now we need to adjust for
 	// scaling, shake position and aspect ratio correction manually.
 
-	if (!_overlayVisible) {
-		dst.x += _currentShakeXOffset;
-		dst.y += _currentShakeYOffset;
-	}
+	dst.x += _currentShakeXOffset;
+	dst.y += _currentShakeYOffset;
 
 	if (_videoMode.aspectRatioCorrection && !_overlayVisible)
 		dst.y = real2Aspect(dst.y);
@@ -177,7 +177,7 @@ void GPHGraphicsManager::drawMouse() {
 	// Note that SDL_BlitSurface() and addDirtyRect() will both perform any
 	// clipping necessary
 
-	if (SDL_BlitSurface(_mouseSurface, NULL, _hwScreen, &dst) != 0)
+	if (SDL_BlitSurface(_mouseSurface, nullptr, _hwScreen, &dst) != 0)
 		error("SDL_BlitSurface failed: %s", SDL_GetError());
 
 	// The screen will be updated using real surface coordinates, i.e.
diff --git a/backends/graphics/linuxmotosdl/linuxmotosdl-graphics.cpp b/backends/graphics/linuxmotosdl/linuxmotosdl-graphics.cpp
index 31f414fbb6..facb24d638 100644
--- a/backends/graphics/linuxmotosdl/linuxmotosdl-graphics.cpp
+++ b/backends/graphics/linuxmotosdl/linuxmotosdl-graphics.cpp
@@ -153,7 +153,7 @@ bool LinuxmotoSdlGraphicsManager::loadGFXMode() {
 }
 
 void LinuxmotoSdlGraphicsManager::drawMouse() {
-	if (!_cursorVisible || !_mouseSurface) {
+	if (!_cursorVisible || !_mouseSurface || !_mouseCurState.w || !_mouseCurState.h) {
 		_mouseBackup.x = _mouseBackup.y = _mouseBackup.w = _mouseBackup.h = 0;
 		return;
 	}
@@ -162,12 +162,14 @@ void LinuxmotoSdlGraphicsManager::drawMouse() {
 	int scale;
 	int hotX, hotY;
 
+	const Common::Point virtualCursor = convertWindowToVirtual(_cursorX, _cursorY);
+
 	if (_videoMode.mode == GFX_HALF && !_overlayVisible) {
-		dst.x = _cursorX / 2;
-		dst.y = _cursorY / 2;
+		dst.x = virtualCursor.x / 2;
+		dst.y = virtualCursor.y / 2;
 	} else {
-		dst.x = _cursorX;
-		dst.y = _cursorY;
+		dst.x = virtualCursor.x;
+		dst.y = virtualCursor.y;
 	}
 
 	if (!_overlayVisible) {
@@ -195,10 +197,8 @@ void LinuxmotoSdlGraphicsManager::drawMouse() {
 	// We draw the pre-scaled cursor image, so now we need to adjust for
 	// scaling, shake position and aspect ratio correction manually.
 
-	if (!_overlayVisible) {
-		dst.x += _currentShakeXOffset;
-		dst.y += _currentShakeYOffset;
-	}
+	dst.x += _currentShakeXOffset;
+	dst.y += _currentShakeYOffset;
 
 	if (_videoMode.aspectRatioCorrection && !_overlayVisible)
 		dst.y = real2Aspect(dst.y);
@@ -211,7 +211,7 @@ void LinuxmotoSdlGraphicsManager::drawMouse() {
 	// Note that SDL_BlitSurface() and addDirtyRect() will both perform any
 	// clipping necessary
 
-	if (SDL_BlitSurface(_mouseSurface, NULL, _hwScreen, &dst) != 0)
+	if (SDL_BlitSurface(_mouseSurface, nullptr, _hwScreen, &dst) != 0)
 		error("SDL_BlitSurface failed: %s", SDL_GetError());
 
 	// The screen will be updated using real surface coordinates, i.e.




More information about the Scummvm-git-logs mailing list