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

Side by Side Diff: remoting/client/plugin/pepper_input_handler.cc

Issue 23484015: Added support of relative mouse motion in Chromoting. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/client/plugin/pepper_input_handler.h" 5 #include "remoting/client/plugin/pepper_input_handler.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ppapi/c/dev/ppb_keyboard_input_event_dev.h" 8 #include "ppapi/c/dev/ppb_keyboard_input_event_dev.h"
9 #include "ppapi/cpp/input_event.h" 9 #include "ppapi/cpp/input_event.h"
10 #include "ppapi/cpp/module_impl.h" 10 #include "ppapi/cpp/module_impl.h"
(...skipping 17 matching lines...) Expand all
28 uint32_t GetUsbKeyCode(pp::KeyboardInputEvent pp_key_event) { 28 uint32_t GetUsbKeyCode(pp::KeyboardInputEvent pp_key_event) {
29 const PPB_KeyboardInputEvent_Dev* key_event_interface = 29 const PPB_KeyboardInputEvent_Dev* key_event_interface =
30 reinterpret_cast<const PPB_KeyboardInputEvent_Dev*>( 30 reinterpret_cast<const PPB_KeyboardInputEvent_Dev*>(
31 pp::Module::Get()->GetBrowserInterface( 31 pp::Module::Get()->GetBrowserInterface(
32 PPB_KEYBOARD_INPUT_EVENT_DEV_INTERFACE)); 32 PPB_KEYBOARD_INPUT_EVENT_DEV_INTERFACE));
33 if (!key_event_interface) 33 if (!key_event_interface)
34 return 0; 34 return 0;
35 return key_event_interface->GetUsbKeyCode(pp_key_event.pp_resource()); 35 return key_event_interface->GetUsbKeyCode(pp_key_event.pp_resource());
36 } 36 }
37 37
38 bool PepperInputHandler::HandleInputEvent(const pp::InputEvent& event) { 38 bool PepperInputHandler::HandleInputEvent(const pp::InputEvent& event,
39 bool mouse_locked) {
39 switch (event.GetType()) { 40 switch (event.GetType()) {
40 case PP_INPUTEVENT_TYPE_CONTEXTMENU: { 41 case PP_INPUTEVENT_TYPE_CONTEXTMENU: {
41 // We need to return true here or else we'll get a local (plugin) context 42 // We need to return true here or else we'll get a local (plugin) context
42 // menu instead of the mouseup event for the right click. 43 // menu instead of the mouseup event for the right click.
43 return true; 44 return true;
44 } 45 }
45 46
46 case PP_INPUTEVENT_TYPE_KEYDOWN: 47 case PP_INPUTEVENT_TYPE_KEYDOWN:
47 case PP_INPUTEVENT_TYPE_KEYUP: { 48 case PP_INPUTEVENT_TYPE_KEYUP: {
48 pp::KeyboardInputEvent pp_key_event(event); 49 pp::KeyboardInputEvent pp_key_event(event);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 return true; 92 return true;
92 } 93 }
93 94
94 case PP_INPUTEVENT_TYPE_MOUSEMOVE: 95 case PP_INPUTEVENT_TYPE_MOUSEMOVE:
95 case PP_INPUTEVENT_TYPE_MOUSEENTER: 96 case PP_INPUTEVENT_TYPE_MOUSEENTER:
96 case PP_INPUTEVENT_TYPE_MOUSELEAVE: { 97 case PP_INPUTEVENT_TYPE_MOUSELEAVE: {
97 pp::MouseInputEvent pp_mouse_event(event); 98 pp::MouseInputEvent pp_mouse_event(event);
98 protocol::MouseEvent mouse_event; 99 protocol::MouseEvent mouse_event;
99 mouse_event.set_x(pp_mouse_event.GetPosition().x()); 100 mouse_event.set_x(pp_mouse_event.GetPosition().x());
100 mouse_event.set_y(pp_mouse_event.GetPosition().y()); 101 mouse_event.set_y(pp_mouse_event.GetPosition().y());
102 if (mouse_locked) {
103 pp::Point delta = pp_mouse_event.GetMovement();
104 mouse_event.set_delta_x(delta.x());
105 mouse_event.set_delta_y(delta.y());
106 }
101 input_stub_->InjectMouseEvent(mouse_event); 107 input_stub_->InjectMouseEvent(mouse_event);
102 return true; 108 return true;
103 } 109 }
104 110
105 case PP_INPUTEVENT_TYPE_WHEEL: { 111 case PP_INPUTEVENT_TYPE_WHEEL: {
106 pp::WheelInputEvent pp_wheel_event(event); 112 pp::WheelInputEvent pp_wheel_event(event);
107 113
108 // Don't handle scroll-by-page events, for now. 114 // Don't handle scroll-by-page events, for now..\admin2
Wez 2013/09/05 20:24:45 Ctrl+V fail ;)
alexeypa (please no reviews) 2013/09/06 20:00:17 At least it wasn't the password. :-)
109 if (pp_wheel_event.GetScrollByPage()) 115 if (pp_wheel_event.GetScrollByPage())
110 return false; 116 return false;
111 117
112 // Add this event to our accumulated sub-pixel deltas and clicks. 118 // Add this event to our accumulated sub-pixel deltas and clicks.
113 pp::FloatPoint delta = pp_wheel_event.GetDelta(); 119 pp::FloatPoint delta = pp_wheel_event.GetDelta();
114 wheel_delta_x_ += delta.x(); 120 wheel_delta_x_ += delta.x();
115 wheel_delta_y_ += delta.y(); 121 wheel_delta_y_ += delta.y();
116 pp::FloatPoint ticks = pp_wheel_event.GetTicks(); 122 pp::FloatPoint ticks = pp_wheel_event.GetTicks();
117 wheel_ticks_x_ += ticks.x(); 123 wheel_ticks_x_ += ticks.x();
118 wheel_ticks_y_ += ticks.y(); 124 wheel_ticks_y_ += ticks.y();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 default: { 159 default: {
154 LOG(INFO) << "Unhandled input event: " << event.GetType(); 160 LOG(INFO) << "Unhandled input event: " << event.GetType();
155 break; 161 break;
156 } 162 }
157 } 163 }
158 164
159 return false; 165 return false;
160 } 166 }
161 167
162 } // namespace remoting 168 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698