summaryrefslogtreecommitdiffstats
path: root/ui/base
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-05 17:33:14 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-05 17:33:14 +0000
commite4cc48300cc9e8d12dd302420ea10817c3160c15 (patch)
tree475592c10f95b5c6fdcfeac36ae8b0d466efc746 /ui/base
parent144450f8ab5a9c259aac9925d031ecae0b86b4bb (diff)
downloadchromium_src-e4cc48300cc9e8d12dd302420ea10817c3160c15.zip
chromium_src-e4cc48300cc9e8d12dd302420ea10817c3160c15.tar.gz
chromium_src-e4cc48300cc9e8d12dd302420ea10817c3160c15.tar.bz2
ui: Split some bits out of event_constants into event_utils.
BUG=none Review URL: https://codereview.chromium.org/11367084 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165951 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base')
-rw-r--r--ui/base/cocoa/events_mac.mm2
-rw-r--r--ui/base/cocoa/events_mac_unittest.mm1
-rw-r--r--ui/base/events/event.cc3
-rw-r--r--ui/base/events/event_constants.h117
-rw-r--r--ui/base/events/event_target.h1
-rw-r--r--ui/base/events/event_utils.h130
-rw-r--r--ui/base/ime/input_method_delegate.h1
-rw-r--r--ui/base/ime/input_method_ibus.cc1
-rw-r--r--ui/base/ime/mock_input_method.cc1
-rw-r--r--ui/base/win/events_win.cc1
-rw-r--r--ui/base/x/events_x.cc3
-rw-r--r--ui/base/x/events_x_unittest.cc1
-rw-r--r--ui/base/x/x11_util.cc1
-rw-r--r--ui/base/x/x11_util.h2
14 files changed, 146 insertions, 119 deletions
diff --git a/ui/base/cocoa/events_mac.mm b/ui/base/cocoa/events_mac.mm
index 7d880a4..12ad074 100644
--- a/ui/base/cocoa/events_mac.mm
+++ b/ui/base/cocoa/events_mac.mm
@@ -6,8 +6,10 @@
#include "ui/base/events/event_constants.h"
+#include "base/event_types.h"
#include "base/logging.h"
#include "base/time.h"
+#include "ui/base/events/event_utils.h"
#import "ui/base/keycodes/keyboard_code_conversion_mac.h"
#include "ui/gfx/point.h"
diff --git a/ui/base/cocoa/events_mac_unittest.mm b/ui/base/cocoa/events_mac_unittest.mm
index b9bb4ff..cf641c8 100644
--- a/ui/base/cocoa/events_mac_unittest.mm
+++ b/ui/base/cocoa/events_mac_unittest.mm
@@ -6,6 +6,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/events/event_constants.h"
+#include "ui/base/events/event_utils.h"
#include "ui/base/test/cocoa_test_event_utils.h"
#import "ui/base/test/ui_cocoa_test_helper.h"
#include "ui/gfx/point.h"
diff --git a/ui/base/events/event.cc b/ui/base/events/event.cc
index 6e6e3de..6a44c33 100644
--- a/ui/base/events/event.cc
+++ b/ui/base/events/event.cc
@@ -11,10 +11,11 @@
#include <cmath>
#include <cstring>
+#include "ui/base/events/event_utils.h"
#include "ui/base/keycodes/keyboard_code_conversion.h"
#include "ui/gfx/interpolated_transform.h"
-#include "ui/gfx/point_conversions.h"
#include "ui/gfx/point3_f.h"
+#include "ui/gfx/point_conversions.h"
#include "ui/gfx/transform.h"
#if defined(USE_X11)
diff --git a/ui/base/events/event_constants.h b/ui/base/events/event_constants.h
index 8ee434f..504fd89 100644
--- a/ui/base/events/event_constants.h
+++ b/ui/base/events/event_constants.h
@@ -5,22 +5,6 @@
#ifndef UI_BASE_EVENTS_EVENT_CONSTANTS_H_
#define UI_BASE_EVENTS_EVENT_CONSTANTS_H_
-#include "base/event_types.h"
-#include "ui/base/keycodes/keyboard_codes.h"
-#include "ui/gfx/native_widget_types.h"
-
-#if defined(OS_WIN)
-#include <windows.h>
-#endif
-
-namespace gfx {
-class Point;
-}
-
-namespace base {
-class TimeDelta;
-}
-
namespace ui {
// Event types. (prefixed because of a conflict with windows headers)
@@ -116,107 +100,6 @@ enum EventPhase {
EP_POSTDISPATCH
};
-// Updates the list of devices for cached properties.
-UI_EXPORT void UpdateDeviceList();
-
-// Get the EventType from a native event.
-UI_EXPORT EventType EventTypeFromNative(const base::NativeEvent& native_event);
-
-// Get the EventFlags from a native event.
-UI_EXPORT int EventFlagsFromNative(const base::NativeEvent& native_event);
-
-UI_EXPORT base::TimeDelta EventTimeFromNative(
- const base::NativeEvent& native_event);
-
-// Get the location from a native event. The coordinate system of the resultant
-// |Point| has the origin at top-left of the "root window". The nature of
-// this "root window" and how it maps to platform-specific drawing surfaces is
-// defined in ui/aura/root_window.* and ui/aura/root_window_host*.
-UI_EXPORT gfx::Point EventLocationFromNative(
- const base::NativeEvent& native_event);
-
-// Gets the location in native system coordinate space.
-UI_EXPORT gfx::Point EventSystemLocationFromNative(
- const base::NativeEvent& native_event);
-
-#if defined(USE_X11)
-// Returns the 'real' button for an event. The button reported in slave events
-// does not take into account any remapping (e.g. using xmodmap), while the
-// button reported in master events do. This is a utility function to always
-// return the mapped button.
-UI_EXPORT int EventButtonFromNative(const base::NativeEvent& native_event);
-#endif
-
-// Returns the KeyboardCode from a native event.
-UI_EXPORT KeyboardCode KeyboardCodeFromNative(
- const base::NativeEvent& native_event);
-
-// Returns true if the message is a mouse event.
-UI_EXPORT bool IsMouseEvent(const base::NativeEvent& native_event);
-
-// Returns the flags of the button that changed during a press/release.
-UI_EXPORT int GetChangedMouseButtonFlagsFromNative(
- const base::NativeEvent& native_event);
-
-// Gets the mouse wheel offset from a native event.
-UI_EXPORT int GetMouseWheelOffset(const base::NativeEvent& native_event);
-
-// Gets the touch id from a native event.
-UI_EXPORT int GetTouchId(const base::NativeEvent& native_event);
-
-// Gets the radius along the X/Y axis from a native event. Default is 1.0.
-UI_EXPORT float GetTouchRadiusX(const base::NativeEvent& native_event);
-UI_EXPORT float GetTouchRadiusY(const base::NativeEvent& native_event);
-
-// Gets the angle of the major axis away from the X axis. Default is 0.0.
-UI_EXPORT float GetTouchAngle(const base::NativeEvent& native_event);
-
-// Gets the force from a native_event. Normalized to be [0, 1]. Default is 0.0.
-UI_EXPORT float GetTouchForce(const base::NativeEvent& native_event);
-
-// Gets the fling velocity from a native event. is_cancel is set to true if
-// this was a tap down, intended to stop an ongoing fling.
-UI_EXPORT bool GetFlingData(const base::NativeEvent& native_event,
- float* vx,
- float* vy,
- bool* is_cancel);
-
-// Returns whether this is a scroll event and optionally gets the amount to be
-// scrolled. |x_offset| and |y_offset| can be NULL.
-UI_EXPORT bool GetScrollOffsets(const base::NativeEvent& native_event,
- float* x_offset,
- float* y_offset);
-
-UI_EXPORT bool GetGestureTimes(const base::NativeEvent& native_event,
- double* start_time,
- double* end_time);
-
-// Enable/disable natural scrolling for touchpads.
-UI_EXPORT void SetNaturalScroll(bool enabled);
-
-// In natural scrolling enabled for touchpads?
-UI_EXPORT bool IsNaturalScrollEnabled();
-
-// Was this event generated by a touchpad device?
-// The caller is responsible for ensuring that this is a mouse/touchpad event
-// before calling this function.
-UI_EXPORT bool IsTouchpadEvent(const base::NativeEvent& event);
-
-// Returns true if event is noop.
-UI_EXPORT bool IsNoopEvent(const base::NativeEvent& event);
-
-// Creates and returns no-op event.
-UI_EXPORT base::NativeEvent CreateNoopEvent();
-
-#if defined(OS_WIN)
-UI_EXPORT int GetModifiersFromACCEL(const ACCEL& accel);
-UI_EXPORT int GetModifiersFromKeyState();
-
-// Returns true if |message| identifies a mouse event that was generated as the
-// result of a touch event.
-UI_EXPORT bool IsMouseEventFromTouch(UINT message);
-#endif
-
} // namespace ui
#endif // UI_BASE_EVENTS_EVENT_CONSTANTS_H_
diff --git a/ui/base/events/event_target.h b/ui/base/events/event_target.h
index eebfc67..0b23997 100644
--- a/ui/base/events/event_target.h
+++ b/ui/base/events/event_target.h
@@ -5,6 +5,7 @@
#ifndef UI_BASE_EVENTS_EVENT_TARGET_H_
#define UI_BASE_EVENTS_EVENT_TARGET_H_
+#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "ui/base/events/event_handler.h"
#include "ui/base/ui_export.h"
diff --git a/ui/base/events/event_utils.h b/ui/base/events/event_utils.h
new file mode 100644
index 0000000..1bef563
--- /dev/null
+++ b/ui/base/events/event_utils.h
@@ -0,0 +1,130 @@
+// Copyright (c) 2012 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_BASE_EVENTS_EVENT_UTILS_H_
+#define UI_BASE_EVENTS_EVENT_UTILS_H_
+
+#include "base/event_types.h"
+#include "ui/base/events/event_constants.h"
+#include "ui/base/keycodes/keyboard_codes.h"
+#include "ui/gfx/native_widget_types.h"
+
+#if defined(OS_WIN)
+#include <windows.h>
+#endif
+
+namespace gfx {
+class Point;
+}
+
+namespace base {
+class TimeDelta;
+}
+
+namespace ui {
+
+// Updates the list of devices for cached properties.
+UI_EXPORT void UpdateDeviceList();
+
+// Get the EventType from a native event.
+UI_EXPORT EventType EventTypeFromNative(const base::NativeEvent& native_event);
+
+// Get the EventFlags from a native event.
+UI_EXPORT int EventFlagsFromNative(const base::NativeEvent& native_event);
+
+UI_EXPORT base::TimeDelta EventTimeFromNative(
+ const base::NativeEvent& native_event);
+
+// Get the location from a native event. The coordinate system of the resultant
+// |Point| has the origin at top-left of the "root window". The nature of
+// this "root window" and how it maps to platform-specific drawing surfaces is
+// defined in ui/aura/root_window.* and ui/aura/root_window_host*.
+UI_EXPORT gfx::Point EventLocationFromNative(
+ const base::NativeEvent& native_event);
+
+// Gets the location in native system coordinate space.
+UI_EXPORT gfx::Point EventSystemLocationFromNative(
+ const base::NativeEvent& native_event);
+
+#if defined(USE_X11)
+// Returns the 'real' button for an event. The button reported in slave events
+// does not take into account any remapping (e.g. using xmodmap), while the
+// button reported in master events do. This is a utility function to always
+// return the mapped button.
+UI_EXPORT int EventButtonFromNative(const base::NativeEvent& native_event);
+#endif
+
+// Returns the KeyboardCode from a native event.
+UI_EXPORT KeyboardCode KeyboardCodeFromNative(
+ const base::NativeEvent& native_event);
+
+// Returns true if the message is a mouse event.
+UI_EXPORT bool IsMouseEvent(const base::NativeEvent& native_event);
+
+// Returns the flags of the button that changed during a press/release.
+UI_EXPORT int GetChangedMouseButtonFlagsFromNative(
+ const base::NativeEvent& native_event);
+
+// Gets the mouse wheel offset from a native event.
+UI_EXPORT int GetMouseWheelOffset(const base::NativeEvent& native_event);
+
+// Gets the touch id from a native event.
+UI_EXPORT int GetTouchId(const base::NativeEvent& native_event);
+
+// Gets the radius along the X/Y axis from a native event. Default is 1.0.
+UI_EXPORT float GetTouchRadiusX(const base::NativeEvent& native_event);
+UI_EXPORT float GetTouchRadiusY(const base::NativeEvent& native_event);
+
+// Gets the angle of the major axis away from the X axis. Default is 0.0.
+UI_EXPORT float GetTouchAngle(const base::NativeEvent& native_event);
+
+// Gets the force from a native_event. Normalized to be [0, 1]. Default is 0.0.
+UI_EXPORT float GetTouchForce(const base::NativeEvent& native_event);
+
+// Gets the fling velocity from a native event. is_cancel is set to true if
+// this was a tap down, intended to stop an ongoing fling.
+UI_EXPORT bool GetFlingData(const base::NativeEvent& native_event,
+ float* vx,
+ float* vy,
+ bool* is_cancel);
+
+// Returns whether this is a scroll event and optionally gets the amount to be
+// scrolled. |x_offset| and |y_offset| can be NULL.
+UI_EXPORT bool GetScrollOffsets(const base::NativeEvent& native_event,
+ float* x_offset,
+ float* y_offset);
+
+UI_EXPORT bool GetGestureTimes(const base::NativeEvent& native_event,
+ double* start_time,
+ double* end_time);
+
+// Enable/disable natural scrolling for touchpads.
+UI_EXPORT void SetNaturalScroll(bool enabled);
+
+// In natural scrolling enabled for touchpads?
+UI_EXPORT bool IsNaturalScrollEnabled();
+
+// Was this event generated by a touchpad device?
+// The caller is responsible for ensuring that this is a mouse/touchpad event
+// before calling this function.
+UI_EXPORT bool IsTouchpadEvent(const base::NativeEvent& event);
+
+// Returns true if event is noop.
+UI_EXPORT bool IsNoopEvent(const base::NativeEvent& event);
+
+// Creates and returns no-op event.
+UI_EXPORT base::NativeEvent CreateNoopEvent();
+
+#if defined(OS_WIN)
+UI_EXPORT int GetModifiersFromACCEL(const ACCEL& accel);
+UI_EXPORT int GetModifiersFromKeyState();
+
+// Returns true if |message| identifies a mouse event that was generated as the
+// result of a touch event.
+UI_EXPORT bool IsMouseEventFromTouch(UINT message);
+#endif
+
+} // namespace ui
+
+#endif // UI_BASE_EVENTS_EVENT_UTILS_H_
diff --git a/ui/base/ime/input_method_delegate.h b/ui/base/ime/input_method_delegate.h
index 3202d90..090ea45 100644
--- a/ui/base/ime/input_method_delegate.h
+++ b/ui/base/ime/input_method_delegate.h
@@ -7,6 +7,7 @@
#include "base/event_types.h"
#include "ui/base/events/event_constants.h"
+#include "ui/base/keycodes/keyboard_codes.h"
#include "ui/base/ui_export.h"
namespace ui {
diff --git a/ui/base/ime/input_method_ibus.cc b/ui/base/ime/input_method_ibus.cc
index 523782f..c7e8325 100644
--- a/ui/base/ime/input_method_ibus.cc
+++ b/ui/base/ime/input_method_ibus.cc
@@ -27,6 +27,7 @@
#include "chromeos/dbus/ibus/ibus_input_context_client.h"
#include "chromeos/dbus/ibus/ibus_text.h"
#include "ui/base/events/event_constants.h"
+#include "ui/base/events/event_utils.h"
#include "ui/base/ime/ibus_client.h"
#include "ui/base/ime/text_input_client.h"
#include "ui/base/keycodes/keyboard_code_conversion.h"
diff --git a/ui/base/ime/mock_input_method.cc b/ui/base/ime/mock_input_method.cc
index 0c1ab4d..21c3dd4 100644
--- a/ui/base/ime/mock_input_method.cc
+++ b/ui/base/ime/mock_input_method.cc
@@ -8,6 +8,7 @@
#include "base/string16.h"
#include "ui/base/events/event.h"
#include "ui/base/events/event_constants.h"
+#include "ui/base/events/event_utils.h"
#include "ui/base/glib/glib_integers.h"
#include "ui/base/ime/input_method_delegate.h"
#include "ui/base/ime/text_input_client.h"
diff --git a/ui/base/win/events_win.cc b/ui/base/win/events_win.cc
index 80b4eaf..96c09f9 100644
--- a/ui/base/win/events_win.cc
+++ b/ui/base/win/events_win.cc
@@ -9,6 +9,7 @@
#include "base/logging.h"
#include "base/time.h"
#include "base/win/win_util.h"
+#include "ui/base/events/event_utils.h"
#include "ui/base/keycodes/keyboard_code_conversion_win.h"
#include "ui/gfx/point.h"
diff --git a/ui/base/x/events_x.cc b/ui/base/x/events_x.cc
index afa9123..e82a06a4 100644
--- a/ui/base/x/events_x.cc
+++ b/ui/base/x/events_x.cc
@@ -13,8 +13,9 @@
#include "base/logging.h"
#include "base/memory/singleton.h"
#include "base/message_pump_aurax11.h"
-#include "base/string_split.h"
#include "base/string_number_conversions.h"
+#include "base/string_split.h"
+#include "ui/base/events/event_utils.h"
#include "ui/base/keycodes/keyboard_code_conversion_x.h"
#include "ui/base/touch/touch_factory.h"
#include "ui/base/ui_base_switches.h"
diff --git a/ui/base/x/events_x_unittest.cc b/ui/base/x/events_x_unittest.cc
index d67f4b7..52a7eb2 100644
--- a/ui/base/x/events_x_unittest.cc
+++ b/ui/base/x/events_x_unittest.cc
@@ -12,6 +12,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/events/event_constants.h"
+#include "ui/base/events/event_utils.h"
#include "ui/gfx/point.h"
namespace ui {
diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc
index 5af4e5e..0c4dc04 100644
--- a/ui/base/x/x11_util.cc
+++ b/ui/base/x/x11_util.cc
@@ -33,6 +33,7 @@
#include "base/stringprintf.h"
#include "base/sys_byteorder.h"
#include "base/threading/thread.h"
+#include "ui/base/events/event_utils.h"
#include "ui/base/keycodes/keyboard_code_conversion_x.h"
#include "ui/base/touch/touch_factory.h"
#include "ui/base/x/valuators.h"
diff --git a/ui/base/x/x11_util.h b/ui/base/x/x11_util.h
index 7d3182e..7ed0129 100644
--- a/ui/base/x/x11_util.h
+++ b/ui/base/x/x11_util.h
@@ -15,7 +15,9 @@
#include <vector>
#include "base/basictypes.h"
+#include "base/event_types.h"
#include "ui/base/events/event_constants.h"
+#include "ui/base/keycodes/keyboard_codes.h"
#include "ui/base/ui_export.h"
#include "ui/gfx/point.h"