summaryrefslogtreecommitdiffstats
path: root/ui/events
diff options
context:
space:
mode:
Diffstat (limited to 'ui/events')
-rw-r--r--ui/events/BUILD.gn2
-rw-r--r--ui/events/event.h5
-rw-r--r--ui/events/events.gyp2
-rw-r--r--ui/events/gestures/gesture_recognizer_impl.cc24
-rw-r--r--ui/events/gestures/unified_gesture_detector_enabled.cc37
-rw-r--r--ui/events/gestures/unified_gesture_detector_enabled.h17
6 files changed, 64 insertions, 23 deletions
diff --git a/ui/events/BUILD.gn b/ui/events/BUILD.gn
index e2fe42b..652f9a4 100644
--- a/ui/events/BUILD.gn
+++ b/ui/events/BUILD.gn
@@ -109,6 +109,8 @@ component("events") {
"gestures/gesture_sequence.cc",
"gestures/gesture_sequence.h",
"gestures/gesture_types.h",
+ "gestures/unified_gesture_detector_enabled.cc",
+ "gestures/unified_gesture_detector_enabled.h",
"gestures/velocity_calculator.cc",
"gestures/velocity_calculator.h",
"platform/x11/x11_event_source.cc",
diff --git a/ui/events/event.h b/ui/events/event.h
index dfd867e..928a2b9 100644
--- a/ui/events/event.h
+++ b/ui/events/event.h
@@ -248,13 +248,16 @@ class EVENTS_EXPORT LocatedEvent : public Event {
// TODO(tdresser): Always return floating point location. See
// crbug.com/337824.
gfx::Point location() const { return gfx::ToFlooredPoint(location_); }
- gfx::PointF location_f() const { return location_; }
+ const gfx::PointF& location_f() const { return location_; }
void set_root_location(const gfx::PointF& root_location) {
root_location_ = root_location;
}
gfx::Point root_location() const {
return gfx::ToFlooredPoint(root_location_);
}
+ const gfx::PointF& root_location_f() const {
+ return root_location_;
+ }
// Transform the locations using |inverted_root_transform|.
// This is applied to both |location_| and |root_location_|.
diff --git a/ui/events/events.gyp b/ui/events/events.gyp
index 111e17c..890708d 100644
--- a/ui/events/events.gyp
+++ b/ui/events/events.gyp
@@ -123,6 +123,8 @@
'gestures/gesture_types.h',
'gestures/motion_event_aura.cc',
'gestures/motion_event_aura.h',
+ 'gestures/unified_gesture_detector_enabled.cc',
+ 'gestures/unified_gesture_detector_enabled.h',
'gestures/velocity_calculator.cc',
'gestures/velocity_calculator.h',
'ozone/events_ozone.cc',
diff --git a/ui/events/gestures/gesture_recognizer_impl.cc b/ui/events/gestures/gesture_recognizer_impl.cc
index bf0dd44..e145334 100644
--- a/ui/events/gestures/gesture_recognizer_impl.cc
+++ b/ui/events/gestures/gesture_recognizer_impl.cc
@@ -18,6 +18,7 @@
#include "ui/events/gestures/gesture_configuration.h"
#include "ui/events/gestures/gesture_sequence.h"
#include "ui/events/gestures/gesture_types.h"
+#include "ui/events/gestures/unified_gesture_detector_enabled.h"
namespace ui {
@@ -69,28 +70,7 @@ GestureProviderAura* CreateGestureProvider(GestureProviderAuraClient* client) {
// GestureRecognizerImpl, public:
GestureRecognizerImpl::GestureRecognizerImpl() {
- // Default to using the unified gesture detector.
- const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- const std::string unified_gd_enabled_switch =
- command_line.HasSwitch(switches::kUnifiedGestureDetector) ?
- command_line.GetSwitchValueASCII(switches::kUnifiedGestureDetector) :
- switches::kUnifiedGestureDetectorAuto;
-
- const bool kUseUnifiedGestureDetectorByDefault = true;
- if (unified_gd_enabled_switch.empty() ||
- unified_gd_enabled_switch == switches::kUnifiedGestureDetectorEnabled) {
- use_unified_gesture_detector_ = true;
- } else if (unified_gd_enabled_switch ==
- switches::kUnifiedGestureDetectorDisabled) {
- use_unified_gesture_detector_ = false;
- } else if (unified_gd_enabled_switch ==
- switches::kUnifiedGestureDetectorAuto) {
- use_unified_gesture_detector_ = kUseUnifiedGestureDetectorByDefault;
- } else {
- LOG(ERROR) << "Invalid --unified-gesture-detector option: "
- << unified_gd_enabled_switch;
- use_unified_gesture_detector_ = false;
- }
+ use_unified_gesture_detector_ = IsUnifiedGestureDetectorEnabled();
}
GestureRecognizerImpl::~GestureRecognizerImpl() {
diff --git a/ui/events/gestures/unified_gesture_detector_enabled.cc b/ui/events/gestures/unified_gesture_detector_enabled.cc
new file mode 100644
index 0000000..cf221ff
--- /dev/null
+++ b/ui/events/gestures/unified_gesture_detector_enabled.cc
@@ -0,0 +1,37 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/command_line.h"
+#include "base/logging.h"
+#include "ui/events/event_switches.h"
+#include "ui/events/gestures/unified_gesture_detector_enabled.h"
+
+namespace ui {
+
+bool IsUnifiedGestureDetectorEnabled() {
+ const bool kUseUnifiedGestureDetectorByDefault = true;
+
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ const std::string unified_gd_enabled_switch =
+ command_line.HasSwitch(switches::kUnifiedGestureDetector) ?
+ command_line.GetSwitchValueASCII(switches::kUnifiedGestureDetector) :
+ switches::kUnifiedGestureDetectorAuto;
+
+ if (unified_gd_enabled_switch.empty() ||
+ unified_gd_enabled_switch == switches::kUnifiedGestureDetectorEnabled) {
+ return true;
+ }
+
+ if (unified_gd_enabled_switch == switches::kUnifiedGestureDetectorDisabled)
+ return false;
+
+ if (unified_gd_enabled_switch == switches::kUnifiedGestureDetectorAuto)
+ return kUseUnifiedGestureDetectorByDefault;
+
+ LOG(ERROR) << "Invalid --unified-gesture-detector option: "
+ << unified_gd_enabled_switch;
+ return false;
+}
+
+} // namespace ui
diff --git a/ui/events/gestures/unified_gesture_detector_enabled.h b/ui/events/gestures/unified_gesture_detector_enabled.h
new file mode 100644
index 0000000..18fdc26
--- /dev/null
+++ b/ui/events/gestures/unified_gesture_detector_enabled.h
@@ -0,0 +1,17 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_EVENTS_GESTURES_UNIFIED_GESTURE_DETECTOR_ENABLED_H_
+#define UI_EVENTS_GESTURES_UNIFIED_GESTURE_DETECTOR_ENABLED_H_
+
+#include "ui/events/events_export.h"
+
+namespace ui {
+
+// Returns true iff the unified gesture detector is enabled for Aura.
+EVENTS_EXPORT bool IsUnifiedGestureDetectorEnabled();
+
+} // namespace ui
+
+#endif // UI_EVENTS_GESTURES_UNIFIED_GESTURE_DETECTOR_ENABLED_H_