diff options
author | Maarten Gribnau <mail@maartengribnau.com> | 2003-01-01 23:42:27 +0300 |
---|---|---|
committer | Maarten Gribnau <mail@maartengribnau.com> | 2003-01-01 23:42:27 +0300 |
commit | 729281a02169bafd4c56f72c6df9097e272cdd2a (patch) | |
tree | 30fdb04b49130275b513f10b2dc00edb3ae2c077 /intern/ghost | |
parent | c78a1749edca3210ed0f3567a086b3f1044a1d04 (diff) |
Added test for events pending for windows already disposed. These events are removed from the event stack now.
Maarten
Diffstat (limited to 'intern/ghost')
-rw-r--r-- | intern/ghost/intern/GHOST_EventManager.cpp | 60 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_EventManager.h | 27 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_System.cpp | 9 |
3 files changed, 87 insertions, 9 deletions
diff --git a/intern/ghost/intern/GHOST_EventManager.cpp b/intern/ghost/intern/GHOST_EventManager.cpp index 878a5f812c6..ba20cce12fd 100644 --- a/intern/ghost/intern/GHOST_EventManager.cpp +++ b/intern/ghost/intern/GHOST_EventManager.cpp @@ -66,7 +66,7 @@ GHOST_TUns32 GHOST_EventManager::getNumEvents() GHOST_TUns32 GHOST_EventManager::getNumEvents(GHOST_TEventType type) { GHOST_TUns32 numEvents = 0; - std::deque<GHOST_IEvent*>::iterator p; + TEventStack::iterator p; for (p = m_events.begin(); p != m_events.end(); p++) { if ((*p)->getType() == type) { numEvents++; @@ -106,13 +106,6 @@ bool GHOST_EventManager::dispatchEvent(GHOST_IEvent* event) bool handled; if (event) { handled = true; - /* - for (unsigned int i = 0; i < m_consumers.size(); i++) { - if (m_consumers[i]->processEvent(event)) { - handled = false; - } - } - */ TConsumerVector::iterator iter; for (iter = m_consumers.begin(); iter != m_consumers.end(); iter++) { if ((*iter)->processEvent(event)) { @@ -197,6 +190,57 @@ GHOST_TSuccess GHOST_EventManager::removeConsumer(GHOST_IEventConsumer* consumer } +void GHOST_EventManager::removeWindowEvents(GHOST_IWindow* window) +{ + TEventStack::iterator iter; + iter = m_events.begin(); + while (iter != m_events.end()) + { + GHOST_IEvent* event = *iter; + if (event->getWindow() == window) + { + GHOST_PRINT("GHOST_EventManager::removeWindowEvents(): removing event\n"); + /* + * Found an event for this window, remove it. + * The iterator will become invalid. + */ + delete event; + m_events.erase(iter); + iter = m_events.begin(); + } + else + { + iter++; + } + } +} + +void GHOST_EventManager::removeTypeEvents(GHOST_TEventType type, GHOST_IWindow* window) +{ + TEventStack::iterator iter; + iter = m_events.begin(); + while (iter != m_events.end()) + { + GHOST_IEvent* event = *iter; + if ((event->getType() == type) && (!window || (event->getWindow() == window))) + { + GHOST_PRINT("GHOST_EventManager::removeTypeEvents(): removing event\n"); + /* + * Found an event of this type for the window, remove it. + * The iterator will become invalid. + */ + delete event; + m_events.erase(iter); + iter = m_events.begin(); + } + else + { + iter++; + } + } +} + + GHOST_IEvent* GHOST_EventManager::popEvent() { GHOST_IEvent* event = peekEvent(); diff --git a/intern/ghost/intern/GHOST_EventManager.h b/intern/ghost/intern/GHOST_EventManager.h index b8c3812b8e1..068ded8ddee 100644 --- a/intern/ghost/intern/GHOST_EventManager.h +++ b/intern/ghost/intern/GHOST_EventManager.h @@ -129,6 +129,28 @@ public: */ virtual GHOST_TSuccess removeConsumer(GHOST_IEventConsumer* consumer); + /** + * Removes all events for a window from the stack. + * @param window The window to remove events for. + */ + virtual void + removeWindowEvents( + GHOST_IWindow* window + ); + + /** + * Removes all events of a certain type from the stack. + * The window parameter is optional. If non-null, the routine will remove + * events only associated with that window. + * @param type The type of events to be removed. + * @param window The window to remove the events for. + */ + virtual void + removeTypeEvents( + GHOST_TEventType type, + GHOST_IWindow* window = 0 + ); + protected: /** * Returns the event at the top of the stack and removes it. @@ -142,10 +164,15 @@ protected: */ virtual void disposeEvents(); + /** A stack with events. */ + typedef std::deque<GHOST_IEvent*> TEventStack; + /** The event stack. */ std::deque<GHOST_IEvent*> m_events; + /** A vector with event consumers. */ typedef std::vector<GHOST_IEventConsumer*> TConsumerVector; + /** The list with event consumers. */ TConsumerVector m_consumers; }; diff --git a/intern/ghost/intern/GHOST_System.cpp b/intern/ghost/intern/GHOST_System.cpp index 50acc19383b..24cc26d5d13 100644 --- a/intern/ghost/intern/GHOST_System.cpp +++ b/intern/ghost/intern/GHOST_System.cpp @@ -106,6 +106,13 @@ GHOST_TSuccess GHOST_System::removeTimer(GHOST_ITimerTask* timerTask) GHOST_TSuccess GHOST_System::disposeWindow(GHOST_IWindow* window) { GHOST_TSuccess success; + + /* + * Remove all pending events for the window. + */ + if (m_windowManager->getWindowFound(window)) { + m_eventManager->removeWindowEvents(window); + } if (window == m_windowManager->getFullScreenWindow()) { success = endFullScreen(); } @@ -165,7 +172,7 @@ GHOST_TSuccess GHOST_System::endFullScreen(void) GHOST_TSuccess success = GHOST_kFailure; GHOST_ASSERT(m_windowManager, "GHOST_System::endFullScreen(): invalid window manager") if (m_windowManager->getFullScreen()) { - GHOST_IWindow* window = m_windowManager->getFullScreenWindow(); + //GHOST_IWindow* window = m_windowManager->getFullScreenWindow(); //GHOST_PRINT("GHOST_System::endFullScreen(): leaving window manager full-screen mode\n"); success = m_windowManager->endFullScreen(); GHOST_ASSERT(m_displayManager, "GHOST_System::endFullScreen(): invalid display manager") |