OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef BASE_MESSAGE_PUMP_OBSERVER_H |
| 6 #define BASE_MESSAGE_PUMP_OBSERVER_H |
| 7 |
| 8 #if defined(USE_X11) |
| 9 typedef union _XEvent XEvent; |
| 10 #endif |
| 11 |
| 12 namespace base { |
| 13 |
| 14 #if defined(OS_WIN) |
| 15 typedef MSG NativeEvent; |
| 16 #elif defined(USE_X11) |
| 17 typedef XEvent* NativeEvent; |
| 18 #endif |
| 19 |
| 20 enum EventStatus { |
| 21 EVENT_CONTINUE, // The event should be dispatched as normal. |
| 22 #if defined(USE_X11) |
| 23 EVENT_HANDLED // The event should not be processed any farther. |
| 24 #endif |
| 25 }; |
| 26 |
| 27 // A MessagePumpObserver is an object that receives global |
| 28 // notifications from the UI MessageLoop with MessagePumpWin or |
| 29 // MessagePumpX. |
| 30 // |
| 31 // NOTE: An Observer implementation should be extremely fast! |
| 32 // |
| 33 // For use with MessagePumpX, please see message_pump_glib.h for more |
| 34 // info about how this is invoked in this environment. |
| 35 class BASE_EXPORT MessagePumpObserver { |
| 36 public: |
| 37 // This method is called before processing a NativeEvent. If the |
| 38 // method returns EVENT_HANDLED, it indicates the event has already |
| 39 // been handled, so the event is not processed any farther. If the |
| 40 // method returns EVENT_CONTINUE, the event dispatching proceeds as |
| 41 // normal. |
| 42 virtual EventStatus WillProcessEvent(const NativeEvent& event) = 0; |
| 43 |
| 44 // This method is called after processing a message. This method |
| 45 // will not be called if WillProcessEvent returns EVENT_HANDLED. |
| 46 virtual void DidProcessEvent(const NativeEvent& event) = 0; |
| 47 |
| 48 protected: |
| 49 virtual ~MessagePumpObserver() {} |
| 50 }; |
| 51 |
| 52 } // namespace base |
| 53 |
| 54 #endif // BASE_MESSAGE_PUMP_OBSERVER_VIEWS_H |
OLD | NEW |