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

Unified Diff: remoting/protocol/key_event_tracker.cc

Issue 8985007: Refactoring of the client-side input pipeline and scaling dimension management. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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 side-by-side diff with in-line comments
Download patch
Index: remoting/protocol/key_event_tracker.cc
diff --git a/remoting/protocol/key_event_tracker.cc b/remoting/protocol/key_event_tracker.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c6e1310b0e3310222b36e4db79e73883a303dca3
--- /dev/null
+++ b/remoting/protocol/key_event_tracker.cc
@@ -0,0 +1,51 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/protocol/key_event_tracker.h"
+
+#include "base/logging.h"
+#include "remoting/proto/event.pb.h"
+
+namespace remoting {
+
Sergey Ulanov 2011/12/20 00:05:35 remove this line
Wez 2011/12/20 07:14:14 Done.
+namespace protocol {
+
+KeyEventTracker::KeyEventTracker(InputStub* input_stub)
+ : input_stub_(input_stub)
+{
Sergey Ulanov 2011/12/20 00:05:35 must be on the previous line.
Wez 2011/12/20 07:14:14 Done.
+}
+
+KeyEventTracker::~KeyEventTracker() {
+ DCHECK(pressed_keys_.empty());
+}
+
+void KeyEventTracker::InjectKeyEvent(const KeyEvent& event) {
+ DCHECK(event.has_pressed());
+ DCHECK(event.has_keycode());
+ if (event.pressed()) {
+ pressed_keys_.insert(event.keycode());
+ } else {
+ pressed_keys_.erase(event.keycode());
+ }
+ input_stub_->InjectKeyEvent(event);
+}
+
+void KeyEventTracker::InjectMouseEvent(const MouseEvent& event) {
+ input_stub_->InjectMouseEvent(event);
+}
+
+void KeyEventTracker::ReleaseAllKeys() {
+ std::set<int>::iterator i;
+ for (i = pressed_keys_.begin(); i != pressed_keys_.end(); ++i) {
+ KeyEvent event;
+ event.set_keycode(*i);
+ event.set_pressed(false);
+ input_stub_->InjectKeyEvent(event);
+ }
+ pressed_keys_.clear();
+}
+
+} // namespace protocol
+
+} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698