Index: ui/base/events.h |
diff --git a/ui/base/events.h b/ui/base/events.h |
index 03e67d05fe6242ef38e17a9e7cb47788f009486e..fe414d9023d49753fc6575afe3bf0b27decffc03 100644 |
--- a/ui/base/events.h |
+++ b/ui/base/events.h |
@@ -6,8 +6,59 @@ |
#define UI_BASE_EVENTS_H_ |
#pragma once |
+#include "ui/base/keycodes/keyboard_codes.h" |
+#include "ui/gfx/native_widget_types.h" |
+ |
+namespace gfx { |
+class Point; |
+} |
+ |
+#if defined(OS_LINUX) |
+typedef union _GdkEvent GdkEvent; |
+#endif |
+#if defined(USE_X11) |
+typedef union _XEvent XEvent; |
+#endif |
+#if defined(USE_WAYLAND) |
+namespace ui { |
+union WaylandEvent; |
+} |
+#endif |
+ |
namespace ui { |
+// A note about NativeEvent and NativeEvent2. |
+// 1. Eventually TOOLKIT_VIEWS will converge on using XEvent as we remove |
+// Gtk/Gdk from the stack. |
+// 2. TOUCH_UI needs XEvents now for certain event types. |
+// 3. TOUCH_UI also needs GdkEvents for certain event types. |
+// |
+// => NativeEvent and NativeEvent2. |
+// |
+// Once we replace usage of Gtk/Gdk types with Xlib types across the board in |
+// views, we can remove NativeEvent2 and typedef XEvent* to NativeEvent. The |
+// world will then be beautiful(ish). |
+ |
+#if defined(OS_WIN) |
Ben Goodger (Google)
2011/09/22 15:40:26
This is going to break in views when USE_AURA is d
msw
2011/09/22 19:17:48
I solved that conundrum by using two levels of typ
|
+typedef MSG NativeEvent; |
+#elif defined(OS_LINUX) |
+ |
+#if defined(USE_WAYLAND) |
+typedef ui::WaylandEvent* NativeEvent; |
+#else |
+typedef GdkEvent* NativeEvent; |
+#endif |
+ |
+#else |
+typedef void* NativeEvent; |
+#endif |
+ |
+#if defined(USE_X11) |
+typedef XEvent* NativeEvent2; |
+#else |
+typedef void* NativeEvent2; |
+#endif |
+ |
// Event types. (prefixed because of a conflict with windows headers) |
enum EventType { |
ET_UNKNOWN = 0, |
@@ -42,6 +93,7 @@ enum EventFlags { |
EF_MIDDLE_BUTTON_DOWN = 1 << 5, |
EF_RIGHT_BUTTON_DOWN = 1 << 6, |
EF_COMMAND_DOWN = 1 << 7, // Only useful on OSX |
+ EF_EXTENDED = 1 << 8, // Windows extended key (see WM_KEYDOWN doc) |
}; |
// Flags specific to mouse events |
@@ -64,7 +116,30 @@ enum TouchStatus { |
// unused touch event was handled. |
}; |
+// Get the EventType from a native event. |
+UI_EXPORT EventType EventTypeFromNative(const NativeEvent& native_event); |
+UI_EXPORT EventType EventTypeFromNative(const NativeEvent2& native_event); |
+ |
+// Get the EventFlags from a native event. |
+UI_EXPORT int EventFlagsFromNative(const NativeEvent& native_event); |
+UI_EXPORT int EventFlagsFromNative(const NativeEvent2& native_event); |
+ |
+// Get the location from a native event. |
+UI_EXPORT gfx::Point EventLocationFromNative(const NativeEvent& native_event); |
+UI_EXPORT gfx::Point EventLocationFromNative(const NativeEvent2& native_event); |
+ |
+// Returns the KeyboardCode from a native event. |
+UI_EXPORT KeyboardCode KeyboardCodeFromNative(const NativeEvent& native_event); |
+UI_EXPORT KeyboardCode KeyboardCodeFromNative(const NativeEvent2& native_event); |
+ |
+// Returns true if the message is a mouse event. |
+UI_EXPORT bool IsMouseEvent(const NativeEvent& native_event); |
+UI_EXPORT bool IsMouseEvent(const NativeEvent2& native_event); |
+ |
+// Get the mouse wheel offset from a native event. |
+UI_EXPORT int GetMouseWheelOffset(const NativeEvent& native_event); |
+UI_EXPORT int GetMouseWheelOffset(const NativeEvent2& native_event); |
+ |
} // namespace ui |
#endif // UI_BASE_EVENTS_H_ |
- |