| 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 #include "base/message_loop/message_pump_x11.h" | 5 #include "base/message_loop/message_pump_x11.h" |
| 6 | 6 |
| 7 #include <glib.h> | 7 #include <glib.h> |
| 8 #include <X11/X.h> | 8 #include <X11/X.h> |
| 9 #include <X11/extensions/XInput2.h> | 9 #include <X11/extensions/XInput2.h> |
| 10 #include <X11/XKBlib.h> | 10 #include <X11/XKBlib.h> |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 #endif | 59 #endif |
| 60 | 60 |
| 61 void MessagePumpX11::AddObserver(MessagePumpObserver* observer) { | 61 void MessagePumpX11::AddObserver(MessagePumpObserver* observer) { |
| 62 observers_.AddObserver(observer); | 62 observers_.AddObserver(observer); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void MessagePumpX11::RemoveObserver(MessagePumpObserver* observer) { | 65 void MessagePumpX11::RemoveObserver(MessagePumpObserver* observer) { |
| 66 observers_.RemoveObserver(observer); | 66 observers_.RemoveObserver(observer); |
| 67 } | 67 } |
| 68 | 68 |
| 69 bool MessagePumpX11::WillProcessXEvent(XEvent* xevent) { | 69 void MessagePumpX11::WillProcessXEvent(XEvent* xevent) { |
| 70 if (!observers_.might_have_observers()) | 70 FOR_EACH_OBSERVER(MessagePumpObserver, observers_, WillProcessEvent(xevent)); |
| 71 return false; | |
| 72 ObserverListBase<MessagePumpObserver>::Iterator it(observers_); | |
| 73 MessagePumpObserver* obs; | |
| 74 while ((obs = it.GetNext()) != NULL) { | |
| 75 if (obs->WillProcessEvent(xevent)) | |
| 76 return true; | |
| 77 } | |
| 78 return false; | |
| 79 } | 71 } |
| 80 | 72 |
| 81 void MessagePumpX11::DidProcessXEvent(XEvent* xevent) { | 73 void MessagePumpX11::DidProcessXEvent(XEvent* xevent) { |
| 82 FOR_EACH_OBSERVER(MessagePumpObserver, observers_, DidProcessEvent(xevent)); | 74 FOR_EACH_OBSERVER(MessagePumpObserver, observers_, DidProcessEvent(xevent)); |
| 83 } | 75 } |
| 84 | 76 |
| 85 } // namespace base | 77 } // namespace base |
| OLD | NEW |