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_X_H | 5 #ifndef BASE_MESSAGE_PUMP_X_H |
6 #define BASE_MESSAGE_PUMP_X_H | 6 #define BASE_MESSAGE_PUMP_X_H |
7 | 7 |
8 #include "base/message_pump.h" | 8 #include "base/message_pump.h" |
9 #include "base/message_pump_glib.h" | 9 #include "base/message_pump_glib.h" |
10 | 10 |
11 #include <bitset> | 11 #include <bitset> |
12 | 12 |
13 #include <glib.h> | 13 #include <glib.h> |
14 #include <gtk/gtk.h> | 14 #include <gtk/gtk.h> |
15 | 15 |
16 typedef union _XEvent XEvent; | 16 typedef union _XEvent XEvent; |
17 typedef struct _XDisplay Display; | 17 typedef struct _XDisplay Display; |
18 | 18 |
19 namespace base { | 19 namespace base { |
20 | 20 |
21 // The documentation for this class is in message_pump_glib.h | 21 // The documentation for this class is in message_pump_glib.h |
22 class BASE_API MessagePumpObserver { | 22 class BASE_EXPORT MessagePumpObserver { |
23 public: | 23 public: |
24 enum EventStatus { | 24 enum EventStatus { |
25 EVENT_CONTINUE, // The event should be dispatched as normal. | 25 EVENT_CONTINUE, // The event should be dispatched as normal. |
26 EVENT_HANDLED // The event should not be processed any farther. | 26 EVENT_HANDLED // The event should not be processed any farther. |
27 }; | 27 }; |
28 | 28 |
29 // This method is called before processing an XEvent. If the method returns | 29 // This method is called before processing an XEvent. If the method returns |
30 // EVENT_HANDLED, it indicates the event has already been handled, so the | 30 // EVENT_HANDLED, it indicates the event has already been handled, so the |
31 // event is not processed any farther. If the method returns EVENT_CONTINUE, | 31 // event is not processed any farther. If the method returns EVENT_CONTINUE, |
32 // the event dispatching proceeds as normal. | 32 // the event dispatching proceeds as normal. |
(...skipping 19 matching lines...) Expand all Loading... |
52 // Dispatches the event. EVENT_IGNORED is returned if the event was ignored | 52 // Dispatches the event. EVENT_IGNORED is returned if the event was ignored |
53 // (i.e. not processed). EVENT_PROCESSED is returned if the event was | 53 // (i.e. not processed). EVENT_PROCESSED is returned if the event was |
54 // processed. The nested loop exits immediately if EVENT_QUIT is returned. | 54 // processed. The nested loop exits immediately if EVENT_QUIT is returned. |
55 virtual DispatchStatus Dispatch(XEvent* xevent) = 0; | 55 virtual DispatchStatus Dispatch(XEvent* xevent) = 0; |
56 | 56 |
57 protected: | 57 protected: |
58 virtual ~MessagePumpDispatcher() {} | 58 virtual ~MessagePumpDispatcher() {} |
59 }; | 59 }; |
60 | 60 |
61 // This class implements a message-pump for dispatching X events. | 61 // This class implements a message-pump for dispatching X events. |
62 class BASE_API MessagePumpX : public MessagePumpGlib { | 62 class BASE_EXPORT MessagePumpX : public MessagePumpGlib { |
63 public: | 63 public: |
64 MessagePumpX(); | 64 MessagePumpX(); |
65 virtual ~MessagePumpX(); | 65 virtual ~MessagePumpX(); |
66 | 66 |
67 // Indicates whether a GDK event was injected by chrome (when |true|) or if it | 67 // Indicates whether a GDK event was injected by chrome (when |true|) or if it |
68 // was captured and being processed by GDK (when |false|). | 68 // was captured and being processed by GDK (when |false|). |
69 bool IsDispatchingEvent(void) { return dispatching_event_; } | 69 bool IsDispatchingEvent(void) { return dispatching_event_; } |
70 | 70 |
71 // Overridden from MessagePumpGlib: | 71 // Overridden from MessagePumpGlib: |
72 virtual bool RunOnce(GMainContext* context, bool block) OVERRIDE; | 72 virtual bool RunOnce(GMainContext* context, bool block) OVERRIDE; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 std::bitset<GDK_EVENT_LAST> capture_gdk_events_; | 138 std::bitset<GDK_EVENT_LAST> capture_gdk_events_; |
139 | 139 |
140 DISALLOW_COPY_AND_ASSIGN(MessagePumpX); | 140 DISALLOW_COPY_AND_ASSIGN(MessagePumpX); |
141 }; | 141 }; |
142 | 142 |
143 typedef MessagePumpX MessagePumpForUI; | 143 typedef MessagePumpX MessagePumpForUI; |
144 | 144 |
145 } // namespace base | 145 } // namespace base |
146 | 146 |
147 #endif // BASE_MESSAGE_PUMP_X_H | 147 #endif // BASE_MESSAGE_PUMP_X_H |
OLD | NEW |