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

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 6 years 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
(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 #include "ui/events/devices/x11/touch_factory_x11.h"
10
11 namespace ui {
12
13 bool IsTouchDevicePresent() {
14 return ui::DeviceDataManager::GetInstance()->touchscreen_devices().size() > 0;
15 }
16
17 int MaxTouchPoints() {
18 return ui::TouchFactory::GetInstance()->GetMaxTouchPoints();
19 }
20
21 // TODO(mustaq@chromium.org): Use mouse detection logic. crbug.com/440503
22 int GetAvailablePointerTypes() {
23 // Assume a mouse is there
24 int available_pointer_types = POINTER_TYPE_FINE;
25 if (IsTouchDevicePresent())
26 available_pointer_types |= POINTER_TYPE_COARSE;
27
28 DCHECK(available_pointer_types);
29 return available_pointer_types;
30 }
31
32 PointerType GetPrimaryPointerType() {
33 int available_pointer_types = GetAvailablePointerTypes();
34 if (available_pointer_types & POINTER_TYPE_FINE)
35 return POINTER_TYPE_FINE;
36 if (available_pointer_types & POINTER_TYPE_COARSE)
37 return POINTER_TYPE_COARSE;
38 DCHECK_EQ(available_pointer_types, POINTER_TYPE_NONE);
39 return POINTER_TYPE_NONE;
40 }
41
42 // TODO(mustaq@chromium.org): Use mouse detection logic. crbug.com/440503
43 int GetAvailableHoverTypes() {
44 // Assume a mouse is there
45 int available_hover_types = HOVER_TYPE_HOVER;
46 if (IsTouchDevicePresent())
47 available_hover_types |= HOVER_TYPE_ON_DEMAND;
48
49 DCHECK(available_hover_types);
50 return available_hover_types;
51 }
52
53 HoverType GetPrimaryHoverType() {
54 int available_hover_types = GetAvailableHoverTypes();
55 if (available_hover_types & HOVER_TYPE_HOVER)
56 return HOVER_TYPE_HOVER;
57 if (available_hover_types & HOVER_TYPE_ON_DEMAND)
58 return HOVER_TYPE_ON_DEMAND;
59 DCHECK_EQ(available_hover_types, HOVER_TYPE_NONE);
60 return HOVER_TYPE_NONE;
61 }
62
63 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698