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

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 return false;
348
349 using InjectTouchInputFn = BOOL(WINAPI*)(UINT32, POINTER_TOUCH_INFO*);
350 static InjectTouchInputFn inject_touch_input =
351 reinterpret_cast<InjectTouchInputFn>(
352 GetProcAddress(GetModuleHandleA("user32.dll"), "InjectTouchInput"));
353 if (!inject_touch_input)
354 return false;
355 POINTER_TOUCH_INFO pointer_touch_info[kTouchesLengthCap];
356 for (int i = 0; i < num; i++) {
357 POINTER_TOUCH_INFO& contact = pointer_touch_info[i];
358 memset(&contact, 0, sizeof(POINTER_TOUCH_INFO));
359 contact.pointerInfo.pointerType = PT_TOUCH;
360 contact.pointerInfo.pointerId = i;
361 contact.pointerInfo.ptPixelLocation.y = y;
362 contact.pointerInfo.ptPixelLocation.x = x + 50 * i;
363
364 contact.touchFlags = TOUCH_FLAG_NONE;
365 contact.touchMask =
366 TOUCH_MASK_CONTACTAREA | TOUCH_MASK_ORIENTATION | TOUCH_MASK_PRESSURE;
367 contact.orientation = 90;
368 contact.pressure = 32000;
369
370 // defining contact area
371 contact.rcContact.top = contact.pointerInfo.ptPixelLocation.y - 2;
372 contact.rcContact.bottom = contact.pointerInfo.ptPixelLocation.y + 2;
373 contact.rcContact.left = contact.pointerInfo.ptPixelLocation.x - 2;
374 contact.rcContact.right = contact.pointerInfo.ptPixelLocation.x + 2;
375
376 contact.pointerInfo.pointerFlags =
377 POINTER_FLAG_DOWN | POINTER_FLAG_INRANGE | POINTER_FLAG_INCONTACT;
378 }
379 // Injecting the touch down on screen
380 if (!inject_touch_input(num, pointer_touch_info))
381 return false;
382
383 Sleep(20);
384 // Injecting the touch move on screen
385 if (action & MOVE) {
386 for (int i = 0; i < num; i++) {
387 POINTER_TOUCH_INFO& contact = pointer_touch_info[i];
388 contact.pointerInfo.ptPixelLocation.y = y + 10;
389 contact.pointerInfo.ptPixelLocation.x = x + 50 * i + 30;
390 contact.pointerInfo.pointerFlags =
391 POINTER_FLAG_UPDATE | POINTER_FLAG_INRANGE | POINTER_FLAG_INCONTACT;
392 }
393 if (!inject_touch_input(num, pointer_touch_info))
394 return false;
395 Sleep(20);
396 }
397
398 // Injecting the touch up on screen
399 if (action & RELEASE) {
400 for (int i = 0; i < num; i++) {
401 POINTER_TOUCH_INFO& contact = pointer_touch_info[i];
402 contact.pointerInfo.ptPixelLocation.y = y + 10;
403 contact.pointerInfo.ptPixelLocation.x = x + 50 * i + 30;
404 contact.pointerInfo.pointerFlags = POINTER_FLAG_UP | POINTER_FLAG_INRANGE;
405 }
406 if (!inject_touch_input(num, pointer_touch_info))
407 return false;
408 Sleep(20);
409 }
410 task.Run();
411
412 return true;
413 }
414
333 } // namespace internal 415 } // namespace internal
334 } // namespace ui_controls 416 } // namespace ui_controls
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698