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

Side by Side Diff: ui/base/touch/touch_device_aurax11.cc

Issue 815983003: Unified touch_device_aurax11 and touch_device_ozone. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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/BUILD.gn ('k') | ui/base/touch/touch_device_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/base/touch/touch_device.h"
6
7 #include "base/logging.h"
8 #include "ui/events/devices/device_data_manager.h"
9
10 namespace ui {
11
12 bool IsTouchDevicePresent() {
13 return ui::DeviceDataManager::GetInstance()->touchscreen_devices().size() > 0;
14 }
15
16 int MaxTouchPoints() {
17 int max_touch = -1;
18 const std::vector<ui::TouchscreenDevice>& touchscreen_devices =
19 ui::DeviceDataManager::GetInstance()->touchscreen_devices();
20 for (const ui::TouchscreenDevice& device : touchscreen_devices) {
21 if (device.touch_points > max_touch)
22 max_touch = device.touch_points;
23 }
24 return max_touch;
25 }
26
27 // TODO(mustaq@chromium.org): Use mouse detection logic. crbug.com/440503
28 int GetAvailablePointerTypes() {
29 // Assume a mouse is there
30 int available_pointer_types = POINTER_TYPE_FINE;
31 if (IsTouchDevicePresent())
32 available_pointer_types |= POINTER_TYPE_COARSE;
33
34 DCHECK(available_pointer_types);
35 return available_pointer_types;
36 }
37
38 PointerType GetPrimaryPointerType() {
39 int available_pointer_types = GetAvailablePointerTypes();
40 if (available_pointer_types & POINTER_TYPE_FINE)
41 return POINTER_TYPE_FINE;
42 if (available_pointer_types & POINTER_TYPE_COARSE)
43 return POINTER_TYPE_COARSE;
44 DCHECK_EQ(available_pointer_types, POINTER_TYPE_NONE);
45 return POINTER_TYPE_NONE;
46 }
47
48 // TODO(mustaq@chromium.org): Use mouse detection logic. crbug.com/440503
49 int GetAvailableHoverTypes() {
50 // Assume a mouse is there
51 int available_hover_types = HOVER_TYPE_HOVER;
52 if (IsTouchDevicePresent())
53 available_hover_types |= HOVER_TYPE_ON_DEMAND;
54
55 DCHECK(available_hover_types);
56 return available_hover_types;
57 }
58
59 HoverType GetPrimaryHoverType() {
60 int available_hover_types = GetAvailableHoverTypes();
61 if (available_hover_types & HOVER_TYPE_HOVER)
62 return HOVER_TYPE_HOVER;
63 if (available_hover_types & HOVER_TYPE_ON_DEMAND)
64 return HOVER_TYPE_ON_DEMAND;
65 DCHECK_EQ(available_hover_types, HOVER_TYPE_NONE);
66 return HOVER_TYPE_NONE;
67 }
68
69 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/BUILD.gn ('k') | ui/base/touch/touch_device_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698