OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BASE_MESSAGE_PUMP_GLIB_X_DISPATCH_H | 5 #ifndef BASE_MESSAGE_PUMP_GLIB_X_DISPATCH_H |
6 #define BASE_MESSAGE_PUMP_GLIB_X_DISPATCH_H | 6 #define BASE_MESSAGE_PUMP_GLIB_X_DISPATCH_H |
7 | 7 |
| 8 #include "base/base_api.h" |
8 #include "base/message_pump.h" | 9 #include "base/message_pump.h" |
9 #include "base/message_pump_glib.h" | 10 #include "base/message_pump_glib.h" |
10 | 11 |
11 typedef union _XEvent XEvent; | 12 typedef union _XEvent XEvent; |
12 | 13 |
13 namespace base { | 14 namespace base { |
14 | 15 |
15 // The message pump used for TOUCH_UI on linux is MessagePumpGlibX, which can | 16 // The message pump used for TOUCH_UI on linux is MessagePumpGlibX, which can |
16 // dispatch both GdkEvents* and XEvents* captured directly from X. | 17 // dispatch both GdkEvents* and XEvents* captured directly from X. |
17 // MessagePumpForUI::Dispatcher provides the mechanism for dispatching | 18 // MessagePumpForUI::Dispatcher provides the mechanism for dispatching |
18 // GdkEvents. This class provides additional mechanism for dispatching XEvents. | 19 // GdkEvents. This class provides additional mechanism for dispatching XEvents. |
19 class MessagePumpGlibXDispatcher : public MessagePumpForUI::Dispatcher { | 20 class MessagePumpGlibXDispatcher : public MessagePumpForUI::Dispatcher { |
20 public: | 21 public: |
21 enum DispatchStatus { | 22 enum DispatchStatus { |
22 EVENT_IGNORED, // The event was not processed. | 23 EVENT_IGNORED, // The event was not processed. |
23 EVENT_PROCESSED, // The event has been processed. | 24 EVENT_PROCESSED, // The event has been processed. |
24 EVENT_QUIT // The event was processed and the message-loop should | 25 EVENT_QUIT // The event was processed and the message-loop should |
25 // terminate. | 26 // terminate. |
26 }; | 27 }; |
27 | 28 |
28 // Dispatches the event. EVENT_IGNORED is returned if the event was ignored | 29 // Dispatches the event. EVENT_IGNORED is returned if the event was ignored |
29 // (i.e. not processed). EVENT_PROCESSED is returned if the event was | 30 // (i.e. not processed). EVENT_PROCESSED is returned if the event was |
30 // processed. The nested loop exits immediately if EVENT_QUIT is returned. | 31 // processed. The nested loop exits immediately if EVENT_QUIT is returned. |
31 virtual DispatchStatus DispatchX(XEvent* xevent) = 0; | 32 virtual DispatchStatus DispatchX(XEvent* xevent) = 0; |
32 }; | 33 }; |
33 | 34 |
34 class MessagePumpXObserver : public MessagePumpForUI::Observer { | 35 class BASE_API MessagePumpXObserver : public MessagePumpForUI::Observer { |
35 public: | 36 public: |
36 // This method is called before processing an XEvent. If the method returns | 37 // This method is called before processing an XEvent. If the method returns |
37 // true, it indicates the event has already been handled, so the event is not | 38 // true, it indicates the event has already been handled, so the event is not |
38 // processed any farther. If the method returns false, the event dispatching | 39 // processed any farther. If the method returns false, the event dispatching |
39 // proceeds as normal. | 40 // proceeds as normal. |
40 virtual bool WillProcessXEvent(XEvent* xevent); | 41 virtual bool WillProcessXEvent(XEvent* xevent); |
41 }; | 42 }; |
42 | 43 |
43 } // namespace base | 44 } // namespace base |
44 | 45 |
45 #endif // BASE_MESSAGE_PUMP_GLIB_X_DISPATCH_H | 46 #endif // BASE_MESSAGE_PUMP_GLIB_X_DISPATCH_H |
OLD | NEW |