Index: remoting/protocol/input_event_tracker.cc |
diff --git a/remoting/protocol/input_event_tracker.cc b/remoting/protocol/input_event_tracker.cc |
index ab9e585205e3feac801efe9a47e381a4b98b4b4d..785997e1044deaad7c300a4aa77296cbb8e2b229 100644 |
--- a/remoting/protocol/input_event_tracker.cc |
+++ b/remoting/protocol/input_event_tracker.cc |
@@ -28,30 +28,33 @@ int InputEventTracker::PressedKeyCount() const { |
} |
void InputEventTracker::ReleaseAll() { |
- std::set<uint32>::iterator i; |
- for (i = pressed_keys_.begin(); i != pressed_keys_.end(); ++i) { |
- KeyEvent event; |
- event.set_pressed(false); |
- event.set_usb_keycode(*i); |
- input_stub_->InjectKeyEvent(event); |
- } |
- pressed_keys_.clear(); |
+ if (input_stub_) { |
+ std::set<uint32>::iterator i; |
+ for (i = pressed_keys_.begin(); i != pressed_keys_.end(); ++i) { |
+ KeyEvent event; |
+ event.set_pressed(false); |
+ event.set_usb_keycode(*i); |
+ input_stub_->InjectKeyEvent(event); |
+ } |
- for (int i = MouseEvent::BUTTON_UNDEFINED + 1; |
- i < MouseEvent::BUTTON_MAX; ++i) { |
- if (mouse_button_state_ & (1 << (i - 1))) { |
- MouseEvent mouse; |
+ for (int i = MouseEvent::BUTTON_UNDEFINED + 1; |
+ i < MouseEvent::BUTTON_MAX; ++i) { |
+ if (mouse_button_state_ & (1 << (i - 1))) { |
+ MouseEvent mouse; |
- // TODO(wez): EventInjectors should cope with positionless events by |
- // using the current cursor position, and we wouldn't set position here. |
- mouse.set_x(mouse_pos_.x()); |
- mouse.set_y(mouse_pos_.y()); |
+ // TODO(wez): EventInjectors should cope with positionless events by |
+ // using the current cursor position, and we wouldn't set position here. |
+ mouse.set_x(mouse_pos_.x()); |
+ mouse.set_y(mouse_pos_.y()); |
- mouse.set_button((MouseEvent::MouseButton)i); |
- mouse.set_button_down(false); |
- input_stub_->InjectMouseEvent(mouse); |
+ mouse.set_button((MouseEvent::MouseButton)i); |
+ mouse.set_button_down(false); |
+ input_stub_->InjectMouseEvent(mouse); |
+ } |
} |
} |
+ |
+ pressed_keys_.clear(); |
mouse_button_state_ = 0; |
} |
@@ -65,7 +68,9 @@ void InputEventTracker::InjectKeyEvent(const KeyEvent& event) { |
} |
} |
} |
- input_stub_->InjectKeyEvent(event); |
+ |
+ if (input_stub_) |
+ input_stub_->InjectKeyEvent(event); |
} |
void InputEventTracker::InjectMouseEvent(const MouseEvent& event) { |
@@ -83,7 +88,9 @@ void InputEventTracker::InjectMouseEvent(const MouseEvent& event) { |
} |
} |
} |
- input_stub_->InjectMouseEvent(event); |
+ |
+ if (input_stub_) |
+ input_stub_->InjectMouseEvent(event); |
} |
} // namespace protocol |