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

Side by Side Diff: chrome/browser/chromeos/events/event_rewriter.cc

Issue 223483002: base: Do not allow MessagePumpObservers to consume events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tot-merge-r262009 Created 6 years, 8 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 | Annotate | Revision Log
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 "chrome/browser/chromeos/events/event_rewriter.h" 5 #include "chrome/browser/chromeos/events/event_rewriter.h"
6 6
7 #include <X11/extensions/XInput2.h> 7 #include <X11/extensions/XInput2.h>
8 #include <X11/keysym.h> 8 #include <X11/keysym.h>
9 #include <X11/XF86keysym.h> 9 #include <X11/XF86keysym.h>
10 #include <X11/Xlib.h> 10 #include <X11/Xlib.h>
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 device_id_to_type_.find(device_id); 186 device_id_to_type_.find(device_id);
187 if (iter == device_id_to_type_.end()) { 187 if (iter == device_id_to_type_.end()) {
188 // |device_id| is unknown. This means the device was connected before 188 // |device_id| is unknown. This means the device was connected before
189 // booting the OS. Query the name of the device and add it to the map. 189 // booting the OS. Query the name of the device and add it to the map.
190 DeviceAdded(device_id); 190 DeviceAdded(device_id);
191 } 191 }
192 192
193 last_device_id_ = device_id; 193 last_device_id_ = device_id;
194 } 194 }
195 195
196 base::EventStatus EventRewriter::WillProcessEvent( 196 void EventRewriter::WillProcessEvent(const base::NativeEvent& event) {
197 const base::NativeEvent& event) {
198 XEvent* xevent = event; 197 XEvent* xevent = event;
199 if (xevent->type == KeyPress || xevent->type == KeyRelease) { 198 if (xevent->type == KeyPress || xevent->type == KeyRelease) {
200 Rewrite(xevent); 199 Rewrite(xevent);
201 } else if (xevent->type == GenericEvent) { 200 } else if (xevent->type == GenericEvent) {
202 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xevent->xcookie.data); 201 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xevent->xcookie.data);
203 if (xievent->evtype == XI_KeyPress || xievent->evtype == XI_KeyRelease) { 202 if (xievent->evtype == XI_KeyPress || xievent->evtype == XI_KeyRelease) {
204 if (xievent->deviceid == xievent->sourceid) 203 if (xievent->deviceid == xievent->sourceid)
205 DeviceKeyPressedOrReleased(xievent->deviceid); 204 DeviceKeyPressedOrReleased(xievent->deviceid);
206 } else { 205 } else {
207 RewriteLocatedEvent(xevent); 206 RewriteLocatedEvent(xevent);
208 } 207 }
209 } else if (xevent->type == MappingNotify) { 208 } else if (xevent->type == MappingNotify) {
210 if (xevent->xmapping.request == MappingModifier || 209 if (xevent->xmapping.request == MappingModifier ||
211 xevent->xmapping.request == MappingKeyboard) { 210 xevent->xmapping.request == MappingKeyboard) {
212 RefreshKeycodes(); 211 RefreshKeycodes();
213 } 212 }
214 } 213 }
215 return base::EVENT_CONTINUE;
216 } 214 }
217 215
218 void EventRewriter::DidProcessEvent(const base::NativeEvent& event) { 216 void EventRewriter::DidProcessEvent(const base::NativeEvent& event) {
219 } 217 }
220 218
221 void EventRewriter::DeviceHierarchyChanged() {} 219 void EventRewriter::DeviceHierarchyChanged() {}
222 220
223 void EventRewriter::DeviceAdded(int device_id) { 221 void EventRewriter::DeviceAdded(int device_id) {
224 DCHECK_NE(XIAllDevices, device_id); 222 DCHECK_NE(XIAllDevices, device_id);
225 DCHECK_NE(XIAllMasterDevices, device_id); 223 DCHECK_NE(XIAllMasterDevices, device_id);
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 VLOG(1) << "Apple keyboard '" << device_name << "' connected: " 891 VLOG(1) << "Apple keyboard '" << device_name << "' connected: "
894 << "id=" << device_id; 892 << "id=" << device_id;
895 } 893 }
896 // Always overwrite the existing device_id since the X server may reuse a 894 // Always overwrite the existing device_id since the X server may reuse a
897 // device id for an unattached device. 895 // device id for an unattached device.
898 device_id_to_type_[device_id] = type; 896 device_id_to_type_[device_id] = type;
899 return type; 897 return type;
900 } 898 }
901 899
902 } // namespace chromeos 900 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/events/event_rewriter.h ('k') | chrome/browser/chromeos/events/system_key_event_listener.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698