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

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: Applied comments, added functionality to only invalidate current scroll device 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
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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 if (time_difference < 0 || time_difference > (UINT32_MAX >> 1)) 201 if (time_difference < 0 || time_difference > (UINT32_MAX >> 1))
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 bool should_update_device_list = false;
212 (xevent->xgeneric.evtype == XI_HierarchyChanged || 212
213 xevent->xgeneric.evtype == XI_DeviceChanged)) { 213 if (xevent->type == GenericEvent) {
214 if (xevent->xgeneric.evtype == XI_HierarchyChanged) {
215 should_update_device_list = true;
216 } else if (xevent->xgeneric.evtype == XI_DeviceChanged) {
217 XIDeviceChangedEvent* xev =
218 static_cast<XIDeviceChangedEvent*>(xevent->xcookie.data);
219 if (xev->reason == XIDeviceChange) {
220 should_update_device_list = true;
221 } else {
222 DCHECK_EQ(XISlaveSwitch, xev->reason);
223 ui::DeviceDataManagerX11::GetInstance()->InvalidateScrollClasses(
224 xev->sourceid);
sadrul 2016/06/27 14:49:21 Can |xev->sourceid| here be really -1?
Will Shackleton 2016/07/12 16:05:04 There are other places |InvalidateScrollClasses| i
225 }
226 }
227 }
228
229 if (should_update_device_list) {
214 UpdateDeviceList(); 230 UpdateDeviceList();
215 hotplug_event_handler_->OnHotplugEvent(); 231 hotplug_event_handler_->OnHotplugEvent();
216 } 232 }
217 233
218 if (xevent->type == EnterNotify && 234 if (xevent->type == EnterNotify &&
219 xevent->xcrossing.detail != NotifyInferior && 235 xevent->xcrossing.detail != NotifyInferior &&
220 xevent->xcrossing.mode != NotifyUngrab) { 236 xevent->xcrossing.mode != NotifyUngrab) {
221 // Clear stored scroll data 237 // Clear stored scroll data
222 ui::DeviceDataManagerX11::GetInstance()->InvalidateScrollClasses(); 238 ui::DeviceDataManagerX11::GetInstance()->InvalidateScrollClasses();
223 } 239 }
224 } 240 }
225 241
226 void X11EventSource::StopCurrentEventStream() { 242 void X11EventSource::StopCurrentEventStream() {
227 continue_stream_ = false; 243 continue_stream_ = false;
228 } 244 }
229 245
230 void X11EventSource::OnDispatcherListChanged() { 246 void X11EventSource::OnDispatcherListChanged() {
231 if (!hotplug_event_handler_) { 247 if (!hotplug_event_handler_) {
232 hotplug_event_handler_.reset(new X11HotplugEventHandler()); 248 hotplug_event_handler_.reset(new X11HotplugEventHandler());
233 // Force the initial device query to have an update list of active devices. 249 // Force the initial device query to have an update list of active devices.
234 hotplug_event_handler_->OnHotplugEvent(); 250 hotplug_event_handler_->OnHotplugEvent();
235 } 251 }
236 } 252 }
237 253
238 } // namespace ui 254 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698