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

Unified Diff: remoting/tools/javascript_key_tester/pnacl/remoting_key_tester.cc

Issue 2063623002: [Chromoting] Log mouse events in remoting_key_tester (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolve review comments -- Remove LogToConsole(s). Created 4 years, 6 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/tools/javascript_key_tester/main.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/tools/javascript_key_tester/pnacl/remoting_key_tester.cc
diff --git a/remoting/tools/javascript_key_tester/pnacl/remoting_key_tester.cc b/remoting/tools/javascript_key_tester/pnacl/remoting_key_tester.cc
index 408725c5e4a77b7ae7f401e79d80114736b900ef..cde6fa388ba97ac9de92273dbe5d6dd3980066f7 100644
--- a/remoting/tools/javascript_key_tester/pnacl/remoting_key_tester.cc
+++ b/remoting/tools/javascript_key_tester/pnacl/remoting_key_tester.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <sstream>
+#include <string>
#include "ppapi/cpp/input_event.h"
#include "ppapi/cpp/instance.h"
@@ -15,12 +15,13 @@ namespace remoting {
class KeyTesterInstance : public pp::Instance {
public:
explicit KeyTesterInstance(PP_Instance instance) : pp::Instance(instance) {
+ RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE | PP_INPUTEVENT_CLASS_WHEEL);
RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_KEYBOARD);
}
virtual ~KeyTesterInstance() {}
- virtual bool HandleInputEvent(const pp::InputEvent& event) {
+ bool HandleInputEvent(const pp::InputEvent& event) override {
switch (event.GetType()) {
case PP_INPUTEVENT_TYPE_KEYDOWN:
case PP_INPUTEVENT_TYPE_KEYUP:
@@ -28,6 +29,19 @@ class KeyTesterInstance : public pp::Instance {
HandleKeyboardEvent(pp::KeyboardInputEvent(event));
break;
}
+ case PP_INPUTEVENT_TYPE_MOUSEDOWN:
+ case PP_INPUTEVENT_TYPE_MOUSEUP:
+ case PP_INPUTEVENT_TYPE_MOUSEMOVE:
+ case PP_INPUTEVENT_TYPE_MOUSEENTER:
+ case PP_INPUTEVENT_TYPE_MOUSELEAVE:
+ case PP_INPUTEVENT_TYPE_CONTEXTMENU: {
+ HandleMouseEvent(pp::MouseInputEvent(event));
+ break;
+ }
+ case PP_INPUTEVENT_TYPE_WHEEL: {
+ HandleWheelEvent(pp::WheelInputEvent(event));
+ break;
+ }
default:
break;
}
@@ -45,7 +59,31 @@ class KeyTesterInstance : public pp::Instance {
PostMessage(out);
}
- std::string EventTypeToString(PP_InputEvent_Type t) {
+ void HandleMouseEvent(const pp::MouseInputEvent& event) {
+ pp::VarDictionary out;
+ out.Set("type", EventTypeToString(event.GetType()));
+ out.Set("button", (double)event.GetButton());
+ out.Set("position", PointToString(event.GetPosition()));
+ out.Set("clickCount", event.GetClickCount());
+ out.Set("movement", PointToString(event.GetMovement()));
+ PostMessage(out);
+ }
+
+ void HandleWheelEvent(const pp::WheelInputEvent& event) {
+ pp::VarDictionary out;
+ out.Set("type", EventTypeToString(event.GetType()));
+ out.Set("delta", PointToString(event.GetDelta()));
+ out.Set("ticks", PointToString(event.GetTicks()));
+ out.Set("scrollByPage", event.GetScrollByPage());
+ PostMessage(out);
+ }
+
+ template <typename T>
+ static std::string PointToString(const T& point) {
+ return std::to_string(point.x()) + ", " + std::to_string(point.y());
+ }
+
+ static std::string EventTypeToString(PP_InputEvent_Type t) {
switch (t) {
case PP_INPUTEVENT_TYPE_UNDEFINED:
return "UNDEFINED";
« no previous file with comments | « remoting/tools/javascript_key_tester/main.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698