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_LOOP_MESSAGE_PUMP_AURAX11_H | 5 #ifndef BASE_MESSAGE_LOOP_MESSAGE_PUMP_AURAX11_H |
6 #define BASE_MESSAGE_LOOP_MESSAGE_PUMP_AURAX11_H | 6 #define BASE_MESSAGE_LOOP_MESSAGE_PUMP_AURAX11_H |
7 | 7 |
8 #include <bitset> | 8 #include <bitset> |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 void AddDispatcherForWindow(MessagePumpDispatcher* dispatcher, | 51 void AddDispatcherForWindow(MessagePumpDispatcher* dispatcher, |
52 unsigned long xid); | 52 unsigned long xid); |
53 void RemoveDispatcherForWindow(unsigned long xid); | 53 void RemoveDispatcherForWindow(unsigned long xid); |
54 | 54 |
55 // Adds/Removes |dispatcher| to receive all events sent to the X root | 55 // Adds/Removes |dispatcher| to receive all events sent to the X root |
56 // window. A root window can have multiple dispatchers, and events on root | 56 // window. A root window can have multiple dispatchers, and events on root |
57 // windows will be dispatched to all. | 57 // windows will be dispatched to all. |
58 void AddDispatcherForRootWindow(MessagePumpDispatcher* dispatcher); | 58 void AddDispatcherForRootWindow(MessagePumpDispatcher* dispatcher); |
59 void RemoveDispatcherForRootWindow(MessagePumpDispatcher* dispatcher); | 59 void RemoveDispatcherForRootWindow(MessagePumpDispatcher* dispatcher); |
60 | 60 |
| 61 // Adds an Observer, which will start receiving notifications immediately. |
| 62 void AddObserver(MessagePumpObserver* observer); |
| 63 |
| 64 // Removes an Observer. It is safe to call this method while an Observer is |
| 65 // receiving a notification callback. |
| 66 void RemoveObserver(MessagePumpObserver* observer); |
| 67 |
61 // Internal function. Called by the glib source dispatch function. Processes | 68 // Internal function. Called by the glib source dispatch function. Processes |
62 // all available X events. | 69 // all available X events. |
63 bool DispatchXEvents(); | 70 bool DispatchXEvents(); |
64 | 71 |
65 // Blocks on the X11 event queue until we receive notification from the | 72 // Blocks on the X11 event queue until we receive notification from the |
66 // xserver that |w| has been mapped; StructureNotifyMask events on |w| are | 73 // xserver that |w| has been mapped; StructureNotifyMask events on |w| are |
67 // pulled out from the queue and dispatched out of order. | 74 // pulled out from the queue and dispatched out of order. |
68 // | 75 // |
69 // For those that know X11, this is really a wrapper around XWindowEvent | 76 // For those that know X11, this is really a wrapper around XWindowEvent |
70 // which still makes sure the preempted event is dispatched instead of | 77 // which still makes sure the preempted event is dispatched instead of |
(...skipping 14 matching lines...) Expand all Loading... |
85 | 92 |
86 // Sends the event to the observers. If an observer returns true, then it does | 93 // Sends the event to the observers. If an observer returns true, then it does |
87 // not send the event to any other observers and returns true. Returns false | 94 // not send the event to any other observers and returns true. Returns false |
88 // if no observer returns true. | 95 // if no observer returns true. |
89 bool WillProcessXEvent(XEvent* xevent); | 96 bool WillProcessXEvent(XEvent* xevent); |
90 void DidProcessXEvent(XEvent* xevent); | 97 void DidProcessXEvent(XEvent* xevent); |
91 | 98 |
92 // Returns the Dispatcher based on the event's target window. | 99 // Returns the Dispatcher based on the event's target window. |
93 MessagePumpDispatcher* GetDispatcherForXEvent(const NativeEvent& xev) const; | 100 MessagePumpDispatcher* GetDispatcherForXEvent(const NativeEvent& xev) const; |
94 | 101 |
| 102 ObserverList<MessagePumpObserver>& observers() { return observers_; } |
| 103 |
95 // Overridden from MessagePumpDispatcher: | 104 // Overridden from MessagePumpDispatcher: |
96 virtual bool Dispatch(const NativeEvent& event) OVERRIDE; | 105 virtual bool Dispatch(const NativeEvent& event) OVERRIDE; |
97 | 106 |
98 // The event source for X events. | 107 // The event source for X events. |
99 GSource* x_source_; | 108 GSource* x_source_; |
100 | 109 |
101 // The poll attached to |x_source_|. | 110 // The poll attached to |x_source_|. |
102 scoped_ptr<GPollFD> x_poll_; | 111 scoped_ptr<GPollFD> x_poll_; |
103 | 112 |
104 DispatchersMap dispatchers_; | 113 DispatchersMap dispatchers_; |
105 | 114 |
106 // Dispatch calls can cause addition of new dispatchers as we iterate | 115 // Dispatch calls can cause addition of new dispatchers as we iterate |
107 // through them. Use ObserverList to ensure the iterator remains valid across | 116 // through them. Use ObserverList to ensure the iterator remains valid across |
108 // additions. | 117 // additions. |
109 ObserverList<MessagePumpDispatcher> root_window_dispatchers_; | 118 ObserverList<MessagePumpDispatcher> root_window_dispatchers_; |
110 | 119 |
| 120 // List of observers. |
| 121 ObserverList<MessagePumpObserver> observers_; |
| 122 |
111 unsigned long x_root_window_; | 123 unsigned long x_root_window_; |
112 | 124 |
113 DISALLOW_COPY_AND_ASSIGN(MessagePumpAuraX11); | 125 DISALLOW_COPY_AND_ASSIGN(MessagePumpAuraX11); |
114 }; | 126 }; |
115 | 127 |
116 typedef MessagePumpAuraX11 MessagePumpForUI; | 128 typedef MessagePumpAuraX11 MessagePumpForUI; |
117 | 129 |
118 } // namespace base | 130 } // namespace base |
119 | 131 |
120 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_AURAX11_H | 132 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_AURAX11_H |
OLD | NEW |