Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / ui / events / event_utils.cc
1 // Copyright (c) 2012 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/events/event_utils.h"
6
7 #include <vector>
8
9 #include "ui/events/event.h"
10 #include "ui/gfx/display.h"
11 #include "ui/gfx/screen.h"
12
13 namespace ui {
14
15 namespace {
16 int g_custom_event_types = ET_LAST;
17 }  // namespace
18
19 int RegisterCustomEventType() {
20   return ++g_custom_event_types;
21 }
22
23 base::TimeDelta EventTimeForNow() {
24   return base::TimeDelta::FromInternalValue(
25       base::TimeTicks::Now().ToInternalValue());
26 }
27
28 bool ShouldDefaultToNaturalScroll() {
29   return GetInternalDisplayTouchSupport() ==
30       gfx::Display::TOUCH_SUPPORT_AVAILABLE;
31 }
32
33 gfx::Display::TouchSupport GetInternalDisplayTouchSupport() {
34   gfx::Screen* screen = gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE);
35   // No screen in some unit tests.
36   if (!screen)
37     return gfx::Display::TOUCH_SUPPORT_UNKNOWN;
38   const std::vector<gfx::Display>& displays = screen->GetAllDisplays();
39   for (std::vector<gfx::Display>::const_iterator it = displays.begin();
40        it != displays.end(); ++it) {
41     if (it->IsInternal())
42       return it->touch_support();
43   }
44   return gfx::Display::TOUCH_SUPPORT_UNAVAILABLE;
45 }
46
47 }  // namespace ui