From 463e475bd654104aab1e19cbc6f315b3341ef470 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 9 Mar 2011 01:19:12 +0100 Subject: SCI: Save mouse position in SciEvent. Instead of querying the event manager for the current mouse cursor coordinates kGetEvent now uses the saved mouse positions, which will assure every event will be processed with the correct coordinates instead of the current ones. Various other functions using SciEvent directly were adapted too. This fixes cursor click positions for the WinCE backend. Thanks to wjp and waltervn for helping me with this. --- engines/sci/event.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'engines/sci/event.cpp') diff --git a/engines/sci/event.cpp b/engines/sci/event.cpp index 7832864024..cb0e6b3c03 100644 --- a/engines/sci/event.cpp +++ b/engines/sci/event.cpp @@ -136,19 +136,28 @@ static int altify(int ch) { } SciEvent EventManager::getScummVMEvent() { - SciEvent input = { SCI_EVENT_NONE, 0, 0, 0 }; - SciEvent noEvent = { SCI_EVENT_NONE, 0, 0, 0 }; + SciEvent input = { SCI_EVENT_NONE, 0, 0, 0, Common::Point(0, 0) }; + SciEvent noEvent = { SCI_EVENT_NONE, 0, 0, 0, Common::Point(0, 0) }; Common::EventManager *em = g_system->getEventManager(); Common::Event ev; bool found = em->pollEvent(ev); - Common::Point p = ev.mouse; // Don't generate events for mouse movement while (found && ev.type == Common::EVENT_MOUSEMOVE) found = em->pollEvent(ev); + // Save the mouse position + // + // We call getMousePos of the event manager here, since we also want to + // store the mouse position in case of keyboard events, which do not feature + // any mouse position information itself. + // This should be safe, since the mouse position in the event manager should + // only be updated when a mouse related event has been taken from the queue + // via pollEvent. + noEvent.mousePos = input.mousePos = em->getMousePos(); + if (!found || ev.type == Common::EVENT_MOUSEMOVE) return noEvent; @@ -277,7 +286,7 @@ void EventManager::updateScreen() { } SciEvent EventManager::getSciEvent(unsigned int mask) { - SciEvent event = { 0, 0, 0, 0 }; + SciEvent event = { 0, 0, 0, 0, Common::Point(0, 0) }; EventManager::updateScreen(); -- cgit v1.2.3