[Scummvm-git-logs] scummvm master -> 4c90ce7cf33971247c0e1f9c22a2abd591cf6203

bluegr noreply at scummvm.org
Mon Aug 3 08:03:50 UTC 2026


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

Summary:
ea5ba1b2e3 CHEWY: Ignore next KEYUP when resuming from overlay
4c90ce7cf3 CHEWY: Remove _pendingEvents and _pendingKeyEvents queues


Commit: ea5ba1b2e3458fa61e47def7e81851b2420a7fd3
    https://github.com/scummvm/scummvm/commit/ea5ba1b2e3458fa61e47def7e81851b2420a7fd3
Author: Max H. Gerlach (git at maxgerlach.de)
Date: 2026-08-03T11:03:45+03:00

Commit Message:
CHEWY: Ignore next KEYUP when resuming from overlay

The orphan event that I was seeing belonged to a key pressed
while a ScummVM overlay dialog had the focus, e.g., Return
confirming the save dialog opened with Ctrl+F5. Acting on
that Return would behave like a phantom left click in game.

Assisted-by: Claude:claude-opus-4.8

Changed paths:
    engines/chewy/chewy.cpp
    engines/chewy/chewy.h
    engines/chewy/events.cpp
    engines/chewy/events.h


diff --git a/engines/chewy/chewy.cpp b/engines/chewy/chewy.cpp
index 01fdc2dd4b0..116f8be1471 100644
--- a/engines/chewy/chewy.cpp
+++ b/engines/chewy/chewy.cpp
@@ -79,6 +79,18 @@ void ChewyEngine::initialize() {
 	syncSoundSettings();
 }
 
+void ChewyEngine::pauseEngineIntern(bool pause) {
+	Engine::pauseEngineIntern(pause);
+
+	if (!pause) {
+		// When a key was pressed to dismiss the ScummVM overlay,
+		// the key-down event may have been consumed outside the engine.
+		// In this case we should not respond to the next (leaked)
+		// key-up event unless it is preceded by another key-down.
+		g_events->ignoreNextKeyUp();
+	}
+}
+
 Common::Error ChewyEngine::run() {
 	// Initialize backend
 	//initGraphics(640, 480);
diff --git a/engines/chewy/chewy.h b/engines/chewy/chewy.h
index fc656b1a3ca..7cdd829ee81 100644
--- a/engines/chewy/chewy.h
+++ b/engines/chewy/chewy.h
@@ -66,6 +66,7 @@ protected:
 	void initialize();
 	void shutdown() {}
 
+	void pauseEngineIntern(bool pause) override;
 public:
 	const ChewyGameDescription *_gameDescription;
 	Common::RandomSource _rnd;
diff --git a/engines/chewy/events.cpp b/engines/chewy/events.cpp
index 08dcd9af508..00f48a2c59a 100644
--- a/engines/chewy/events.cpp
+++ b/engines/chewy/events.cpp
@@ -19,6 +19,7 @@
  *
  */
 
+#include "common/debug.h"
 #include "common/system.h"
 #include "chewy/cursor.h"
 #include "chewy/events.h"
@@ -72,7 +73,7 @@ void EventsManager::updateScreen() {
 void EventsManager::handleEvent(const Common::Event &event) {
 	if (event.type >= Common::EVENT_MOUSEMOVE && event.type <= Common::EVENT_MBUTTONUP)
 		handleMouseEvent(event);
-	else if (event.type == Common::EVENT_KEYUP)
+	else if (event.type == Common::EVENT_KEYDOWN || event.type == Common::EVENT_KEYUP)
 		handleKbdEvent(event);
 }
 
@@ -145,11 +146,26 @@ void EventsManager::handleMouseEvent(const Common::Event &event) {
 void EventsManager::handleKbdEvent(const Common::Event &event) {
 	_pendingKeyEvents.push(event);
 
-	if (event.type == Common::EVENT_KEYUP) {
+	switch (event.type) {
+	case Common::EVENT_KEYDOWN:
+		// Fresh keyboard input (not leaked from overlay)
+		_ignoreKeyUp = false;
+		return;
+
+	case Common::EVENT_KEYUP:
+		if (_ignoreKeyUp) {
+			// This key-up has no matching key-down within the running engine.
+			debug(1, "dropping leaked key up after resume: keycode=%d ascii=%d", event.kbd.keycode, event.kbd.ascii);
+			return;
+		}
 		_kbInfo._keyCode = event.kbd.ascii;
 		_kbInfo._scanCode = event.kbd.keycode;
 		if (event.kbd.flags & Common::KBD_ALT)
 			_kbInfo._scanCode |= ALT;
+		return;
+
+	default:
+		return;
 	}
 }
 
diff --git a/engines/chewy/events.h b/engines/chewy/events.h
index 8b0ea56c704..2a806d3f1f3 100644
--- a/engines/chewy/events.h
+++ b/engines/chewy/events.h
@@ -56,6 +56,7 @@ private:
 	Common::Queue<Common::Event> _pendingEvents;
 	Common::Queue<Common::Event> _pendingKeyEvents;
 	int16 _hotkey = Common::KEYCODE_INVALID;
+	bool _ignoreKeyUp = false;
 
 	/**
 	 * Checks for timers' expiration
@@ -150,6 +151,12 @@ public:
 
 	void setHotKey(Common::KeyCode key) { _hotkey = key; }
 	int16 getSwitchCode();
+
+	/**
+	 * Activate a filter that drops key-up events until the next
+	 * key-down.
+	 */
+	void ignoreNextKeyUp() { _ignoreKeyUp = true; }
 };
 
 extern EventsManager *g_events;


Commit: 4c90ce7cf33971247c0e1f9c22a2abd591cf6203
    https://github.com/scummvm/scummvm/commit/4c90ce7cf33971247c0e1f9c22a2abd591cf6203
Author: Max H. Gerlach (git at maxgerlach.de)
Date: 2026-08-03T11:03:45+03:00

Commit Message:
CHEWY: Remove _pendingEvents and _pendingKeyEvents queues

They were only written to and eventually cleared, but the
contents were never consumed.

Changed paths:
    engines/chewy/events.cpp
    engines/chewy/events.h


diff --git a/engines/chewy/events.cpp b/engines/chewy/events.cpp
index 00f48a2c59a..419935042ca 100644
--- a/engines/chewy/events.cpp
+++ b/engines/chewy/events.cpp
@@ -85,8 +85,6 @@ static void returnInventoryCursorToSlot() {
 }
 
 void EventsManager::handleMouseEvent(const Common::Event &event) {
-	_pendingEvents.push(event);
-
 	_mousePos = event.mouse;
 	bool isWheelEnabled = !_G(menu_display) && !_G(flags).InventMenu &&
 		g_engine->canSaveAutosaveCurrently() &&
@@ -144,8 +142,6 @@ void EventsManager::handleMouseEvent(const Common::Event &event) {
 }
 
 void EventsManager::handleKbdEvent(const Common::Event &event) {
-	_pendingKeyEvents.push(event);
-
 	switch (event.type) {
 	case Common::EVENT_KEYDOWN:
 		// Fresh keyboard input (not leaked from overlay)
@@ -181,8 +177,6 @@ void EventsManager::delay(size_t time) {
 
 void EventsManager::clearEvents() {
 	processEvents();
-	_pendingEvents.clear();
-	_pendingKeyEvents.clear();
 
 	_kbInfo._scanCode = Common::KEYCODE_INVALID;
 	_kbInfo._keyCode = '\0';
diff --git a/engines/chewy/events.h b/engines/chewy/events.h
index 2a806d3f1f3..e7846bca87e 100644
--- a/engines/chewy/events.h
+++ b/engines/chewy/events.h
@@ -23,7 +23,6 @@
 #define CHEWY_EVENTS_H
 
 #include "common/events.h"
-#include "common/queue.h"
 #include "graphics/screen.h"
 
 namespace Chewy {
@@ -53,8 +52,6 @@ private:
 	void handleKbdEvent(const Common::Event &event);
 
 	TimerList _timers;
-	Common::Queue<Common::Event> _pendingEvents;
-	Common::Queue<Common::Event> _pendingKeyEvents;
 	int16 _hotkey = Common::KEYCODE_INVALID;
 	bool _ignoreKeyUp = false;
 
@@ -106,39 +103,6 @@ public:
 	 */
 	void update();
 
-	/**
-	 * Returns true if any unprocessed keyboard events are pending
-	 */
-	bool keyEventPending() {
-		processEvents();
-		return !_pendingKeyEvents.empty();
-	}
-
-	/**
-	 * Returns true if any unprocessed event other than key events
-	 * are pending
-	 */
-	bool eventPending() {
-		processEvents();
-		return !_pendingEvents.empty();
-	}
-
-	/**
-	 * Returns the next pending unprocessed keyboard event
-	 */
-	Common::Event getPendingKeyEvent() {
-		processEvents();
-		return _pendingKeyEvents.empty() ? Common::Event() : _pendingKeyEvents.pop();
-	}
-
-	/**
-	 * Returns the next event, if any
-	 */
-	Common::Event getPendingEvent() {
-		processEvents();
-		return _pendingEvents.empty() ? Common::Event() : _pendingEvents.pop();
-	}
-
 	/**
 	 * Sets the mouse position
 	 */




More information about the Scummvm-git-logs mailing list