OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_pump.h" | 9 #include "base/message_pump.h" |
10 #include "base/message_pump_glib.h" | 10 #include "base/message_pump_glib.h" |
| 11 #include "base/message_pump_dispatcher.h" |
11 #include "base/message_pump_observer.h" | 12 #include "base/message_pump_observer.h" |
12 | 13 |
13 #include <bitset> | 14 #include <bitset> |
14 | 15 |
15 #include <glib.h> | 16 #include <glib.h> |
16 | 17 |
17 typedef struct _XDisplay Display; | 18 typedef struct _XDisplay Display; |
18 | 19 |
19 namespace base { | 20 namespace base { |
20 | 21 |
21 // The documentation for this class is in message_pump_glib.h | |
22 // | |
23 // The nested loop is exited by either posting a quit, or returning EVENT_QUIT | |
24 // from Dispatch. | |
25 class MessagePumpDispatcher { | |
26 public: | |
27 enum DispatchStatus { | |
28 EVENT_IGNORED, // The event was not processed. | |
29 EVENT_PROCESSED, // The event has been processed. | |
30 EVENT_QUIT // The event was processed and the message-loop should | |
31 // terminate. | |
32 }; | |
33 virtual ~MessagePumpDispatcher() {} | |
34 | |
35 // Dispatches the event. EVENT_IGNORED is returned if the event was ignored | |
36 // (i.e. not processed). EVENT_PROCESSED is returned if the event was | |
37 // processed. The nested loop exits immediately if EVENT_QUIT is returned. | |
38 virtual DispatchStatus Dispatch(XEvent* xevent) = 0; | |
39 }; | |
40 | |
41 // This class implements a message-pump for dispatching X events. | 22 // This class implements a message-pump for dispatching X events. |
42 class BASE_EXPORT MessagePumpX : public MessagePumpGlib { | 23 class BASE_EXPORT MessagePumpX : public MessagePumpGlib { |
43 public: | 24 public: |
44 MessagePumpX(); | 25 MessagePumpX(); |
45 virtual ~MessagePumpX(); | 26 virtual ~MessagePumpX(); |
46 | 27 |
47 // Returns default X Display. | 28 // Returns default X Display. |
48 static Display* GetDefaultXDisplay(); | 29 static Display* GetDefaultXDisplay(); |
49 | 30 |
50 // Returns true if the system supports XINPUT2. | 31 // Returns true if the system supports XINPUT2. |
(...skipping 27 matching lines...) Expand all Loading... |
78 scoped_ptr<GPollFD> x_poll_; | 59 scoped_ptr<GPollFD> x_poll_; |
79 | 60 |
80 DISALLOW_COPY_AND_ASSIGN(MessagePumpX); | 61 DISALLOW_COPY_AND_ASSIGN(MessagePumpX); |
81 }; | 62 }; |
82 | 63 |
83 typedef MessagePumpX MessagePumpForUI; | 64 typedef MessagePumpX MessagePumpForUI; |
84 | 65 |
85 } // namespace base | 66 } // namespace base |
86 | 67 |
87 #endif // BASE_MESSAGE_PUMP_X_H | 68 #endif // BASE_MESSAGE_PUMP_X_H |
OLD | NEW |