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 #include "base/message_pump_observer.h" | 10 #include "base/message_pump_observer.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 protected: | 38 protected: |
39 virtual ~MessagePumpDispatcher() {} | 39 virtual ~MessagePumpDispatcher() {} |
40 }; | 40 }; |
41 | 41 |
42 // This class implements a message-pump for dispatching X events. | 42 // This class implements a message-pump for dispatching X events. |
43 class BASE_EXPORT MessagePumpX : public MessagePumpGlib { | 43 class BASE_EXPORT MessagePumpX : public MessagePumpGlib { |
44 public: | 44 public: |
45 MessagePumpX(); | 45 MessagePumpX(); |
46 virtual ~MessagePumpX(); | 46 virtual ~MessagePumpX(); |
47 | 47 |
48 // Overridden from MessagePumpGlib: | |
49 virtual bool RunOnce(GMainContext* context, bool block) OVERRIDE; | |
50 | |
51 // Returns default X Display. | 48 // Returns default X Display. |
52 static Display* GetDefaultXDisplay(); | 49 static Display* GetDefaultXDisplay(); |
53 | 50 |
54 // Returns true if the system supports XINPUT2. | 51 // Returns true if the system supports XINPUT2. |
55 static bool HasXInput2(); | 52 static bool HasXInput2(); |
56 | 53 |
57 // Sets the default dispatcher to process native events. | 54 // Sets the default dispatcher to process native events. |
58 static void SetDefaultDispatcher(MessagePumpDispatcher* dispatcher); | 55 static void SetDefaultDispatcher(MessagePumpDispatcher* dispatcher); |
59 | 56 |
| 57 // Internal function. Called by the glib source dispatch function. Processes |
| 58 // all available X events. |
| 59 gboolean DispatchXEvents(); |
| 60 |
60 private: | 61 private: |
61 // Initializes the glib event source for X. | 62 // Initializes the glib event source for X. |
62 void InitXSource(); | 63 void InitXSource(); |
63 | 64 |
64 // Dispatches the XEvent and returns true if we should exit the current loop | 65 // Dispatches the XEvent and returns true if we should exit the current loop |
65 // of message processing. | 66 // of message processing. |
66 bool ProcessXEvent(MessagePumpDispatcher* dispatcher, XEvent* event); | 67 bool ProcessXEvent(MessagePumpDispatcher* dispatcher, XEvent* event); |
67 | 68 |
68 // Sends the event to the observers. If an observer returns true, then it does | 69 // Sends the event to the observers. If an observer returns true, then it does |
69 // not send the event to any other observers and returns true. Returns false | 70 // not send the event to any other observers and returns true. Returns false |
70 // if no observer returns true. | 71 // if no observer returns true. |
71 bool WillProcessXEvent(XEvent* xevent); | 72 bool WillProcessXEvent(XEvent* xevent); |
72 void DidProcessXEvent(XEvent* xevent); | 73 void DidProcessXEvent(XEvent* xevent); |
73 | 74 |
74 // The event source for X events. | 75 // The event source for X events. |
75 GSource* x_source_; | 76 GSource* x_source_; |
76 | 77 |
77 DISALLOW_COPY_AND_ASSIGN(MessagePumpX); | 78 DISALLOW_COPY_AND_ASSIGN(MessagePumpX); |
78 }; | 79 }; |
79 | 80 |
80 typedef MessagePumpX MessagePumpForUI; | 81 typedef MessagePumpX MessagePumpForUI; |
81 | 82 |
82 } // namespace base | 83 } // namespace base |
83 | 84 |
84 #endif // BASE_MESSAGE_PUMP_X_H | 85 #endif // BASE_MESSAGE_PUMP_X_H |
OLD | NEW |