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

Side by Side Diff: remoting/host/input_injector_win.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/host/input_injector.h" 5 #include "remoting/host/input_injector.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 input.ki.dwFlags |= KEYEVENTF_EXTENDEDKEY; 212 input.ki.dwFlags |= KEYEVENTF_EXTENDEDKEY;
213 213
214 if (SendInput(1, &input, sizeof(INPUT)) == 0) 214 if (SendInput(1, &input, sizeof(INPUT)) == 0)
215 LOG_GETLASTERROR(ERROR) << "Failed to inject a key event"; 215 LOG_GETLASTERROR(ERROR) << "Failed to inject a key event";
216 } 216 }
217 217
218 void InputInjectorWin::Core::HandleMouse(const MouseEvent& event) { 218 void InputInjectorWin::Core::HandleMouse(const MouseEvent& event) {
219 // Reset the system idle suspend timeout. 219 // Reset the system idle suspend timeout.
220 SetThreadExecutionState(ES_SYSTEM_REQUIRED); 220 SetThreadExecutionState(ES_SYSTEM_REQUIRED);
221 221
222 // TODO(garykac) Collapse mouse (x,y) and button events into a single 222 // TODO(garykac) Collapse mouse movement and button events into a single
223 // input event when possible. 223 // input event when possible.
224 if (event.has_x() && event.has_y()) { 224 if (event.has_delta_x() && event.has_delta_y()) {
225 int x = event.x(); 225 INPUT input;
226 int y = event.y(); 226 input.type = INPUT_MOUSE;
227 227 input.mi.time = 0;
228 input.mi.dx = event.delta_x();
229 input.mi.dy = event.delta_y();
230 input.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_VIRTUALDESK;
231 if (SendInput(1, &input, sizeof(INPUT)) == 0)
Wez 2013/09/05 20:24:45 How does this interact with mouse acceleration?
alexeypa (please no reviews) 2013/09/06 20:00:17 MSDN: Relative mouse motion is subject to the eff
232 LOG_GETLASTERROR(ERROR) << "Failed to inject a mouse move event";
233 } else if (event.has_x() && event.has_y()) {
228 INPUT input; 234 INPUT input;
229 input.type = INPUT_MOUSE; 235 input.type = INPUT_MOUSE;
230 input.mi.time = 0; 236 input.mi.time = 0;
231 SkISize screen_size(SkISize::Make(GetSystemMetrics(SM_CXVIRTUALSCREEN), 237 SkISize screen_size(SkISize::Make(GetSystemMetrics(SM_CXVIRTUALSCREEN),
232 GetSystemMetrics(SM_CYVIRTUALSCREEN))); 238 GetSystemMetrics(SM_CYVIRTUALSCREEN)));
233 if ((screen_size.width() > 1) && (screen_size.height() > 1)) { 239 if ((screen_size.width() > 1) && (screen_size.height() > 1)) {
234 x = std::max(0, std::min(screen_size.width(), x)); 240 int x = std::max(0, std::min(screen_size.width(), event.x()));
235 y = std::max(0, std::min(screen_size.height(), y)); 241 int y = std::max(0, std::min(screen_size.height(), event.y()));
236 input.mi.dx = static_cast<int>((x * 65535) / (screen_size.width() - 1)); 242 input.mi.dx = static_cast<int>((x * 65535) / (screen_size.width() - 1));
237 input.mi.dy = static_cast<int>((y * 65535) / (screen_size.height() - 1)); 243 input.mi.dy = static_cast<int>((y * 65535) / (screen_size.height() - 1));
238 input.mi.dwFlags = 244 input.mi.dwFlags =
239 MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_VIRTUALDESK; 245 MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_VIRTUALDESK;
240 if (SendInput(1, &input, sizeof(INPUT)) == 0) 246 if (SendInput(1, &input, sizeof(INPUT)) == 0)
241 LOG_GETLASTERROR(ERROR) << "Failed to inject a mouse move event"; 247 LOG_GETLASTERROR(ERROR) << "Failed to inject a mouse move event";
242 } 248 }
243 } 249 }
244 250
245 int wheel_delta_x = 0; 251 int wheel_delta_x = 0;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 } // namespace 316 } // namespace
311 317
312 scoped_ptr<InputInjector> InputInjector::Create( 318 scoped_ptr<InputInjector> InputInjector::Create(
313 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 319 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
314 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { 320 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) {
315 return scoped_ptr<InputInjector>( 321 return scoped_ptr<InputInjector>(
316 new InputInjectorWin(main_task_runner, ui_task_runner)); 322 new InputInjectorWin(main_task_runner, ui_task_runner));
317 } 323 }
318 324
319 } // namespace remoting 325 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698