Chromium Code Reviews| Index: remoting/client/plugin/mac_key_event_processor.cc |
| diff --git a/remoting/client/plugin/mac_key_event_processor.cc b/remoting/client/plugin/mac_key_event_processor.cc |
| index ac82745cacd05fdf24d7cdd45cd4ef2cef6a8e62..ab8f17c8a60277f74a59478bf30d1ce76293f5f0 100644 |
| --- a/remoting/client/plugin/mac_key_event_processor.cc |
| +++ b/remoting/client/plugin/mac_key_event_processor.cc |
| @@ -10,13 +10,15 @@ namespace remoting { |
| namespace { |
| -// A list of known keycodes. |
| -const int kShift = 16; |
| -const int kControl = 17; |
| -const int kOption = 18; |
| -const int kCapsLock = 20; |
| -const int kLeftCmd = 91; |
| -const int kRightCmd = 93; |
| +const unsigned int kUsbLeftControl = 0x0700e0; |
| +const unsigned int kUsbLeftShift = 0x0700e1; |
| +const unsigned int kUsbLeftOption = 0x0700e2; |
| +const unsigned int kUsbLeftCmd = 0x0700e3; |
| +const unsigned int kUsbRightControl = 0x0700e4; |
| +const unsigned int kUsbRightShift = 0x0700e5; |
| +const unsigned int kUsbRightOption = 0x0700e6; |
| +const unsigned int kUsbRightCmd = 0x0700e7; |
| +const unsigned int kUsbTab = 0x07002b; |
| } // namespace |
| @@ -28,19 +30,30 @@ MacKeyEventProcessor::~MacKeyEventProcessor() { |
| } |
| void MacKeyEventProcessor::InjectKeyEvent(const protocol::KeyEvent& event) { |
|
Wez
2012/05/22 00:17:08
nit: DCHECK(event.has_usb_keycode());
|
| - if (event.pressed()) { |
| - key_pressed_map_[event.keycode()] = event; |
| - } else { |
| - key_pressed_map_.erase(event.keycode()); |
| - if (event.keycode() == kLeftCmd || event.keycode() == kRightCmd) |
| - GenerateKeyupEvents(); |
| + bool special_key = event.usb_keycode() == kUsbLeftControl || |
|
Wez
2012/05/22 00:17:08
nit: is_special_key
|
| + event.usb_keycode() == kUsbLeftShift || |
| + event.usb_keycode() == kUsbLeftOption || |
| + event.usb_keycode() == kUsbRightControl || |
| + event.usb_keycode() == kUsbRightShift || |
| + event.usb_keycode() == kUsbRightOption || |
| + event.usb_keycode() == kUsbTab; |
| + |
| + bool cmd_key = event.usb_keycode() == kUsbLeftCmd || |
|
Wez
2012/05/22 00:17:08
nit: is_cmd_key
|
| + event.usb_keycode() == kUsbRightCmd; |
| + |
| + if (!cmd_key && !special_key) { |
| + if (event.pressed()) { |
| + key_pressed_map_[event.usb_keycode()] = event; |
| + } else { |
| + key_pressed_map_.erase(event.usb_keycode()); |
| + } |
| } |
| - InputFilter::InjectKeyEvent(event); |
| -} |
| + if (cmd_key && !event.pressed()) { |
| + GenerateKeyupEvents(); |
| + } |
| -int MacKeyEventProcessor::NumberOfPressedKeys() const { |
| - return key_pressed_map_.size(); |
| + InputFilter::InjectKeyEvent(event); |
| } |
| void MacKeyEventProcessor::GenerateKeyupEvents() { |
| @@ -52,12 +65,6 @@ void MacKeyEventProcessor::GenerateKeyupEvents() { |
| i != key_pressed_map_.end(); ++i) { |
| const int keycode = i->first; |
| - if (keycode == kCapsLock || keycode == kOption || |
| - keycode == kControl || keycode == kShift || |
| - keycode == kLeftCmd || keycode == kRightCmd) { |
| - continue; |
| - } |
| - |
| keycodes.push_back(keycode); |
| protocol::KeyEvent event = i->second; |
| event.set_pressed(false); |