[Scummvm-git-logs] scummvm master -> 82ccce948aaafed2f8e847359ab87c1a4878c74b

bluegr bluegr at gmail.com
Mon Apr 1 00:16:56 CEST 2019


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:
82ccce948a SCI: Fix Mac icon bar event handling


Commit: 82ccce948aaafed2f8e847359ab87c1a4878c74b
    https://github.com/scummvm/scummvm/commit/82ccce948aaafed2f8e847359ab87c1a4878c74b
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2019-04-01T01:16:53+03:00

Commit Message:
SCI: Fix Mac icon bar event handling

Fix mouse presses falling through the icon bar in KQ6 and FPFP Mac

Changed paths:
    engines/sci/engine/kevent.cpp
    engines/sci/graphics/maciconbar.cpp
    engines/sci/graphics/maciconbar.h


diff --git a/engines/sci/engine/kevent.cpp b/engines/sci/engine/kevent.cpp
index 608e2e4..df0e94f 100644
--- a/engines/sci/engine/kevent.cpp
+++ b/engines/sci/engine/kevent.cpp
@@ -49,13 +49,6 @@ reg_t kGetEvent(EngineState *s, int argc, reg_t *argv) {
 	SegManager *segMan = s->_segMan;
 	Common::Point mousePos;
 
-	// For Mac games with an icon bar, handle possible icon bar events first
-	if (g_sci->hasMacIconBar()) {
-		reg_t iconObj = g_sci->_gfxMacIconBar->handleEvents();
-		if (!iconObj.isNull())
-			invokeSelector(s, iconObj, SELECTOR(select), argc, argv, 0, NULL);
-	}
-
 	// If there's a simkey pending, and the game wants a keyboard event, use the
 	// simkey instead of a normal event
 	// TODO: This does not really work as expected for keyup events, since the
@@ -78,6 +71,21 @@ reg_t kGetEvent(EngineState *s, int argc, reg_t *argv) {
 
 	curEvent = g_sci->getEventManager()->getSciEvent(mask);
 
+	// For Mac games with an icon bar, handle possible icon bar events first
+	if (g_sci->hasMacIconBar()) {
+		reg_t iconObj = NULL_REG;
+		if (g_sci->_gfxMacIconBar->handleEvents(curEvent, iconObj)) {
+			if (!iconObj.isNull()) {
+				invokeSelector(s, iconObj, SELECTOR(select), argc, argv, 0, NULL);
+			}
+
+			// The mouse press event was handled by the mac icon bar so change
+			// its type to none so that generic event processing can continue
+			// without the mouse press being handled twice
+			curEvent.type = kSciEventNone;
+		}
+	}
+
 	if (g_sci->_guestAdditions->kGetEventHook()) {
 		return NULL_REG;
 	}
diff --git a/engines/sci/graphics/maciconbar.cpp b/engines/sci/graphics/maciconbar.cpp
index 9b645e4..7b2b2a9 100644
--- a/engines/sci/graphics/maciconbar.cpp
+++ b/engines/sci/graphics/maciconbar.cpp
@@ -24,7 +24,6 @@
 #include "sci/engine/kernel.h"
 #include "sci/engine/selector.h"
 #include "sci/engine/state.h"
-#include "sci/event.h"
 #include "sci/graphics/maciconbar.h"
 #include "sci/graphics/palette.h"
 #include "sci/graphics/screen.h"
@@ -259,21 +258,17 @@ bool GfxMacIconBar::pointOnIcon(uint32 iconIndex, Common::Point point) {
 	return _iconBarItems[iconIndex].rect.contains(point);
 }
 
-reg_t GfxMacIconBar::handleEvents() {
-	// Peek event queue for a mouse button press
+bool GfxMacIconBar::handleEvents(SciEvent evt, reg_t &iconObj) {
 	EventManager *evtMgr = g_sci->getEventManager();
-	SciEvent evt = evtMgr->getSciEvent(kSciEventMousePress | kSciEventPeek);
+	iconObj = NULL_REG;
 
-	// No mouse press found
-	if (evt.type == kSciEventNone)
-		return NULL_REG;
+	// Not a mouse press
+	if (evt.type != kSciEventMousePress)
+		return false;
 
 	// If the mouse is not over the icon bar, return
 	if (evt.mousePos.y < g_sci->_gfxScreen->getHeight())
-		return NULL_REG;
-
-	// Remove event from queue
-	evtMgr->getSciEvent(kSciEventMousePress);
+		return false;
 
 	// Mouse press on the icon bar, check the icon rectangles
 	uint iconNr;
@@ -282,9 +277,10 @@ reg_t GfxMacIconBar::handleEvents() {
 			break;
 	}
 
-	// Mouse press not on an icon
+	// Mouse press on the icon bar but not on an enabled icon,
+	// return true to indicate that this mouse press was handled
 	if (iconNr == _iconBarItems.size())
-		return NULL_REG;
+		return true;
 
 	drawIcon(iconNr, true);
 	bool isSelected = true;
@@ -305,9 +301,10 @@ reg_t GfxMacIconBar::handleEvents() {
 
 	// If user moved away from the icon, we do nothing
 	if (pointOnIcon(iconNr, evt.mousePos))
-		return _iconBarItems[iconNr].object;
+		iconObj = _iconBarItems[iconNr].object;
 
-	return NULL_REG;
+	// The mouse press was handled
+	return true;
 }
 
 } // End of namespace Sci
diff --git a/engines/sci/graphics/maciconbar.h b/engines/sci/graphics/maciconbar.h
index 21d28df..754da8b 100644
--- a/engines/sci/graphics/maciconbar.h
+++ b/engines/sci/graphics/maciconbar.h
@@ -26,6 +26,7 @@
 #include "common/array.h"
 
 #include "sci/engine/vm.h"
+#include "sci/event.h"
 
 namespace Graphics {
 struct Surface;
@@ -42,7 +43,7 @@ public:
 	void drawIcons();
 	void setIconEnabled(int16 index, bool enabled);
 	void setInventoryIcon(int16 icon);
-	reg_t handleEvents();
+	bool handleEvents(SciEvent evt, reg_t &iconObj);
 
 private:
 	struct IconBarItem {





More information about the Scummvm-git-logs mailing list