| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ui/base/test/ui_controls_internal_win.h" | 5 #include "ui/base/test/ui_controls_internal_win.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 | 248 |
| 249 if (::SendInput(i, input, sizeof(INPUT)) != i) | 249 if (::SendInput(i, input, sizeof(INPUT)) != i) |
| 250 return false; | 250 return false; |
| 251 | 251 |
| 252 if (dispatcher.get()) | 252 if (dispatcher.get()) |
| 253 dispatcher->AddRef(); | 253 dispatcher->AddRef(); |
| 254 | 254 |
| 255 return true; | 255 return true; |
| 256 } | 256 } |
| 257 | 257 |
| 258 bool SendMouseMoveImpl(long x, long y, const base::Closure& task) { | 258 bool SendMouseMoveImpl(long screen_x, |
| 259 long screen_y, |
| 260 const base::Closure& task) { |
| 259 // First check if the mouse is already there. | 261 // First check if the mouse is already there. |
| 260 POINT current_pos; | 262 POINT current_pos; |
| 261 ::GetCursorPos(¤t_pos); | 263 ::GetCursorPos(¤t_pos); |
| 262 if (x == current_pos.x && y == current_pos.y) { | 264 if (screen_x == current_pos.x && screen_y == current_pos.y) { |
| 263 if (!task.is_null()) | 265 if (!task.is_null()) |
| 264 base::MessageLoop::current()->PostTask(FROM_HERE, task); | 266 base::MessageLoop::current()->PostTask(FROM_HERE, task); |
| 265 return true; | 267 return true; |
| 266 } | 268 } |
| 267 | 269 |
| 268 INPUT input = { 0 }; | 270 INPUT input = { 0 }; |
| 269 | 271 |
| 270 int screen_width = ::GetSystemMetrics(SM_CXSCREEN) - 1; | 272 int screen_width = ::GetSystemMetrics(SM_CXSCREEN) - 1; |
| 271 int screen_height = ::GetSystemMetrics(SM_CYSCREEN) - 1; | 273 int screen_height = ::GetSystemMetrics(SM_CYSCREEN) - 1; |
| 272 LONG pixel_x = static_cast<LONG>(x * (65535.0f / screen_width)); | 274 LONG pixel_x = static_cast<LONG>(screen_x * (65535.0f / screen_width)); |
| 273 LONG pixel_y = static_cast<LONG>(y * (65535.0f / screen_height)); | 275 LONG pixel_y = static_cast<LONG>(screen_y * (65535.0f / screen_height)); |
| 274 | 276 |
| 275 input.type = INPUT_MOUSE; | 277 input.type = INPUT_MOUSE; |
| 276 input.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE; | 278 input.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE; |
| 277 input.mi.dx = pixel_x; | 279 input.mi.dx = pixel_x; |
| 278 input.mi.dy = pixel_y; | 280 input.mi.dy = pixel_y; |
| 279 | 281 |
| 280 scoped_refptr<InputDispatcher> dispatcher( | 282 scoped_refptr<InputDispatcher> dispatcher( |
| 281 !task.is_null() ? new InputDispatcher(task, WM_MOUSEMOVE) : NULL); | 283 !task.is_null() ? new InputDispatcher(task, WM_MOUSEMOVE) : NULL); |
| 282 | 284 |
| 283 if (!::SendInput(1, &input, sizeof(INPUT))) | 285 if (!::SendInput(1, &input, sizeof(INPUT))) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 return false; | 335 return false; |
| 334 | 336 |
| 335 if (dispatcher.get()) | 337 if (dispatcher.get()) |
| 336 dispatcher->AddRef(); | 338 dispatcher->AddRef(); |
| 337 | 339 |
| 338 return true; | 340 return true; |
| 339 } | 341 } |
| 340 | 342 |
| 341 } // namespace internal | 343 } // namespace internal |
| 342 } // namespace ui_controls | 344 } // namespace ui_controls |
| OLD | NEW |