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

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: Changed ALL_DEVICES to kAllDevices Created 4 years, 4 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 | « ui/events/devices/x11/device_data_manager_x11.cc ('k') | 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 if (time_difference < 0 || time_difference > (UINT32_MAX >> 1)) 199 if (time_difference < 0 || time_difference > (UINT32_MAX >> 1))
200 last_seen_server_time_ = event_time; 200 last_seen_server_time_ = event_time;
201 } 201 }
202 delegate_->ProcessXEvent(xevent); 202 delegate_->ProcessXEvent(xevent);
203 PostDispatchEvent(xevent); 203 PostDispatchEvent(xevent);
204 if (have_cookie) 204 if (have_cookie)
205 XFreeEventData(xevent->xgeneric.display, &xevent->xcookie); 205 XFreeEventData(xevent->xgeneric.display, &xevent->xcookie);
206 } 206 }
207 207
208 void X11EventSource::PostDispatchEvent(XEvent* xevent) { 208 void X11EventSource::PostDispatchEvent(XEvent* xevent) {
209 if (xevent->type == GenericEvent && 209 bool should_update_device_list = false;
210 (xevent->xgeneric.evtype == XI_HierarchyChanged || 210
211 xevent->xgeneric.evtype == XI_DeviceChanged)) { 211 if (xevent->type == GenericEvent) {
212 if (xevent->xgeneric.evtype == XI_HierarchyChanged) {
213 should_update_device_list = true;
214 } else if (xevent->xgeneric.evtype == XI_DeviceChanged) {
215 XIDeviceChangedEvent* xev =
216 static_cast<XIDeviceChangedEvent*>(xevent->xcookie.data);
217 if (xev->reason == XIDeviceChange) {
218 should_update_device_list = true;
219 } else if (xev->reason == XISlaveSwitch) {
220 ui::DeviceDataManagerX11::GetInstance()->InvalidateScrollClasses(
221 xev->sourceid);
222 }
223 }
224 }
225
226 if (should_update_device_list) {
212 UpdateDeviceList(); 227 UpdateDeviceList();
213 hotplug_event_handler_->OnHotplugEvent(); 228 hotplug_event_handler_->OnHotplugEvent();
214 } 229 }
215 230
216 if (xevent->type == EnterNotify && 231 if (xevent->type == EnterNotify &&
217 xevent->xcrossing.detail != NotifyInferior && 232 xevent->xcrossing.detail != NotifyInferior &&
218 xevent->xcrossing.mode != NotifyUngrab) { 233 xevent->xcrossing.mode != NotifyUngrab) {
219 // Clear stored scroll data 234 // Clear stored scroll data
220 ui::DeviceDataManagerX11::GetInstance()->InvalidateScrollClasses(); 235 ui::DeviceDataManagerX11::GetInstance()->InvalidateScrollClasses(
236 DeviceDataManagerX11::kAllDevices);
221 } 237 }
222 } 238 }
223 239
224 void X11EventSource::BlockOnWindowStructureEvent(XID window, int type) { 240 void X11EventSource::BlockOnWindowStructureEvent(XID window, int type) {
225 XEvent event; 241 XEvent event;
226 do { 242 do {
227 // Block until there's a StructureNotify event of |type| on |window|. Then 243 // Block until there's a StructureNotify event of |type| on |window|. Then
228 // remove it from the queue and stuff it in |event|. 244 // remove it from the queue and stuff it in |event|.
229 XWindowEvent(display_, window, StructureNotifyMask, &event); 245 XWindowEvent(display_, window, StructureNotifyMask, &event);
230 ExtractCookieDataDispatchEvent(&event); 246 ExtractCookieDataDispatchEvent(&event);
231 } while (event.type != type); 247 } while (event.type != type);
232 } 248 }
233 249
234 void X11EventSource::StopCurrentEventStream() { 250 void X11EventSource::StopCurrentEventStream() {
235 continue_stream_ = false; 251 continue_stream_ = false;
236 } 252 }
237 253
238 void X11EventSource::OnDispatcherListChanged() { 254 void X11EventSource::OnDispatcherListChanged() {
239 if (!hotplug_event_handler_) { 255 if (!hotplug_event_handler_) {
240 hotplug_event_handler_.reset(new X11HotplugEventHandler()); 256 hotplug_event_handler_.reset(new X11HotplugEventHandler());
241 // Force the initial device query to have an update list of active devices. 257 // Force the initial device query to have an update list of active devices.
242 hotplug_event_handler_->OnHotplugEvent(); 258 hotplug_event_handler_->OnHotplugEvent();
243 } 259 }
244 } 260 }
245 261
246 } // namespace ui 262 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/devices/x11/device_data_manager_x11.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698