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

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, 5 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
« no previous file with comments | « ui/base/test/ui_controls_internal_win.h ('k') | ui/base/test/ui_controls_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 input.mi.dwFlags = up_flags; 345 input.mi.dwFlags = up_flags;
346 if ((state & UP) && !::SendInput(1, &input, sizeof(INPUT))) 346 if ((state & UP) && !::SendInput(1, &input, sizeof(INPUT)))
347 return false; 347 return false;
348 348
349 if (dispatcher.get()) 349 if (dispatcher.get())
350 dispatcher->AddRef(); 350 dispatcher->AddRef();
351 351
352 return true; 352 return true;
353 } 353 }
354 354
355 bool SendTouchEventsImpl(int action, int num, int x, int y) {
356 const int kTouchesLengthCap = 16;
357 DCHECK_LE(num, kTouchesLengthCap);
358
359 using InitializeTouchInjectionFn = BOOL(WINAPI*)(UINT32, DWORD);
360 static InitializeTouchInjectionFn initialize_touch_injection =
361 reinterpret_cast<InitializeTouchInjectionFn>(GetProcAddress(
362 GetModuleHandleA("user32.dll"), "InitializeTouchInjection"));
363 if (!initialize_touch_injection ||
364 !initialize_touch_injection(num, TOUCH_FEEDBACK_INDIRECT)) {
365 return false;
366 }
367
368 using InjectTouchInputFn = BOOL(WINAPI*)(UINT32, POINTER_TOUCH_INFO*);
369 static InjectTouchInputFn inject_touch_input =
370 reinterpret_cast<InjectTouchInputFn>(
371 GetProcAddress(GetModuleHandleA("user32.dll"), "InjectTouchInput"));
372 if (!inject_touch_input)
373 return false;
374
375 POINTER_TOUCH_INFO pointer_touch_info[kTouchesLengthCap];
376 for (int i = 0; i < num; i++) {
377 POINTER_TOUCH_INFO& contact = pointer_touch_info[i];
378 memset(&contact, 0, sizeof(POINTER_TOUCH_INFO));
379 contact.pointerInfo.pointerType = PT_TOUCH;
380 contact.pointerInfo.pointerId = i;
381 contact.pointerInfo.ptPixelLocation.y = y;
382 contact.pointerInfo.ptPixelLocation.x = x + 10 * i;
383
384 contact.touchFlags = TOUCH_FLAG_NONE;
385 contact.touchMask =
386 TOUCH_MASK_CONTACTAREA | TOUCH_MASK_ORIENTATION | TOUCH_MASK_PRESSURE;
387 contact.orientation = 90;
388 contact.pressure = 32000;
389
390 // defining contact area
391 contact.rcContact.top = contact.pointerInfo.ptPixelLocation.y - 2;
392 contact.rcContact.bottom = contact.pointerInfo.ptPixelLocation.y + 2;
393 contact.rcContact.left = contact.pointerInfo.ptPixelLocation.x - 2;
394 contact.rcContact.right = contact.pointerInfo.ptPixelLocation.x + 2;
395
396 contact.pointerInfo.pointerFlags =
397 POINTER_FLAG_DOWN | POINTER_FLAG_INRANGE | POINTER_FLAG_INCONTACT;
398 }
399 // Injecting the touch down on screen
400 if (!inject_touch_input(num, pointer_touch_info))
401 return false;
402
403 // Injecting the touch move on screen
404 if (action & MOVE) {
405 for (int i = 0; i < num; i++) {
406 POINTER_TOUCH_INFO& contact = pointer_touch_info[i];
407 contact.pointerInfo.ptPixelLocation.y = y + 10;
408 contact.pointerInfo.ptPixelLocation.x = x + 10 * i + 30;
409 contact.pointerInfo.pointerFlags =
410 POINTER_FLAG_UPDATE | POINTER_FLAG_INRANGE | POINTER_FLAG_INCONTACT;
411 }
412 if (!inject_touch_input(num, pointer_touch_info))
413 return false;
414 }
415
416 // Injecting the touch up on screen
417 if (action & RELEASE) {
418 for (int i = 0; i < num; i++) {
419 POINTER_TOUCH_INFO& contact = pointer_touch_info[i];
420 contact.pointerInfo.ptPixelLocation.y = y + 10;
421 contact.pointerInfo.ptPixelLocation.x = x + 10 * i + 30;
422 contact.pointerInfo.pointerFlags = POINTER_FLAG_UP | POINTER_FLAG_INRANGE;
423 }
424 if (!inject_touch_input(num, pointer_touch_info))
425 return false;
426 }
427
428 return true;
429 }
430
355 } // namespace internal 431 } // namespace internal
356 } // namespace ui_controls 432 } // namespace ui_controls
OLDNEW
« no previous file with comments | « ui/base/test/ui_controls_internal_win.h ('k') | ui/base/test/ui_controls_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698