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 #include "base/message_pump_x.h" | 5 #include "base/message_pump_x.h" |
6 | 6 |
7 #include <X11/extensions/XInput2.h> | 7 #include <X11/extensions/XInput2.h> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 XEvent xev; | 176 XEvent xev; |
177 XNextEvent(display, &xev); | 177 XNextEvent(display, &xev); |
178 if (ProcessXEvent(dispatcher, &xev)) | 178 if (ProcessXEvent(dispatcher, &xev)) |
179 return true; | 179 return true; |
180 } | 180 } |
181 | 181 |
182 return g_main_context_iteration(context, block); | 182 return g_main_context_iteration(context, block); |
183 } | 183 } |
184 | 184 |
185 bool MessagePumpX::WillProcessXEvent(XEvent* xevent) { | 185 bool MessagePumpX::WillProcessXEvent(XEvent* xevent) { |
| 186 if (!observers().might_have_observers()) |
| 187 return false; |
186 ObserverListBase<MessagePumpObserver>::Iterator it(observers()); | 188 ObserverListBase<MessagePumpObserver>::Iterator it(observers()); |
187 MessagePumpObserver* obs; | 189 MessagePumpObserver* obs; |
188 while ((obs = it.GetNext()) != NULL) { | 190 while ((obs = it.GetNext()) != NULL) { |
189 if (obs->WillProcessEvent(xevent)) | 191 if (obs->WillProcessEvent(xevent)) |
190 return true; | 192 return true; |
191 } | 193 } |
192 return false; | 194 return false; |
193 } | 195 } |
194 | 196 |
195 void MessagePumpX::DidProcessXEvent(XEvent* xevent) { | 197 void MessagePumpX::DidProcessXEvent(XEvent* xevent) { |
196 ObserverListBase<MessagePumpObserver>::Iterator it(observers()); | 198 FOR_EACH_OBSERVER(MessagePumpObserver, observers(), DidProcessEvent(xevent)); |
197 MessagePumpObserver* obs; | |
198 while ((obs = it.GetNext()) != NULL) { | |
199 obs->DidProcessEvent(xevent); | |
200 } | |
201 } | 199 } |
202 | 200 |
203 } // namespace base | 201 } // namespace base |
OLD | NEW |