Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Side by Side Diff: ui/events/platform/x11/x11_event_source.cc

Issue 2077163003: Reduced number of UpdateDeviceList calls (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.h" 5 #include "ui/events/platform/x11/x11_event_source.h"
6 6
7 #include <X11/Xatom.h> 7 #include <X11/Xatom.h>
8 #include <X11/XKBlib.h> 8 #include <X11/XKBlib.h>
9 #include <X11/Xlib.h> 9 #include <X11/Xlib.h>
10 10
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 last_seen_server_time_ = event_time; 202 last_seen_server_time_ = event_time;
203 } 203 }
204 delegate_->ProcessXEvent(xevent); 204 delegate_->ProcessXEvent(xevent);
205 PostDispatchEvent(xevent); 205 PostDispatchEvent(xevent);
206 if (have_cookie) 206 if (have_cookie)
207 XFreeEventData(xevent->xgeneric.display, &xevent->xcookie); 207 XFreeEventData(xevent->xgeneric.display, &xevent->xcookie);
208 } 208 }
209 209
210 void X11EventSource::PostDispatchEvent(XEvent* xevent) { 210 void X11EventSource::PostDispatchEvent(XEvent* xevent) {
211 if (xevent->type == GenericEvent && 211 if (xevent->type == GenericEvent &&
212 (xevent->xgeneric.evtype == XI_HierarchyChanged || 212 xevent->xgeneric.evtype == XI_HierarchyChanged) {
213 xevent->xgeneric.evtype == XI_DeviceChanged)) {
214 UpdateDeviceList(); 213 UpdateDeviceList();
215 hotplug_event_handler_->OnHotplugEvent(); 214 hotplug_event_handler_->OnHotplugEvent();
216 } 215 }
217 216
217 if (xevent->type == GenericEvent &&
218 xevent->xgeneric.evtype == XI_DeviceChanged) {
219 XIDeviceChangedEvent* xev =
220 static_cast<XIDeviceChangedEvent*>(xevent->xcookie.data);
221 if (xev->reason == XIDeviceChange) {
222 UpdateDeviceList();
223 hotplug_event_handler_->OnHotplugEvent();
224 } else { // XISlaveSwitch
225 ui::DeviceDataManagerX11::GetInstance()->InvalidateScrollClasses();
226 }
227 }
228
sadrul 2016/06/20 19:37:30 How about: bool should_update_list = false; i
Will Shackleton 2016/06/21 16:27:46 Done.
218 if (xevent->type == EnterNotify && 229 if (xevent->type == EnterNotify &&
219 xevent->xcrossing.detail != NotifyInferior && 230 xevent->xcrossing.detail != NotifyInferior &&
220 xevent->xcrossing.mode != NotifyUngrab) { 231 xevent->xcrossing.mode != NotifyUngrab) {
221 // Clear stored scroll data 232 // Clear stored scroll data
222 ui::DeviceDataManagerX11::GetInstance()->InvalidateScrollClasses(); 233 ui::DeviceDataManagerX11::GetInstance()->InvalidateScrollClasses();
223 } 234 }
224 } 235 }
225 236
226 void X11EventSource::StopCurrentEventStream() { 237 void X11EventSource::StopCurrentEventStream() {
227 continue_stream_ = false; 238 continue_stream_ = false;
228 } 239 }
229 240
230 void X11EventSource::OnDispatcherListChanged() { 241 void X11EventSource::OnDispatcherListChanged() {
231 if (!hotplug_event_handler_) { 242 if (!hotplug_event_handler_) {
232 hotplug_event_handler_.reset(new X11HotplugEventHandler()); 243 hotplug_event_handler_.reset(new X11HotplugEventHandler());
233 // Force the initial device query to have an update list of active devices. 244 // Force the initial device query to have an update list of active devices.
234 hotplug_event_handler_->OnHotplugEvent(); 245 hotplug_event_handler_->OnHotplugEvent();
235 } 246 }
236 } 247 }
237 248
238 } // namespace ui 249 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698