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

Unified Diff: remoting/client/input_handler.cc

Issue 3175028: Add mouse event support to Chromoting client (Pepper and X11). (Closed)
Patch Set: Remove win float/int conversion Created 10 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/client/input_handler.h ('k') | remoting/client/jingle_host_connection.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/client/input_handler.cc
diff --git a/remoting/client/input_handler.cc b/remoting/client/input_handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..dd0fd7aa558c34ef14629a6856750df8faad2867
--- /dev/null
+++ b/remoting/client/input_handler.cc
@@ -0,0 +1,69 @@
+// Copyright (c) 2010 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/client/input_handler.h"
+
+#include "remoting/client/chromoting_view.h"
+#include "remoting/client/host_connection.h"
+
+namespace remoting {
+
+InputHandler::InputHandler(ClientContext* context,
+ HostConnection* connection,
+ ChromotingView* view)
+ : context_(context),
+ connection_(connection),
+ view_(view),
+ send_absolute_mouse_(true),
+ mouse_x_(0),
+ mouse_y_(0) {
+}
+
+void InputHandler::SendMouseMoveEvent(int x, int y) {
+ ChromotingClientMessage msg;
+
+ if (send_absolute_mouse_) {
+ MouseSetPositionEvent *event = msg.mutable_mouse_set_position_event();
+ event->set_x(x);
+ event->set_y(y);
+
+ int width, height;
+ view_->GetScreenSize(&width, &height);
+ event->set_width(width);
+ event->set_height(height);
+
+ // TODO(garykac): Fix drift problem with relative mouse events and
+ // then re-add this line.
+ //send_absolute_mouse_ = false;
+ } else {
+ MouseMoveEvent *event = msg.mutable_mouse_move_event();
+ int dx = x - mouse_x_;
+ int dy = y - mouse_y_;
+ if (dx == 0 && dy == 0) {
+ return;
+ }
+ event->set_offset_x(dx);
+ event->set_offset_y(dy);
+ }
+ // Record current mouse position.
+ mouse_x_ = x;
+ mouse_y_ = y;
+
+ connection_->SendEvent(msg);
+}
+
+void InputHandler::SendMouseButtonEvent(bool button_down,
+ MouseButton button) {
+ ChromotingClientMessage msg;
+
+ if (button_down) {
+ msg.mutable_mouse_down_event()->set_button(button);
+ } else {
+ msg.mutable_mouse_up_event()->set_button(button);
+ }
+
+ connection_->SendEvent(msg);
+}
+
+} // namespace remoting
« no previous file with comments | « remoting/client/input_handler.h ('k') | remoting/client/jingle_host_connection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698