OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/ash/event_rewriter.h" | 5 #include "chrome/browser/ui/ash/event_rewriter.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 #if defined(OS_CHROMEOS) | 230 #if defined(OS_CHROMEOS) |
231 void EventRewriter::DeviceAdded(int device_id) { | 231 void EventRewriter::DeviceAdded(int device_id) { |
232 DCHECK_NE(XIAllDevices, device_id); | 232 DCHECK_NE(XIAllDevices, device_id); |
233 DCHECK_NE(XIAllMasterDevices, device_id); | 233 DCHECK_NE(XIAllMasterDevices, device_id); |
234 if (device_id == XIAllDevices || device_id == XIAllMasterDevices) { | 234 if (device_id == XIAllDevices || device_id == XIAllMasterDevices) { |
235 LOG(ERROR) << "Unexpected device_id passed: " << device_id; | 235 LOG(ERROR) << "Unexpected device_id passed: " << device_id; |
236 return; | 236 return; |
237 } | 237 } |
238 | 238 |
239 int ndevices_return = 0; | 239 int ndevices_return = 0; |
240 XIDeviceInfo* device_info = XIQueryDevice(ui::GetXDisplay(), | 240 XIDeviceInfo* device_info = XIQueryDevice(gfx::GetXDisplay(), |
241 device_id, | 241 device_id, |
242 &ndevices_return); | 242 &ndevices_return); |
243 | 243 |
244 // Since |device_id| is neither XIAllDevices nor XIAllMasterDevices, | 244 // Since |device_id| is neither XIAllDevices nor XIAllMasterDevices, |
245 // the number of devices found should be either 0 (not found) or 1. | 245 // the number of devices found should be either 0 (not found) or 1. |
246 if (!device_info) { | 246 if (!device_info) { |
247 LOG(ERROR) << "XIQueryDevice: Device ID " << device_id << " is unknown."; | 247 LOG(ERROR) << "XIQueryDevice: Device ID " << device_id << " is unknown."; |
248 return; | 248 return; |
249 } | 249 } |
250 | 250 |
(...skipping 24 matching lines...) Expand all Loading... |
275 } | 275 } |
276 | 276 |
277 void EventRewriter::RefreshKeycodes() { | 277 void EventRewriter::RefreshKeycodes() { |
278 keysym_to_keycode_map_.clear(); | 278 keysym_to_keycode_map_.clear(); |
279 } | 279 } |
280 | 280 |
281 KeyCode EventRewriter::NativeKeySymToNativeKeycode(KeySym keysym) { | 281 KeyCode EventRewriter::NativeKeySymToNativeKeycode(KeySym keysym) { |
282 if (keysym_to_keycode_map_.count(keysym)) | 282 if (keysym_to_keycode_map_.count(keysym)) |
283 return keysym_to_keycode_map_[keysym]; | 283 return keysym_to_keycode_map_[keysym]; |
284 | 284 |
285 Display* display = ui::GetXDisplay(); | 285 XDisplay* display = gfx::GetXDisplay(); |
286 KeyCode keycode = XKeysymToKeycode(display, keysym); | 286 KeyCode keycode = XKeysymToKeycode(display, keysym); |
287 keysym_to_keycode_map_[keysym] = keycode; | 287 keysym_to_keycode_map_[keysym] = keycode; |
288 return keycode; | 288 return keycode; |
289 } | 289 } |
290 | 290 |
291 bool EventRewriter::RewriteWithKeyboardRemappingsByKeySym( | 291 bool EventRewriter::RewriteWithKeyboardRemappingsByKeySym( |
292 const KeyboardRemapping* remappings, | 292 const KeyboardRemapping* remappings, |
293 size_t num_remappings, | 293 size_t num_remappings, |
294 KeySym keysym, | 294 KeySym keysym, |
295 unsigned int native_mods, | 295 unsigned int native_mods, |
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1011 const DeviceType type = EventRewriter::GetDeviceType(device_name); | 1011 const DeviceType type = EventRewriter::GetDeviceType(device_name); |
1012 if (type == kDeviceAppleKeyboard) { | 1012 if (type == kDeviceAppleKeyboard) { |
1013 VLOG(1) << "Apple keyboard '" << device_name << "' connected: " | 1013 VLOG(1) << "Apple keyboard '" << device_name << "' connected: " |
1014 << "id=" << device_id; | 1014 << "id=" << device_id; |
1015 } | 1015 } |
1016 // Always overwrite the existing device_id since the X server may reuse a | 1016 // Always overwrite the existing device_id since the X server may reuse a |
1017 // device id for an unattached device. | 1017 // device id for an unattached device. |
1018 device_id_to_type_[device_id] = type; | 1018 device_id_to_type_[device_id] = type; |
1019 return type; | 1019 return type; |
1020 } | 1020 } |
OLD | NEW |