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

Side by Side Diff: ui/base/test/ui_controls_internal_win.cc

Issue 2904113002: Replacing WM_TOUCH with WM_POINTER for touch events on Wins 8+ (Closed)
Patch Set: wm touch Created 3 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 unified diff | Download patch
OLDNEW
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/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 input.mi.dwFlags = up_flags; 323 input.mi.dwFlags = up_flags;
324 if ((state & UP) && !::SendInput(1, &input, sizeof(INPUT))) 324 if ((state & UP) && !::SendInput(1, &input, sizeof(INPUT)))
325 return false; 325 return false;
326 326
327 if (dispatcher.get()) 327 if (dispatcher.get())
328 dispatcher->AddRef(); 328 dispatcher->AddRef();
329 329
330 return true; 330 return true;
331 } 331 }
332 332
333 bool SendTouchEventsImpl(int action,
334 int num,
335 int x,
336 int y,
337 const base::Closure& task) {
338 const int kTouchesLengthCap = 16;
339 DCHECK_LE(num, kTouchesLengthCap);
340
341 using InitializeTouchInjectionFn = BOOL(WINAPI*)(UINT32, DWORD);
342 static InitializeTouchInjectionFn initialize_touch_injection =
343 reinterpret_cast<InitializeTouchInjectionFn>(GetProcAddress(
344 GetModuleHandleA("user32.dll"), "InitializeTouchInjection"));
345 if (!initialize_touch_injection ||
346 !initialize_touch_injection(num, TOUCH_FEEDBACK_INDIRECT)) {
347 task.Run();
348 return false;
349 }
350
351 using InjectTouchInputFn = BOOL(WINAPI*)(UINT32, POINTER_TOUCH_INFO*);
352 static InjectTouchInputFn inject_touch_input =
353 reinterpret_cast<InjectTouchInputFn>(
354 GetProcAddress(GetModuleHandleA("user32.dll"), "InjectTouchInput"));
355 if (!inject_touch_input) {
356 task.Run();
357 return false;
358 }
359 POINTER_TOUCH_INFO pointer_touch_info[kTouchesLengthCap];
360 for (int i = 0; i < num; i++) {
361 POINTER_TOUCH_INFO& contact = pointer_touch_info[i];
362 memset(&contact, 0, sizeof(POINTER_TOUCH_INFO));
363 contact.pointerInfo.pointerType = PT_TOUCH;
364 contact.pointerInfo.pointerId = i;
365 contact.pointerInfo.ptPixelLocation.y = y;
366 contact.pointerInfo.ptPixelLocation.x = x + 10 * i;
367
368 contact.touchFlags = TOUCH_FLAG_NONE;
369 contact.touchMask =
370 TOUCH_MASK_CONTACTAREA | TOUCH_MASK_ORIENTATION | TOUCH_MASK_PRESSURE;
371 contact.orientation = 90;
372 contact.pressure = 32000;
373
374 // defining contact area
375 contact.rcContact.top = contact.pointerInfo.ptPixelLocation.y - 2;
376 contact.rcContact.bottom = contact.pointerInfo.ptPixelLocation.y + 2;
377 contact.rcContact.left = contact.pointerInfo.ptPixelLocation.x - 2;
378 contact.rcContact.right = contact.pointerInfo.ptPixelLocation.x + 2;
379
380 contact.pointerInfo.pointerFlags =
381 POINTER_FLAG_DOWN | POINTER_FLAG_INRANGE | POINTER_FLAG_INCONTACT;
382 }
383 // Injecting the touch down on screen
384 if (!inject_touch_input(num, pointer_touch_info)) {
385 task.Run();
386 return false;
387 }
388
389 // Injecting the touch move on screen
390 if (action & MOVE) {
391 for (int i = 0; i < num; i++) {
392 POINTER_TOUCH_INFO& contact = pointer_touch_info[i];
393 contact.pointerInfo.ptPixelLocation.y = y + 10;
394 contact.pointerInfo.ptPixelLocation.x = x + 10 * i + 30;
395 contact.pointerInfo.pointerFlags =
396 POINTER_FLAG_UPDATE | POINTER_FLAG_INRANGE | POINTER_FLAG_INCONTACT;
397 }
398 if (!inject_touch_input(num, pointer_touch_info)) {
399 task.Run();
400 return false;
401 }
402 }
403
404 // Injecting the touch up on screen
405 if (action & RELEASE) {
406 for (int i = 0; i < num; i++) {
407 POINTER_TOUCH_INFO& contact = pointer_touch_info[i];
408 contact.pointerInfo.ptPixelLocation.y = y + 10;
409 contact.pointerInfo.ptPixelLocation.x = x + 10 * i + 30;
410 contact.pointerInfo.pointerFlags = POINTER_FLAG_UP | POINTER_FLAG_INRANGE;
411 }
412 if (!inject_touch_input(num, pointer_touch_info)) {
413 task.Run();
414 return false;
415 }
416 }
417 task.Run();
418
419 return true;
420 }
421
333 } // namespace internal 422 } // namespace internal
334 } // namespace ui_controls 423 } // namespace ui_controls
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698