Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/events/platform/x11/x11_event_source_libevent.h" | 5 #include "ui/events/platform/x11/x11_event_source_libevent.h" |
| 6 | 6 |
| 7 #include <X11/Xlib.h> | 7 #include <X11/Xlib.h> |
| 8 #include <X11/extensions/XInput2.h> | 8 #include <X11/extensions/XInput2.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 return; | 172 return; |
| 173 | 173 |
| 174 int fd = ConnectionNumber(event_source_.display()); | 174 int fd = ConnectionNumber(event_source_.display()); |
| 175 base::MessageLoopForUI::current()->WatchFileDescriptor( | 175 base::MessageLoopForUI::current()->WatchFileDescriptor( |
| 176 fd, true, base::MessagePumpLibevent::WATCH_READ, &watcher_controller_, | 176 fd, true, base::MessagePumpLibevent::WATCH_READ, &watcher_controller_, |
| 177 this); | 177 this); |
| 178 initialized_ = true; | 178 initialized_ = true; |
| 179 } | 179 } |
| 180 | 180 |
| 181 void X11EventSourceLibevent::DispatchXEventToXEventDispatchers(XEvent* xevent) { | 181 void X11EventSourceLibevent::DispatchXEventToXEventDispatchers(XEvent* xevent) { |
| 182 if (dispatchers_xevent_.might_have_observers()) { | 182 for (auto& dispatcher : dispatchers_xevent_) { |
|
sky
2016/10/13 02:20:57
This code is called on every mouse event, so it se
dcheng
2016/10/13 02:39:22
Creation of the iterator is cheap if might_have_ob
loyso (OOO)
2016/10/13 02:40:26
We have that optimization as a built-in. If underl
| |
| 183 base::ObserverList<XEventDispatcher>::Iterator iter(&dispatchers_xevent_); | 183 if (dispatcher.DispatchXEvent(xevent)) |
| 184 while (XEventDispatcher* dispatcher = iter.GetNext()) { | 184 break; |
| 185 if (dispatcher->DispatchXEvent(xevent)) | |
| 186 break; | |
| 187 } | |
| 188 } | 185 } |
| 189 } | 186 } |
| 190 | 187 |
| 191 void X11EventSourceLibevent::StopCurrentEventStream() { | 188 void X11EventSourceLibevent::StopCurrentEventStream() { |
| 192 event_source_.StopCurrentEventStream(); | 189 event_source_.StopCurrentEventStream(); |
| 193 } | 190 } |
| 194 | 191 |
| 195 void X11EventSourceLibevent::OnDispatcherListChanged() { | 192 void X11EventSourceLibevent::OnDispatcherListChanged() { |
| 196 AddEventWatcher(); | 193 AddEventWatcher(); |
| 197 event_source_.OnDispatcherListChanged(); | 194 event_source_.OnDispatcherListChanged(); |
| 198 } | 195 } |
| 199 | 196 |
| 200 void X11EventSourceLibevent::OnFileCanReadWithoutBlocking(int fd) { | 197 void X11EventSourceLibevent::OnFileCanReadWithoutBlocking(int fd) { |
| 201 event_source_.DispatchXEvents(); | 198 event_source_.DispatchXEvents(); |
| 202 } | 199 } |
| 203 | 200 |
| 204 void X11EventSourceLibevent::OnFileCanWriteWithoutBlocking(int fd) { | 201 void X11EventSourceLibevent::OnFileCanWriteWithoutBlocking(int fd) { |
| 205 NOTREACHED(); | 202 NOTREACHED(); |
| 206 } | 203 } |
| 207 | 204 |
| 208 } // namespace ui | 205 } // namespace ui |
| OLD | NEW |