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

Side by Side Diff: ui/base/events.h

Issue 7942004: Consolidate/cleanup event cracking code; single out GdkEvents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: File permissions and aura fix. Created 9 years, 3 months 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 | Annotate | Revision Log
« no previous file with comments | « ui/aura/event_x.cc ('k') | ui/base/gtk/events_gtk.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_BASE_EVENTS_H_ 5 #ifndef UI_BASE_EVENTS_H_
6 #define UI_BASE_EVENTS_H_ 6 #define UI_BASE_EVENTS_H_
7 #pragma once 7 #pragma once
8 8
9 #include "ui/base/keycodes/keyboard_codes.h"
10 #include "ui/gfx/native_widget_types.h"
11
12 namespace gfx {
13 class Point;
14 }
15
16 #if defined(OS_LINUX)
sadrul 2011/09/22 20:15:33 #if defined(TOOLKIT_USES_GTK)
17 typedef union _GdkEvent GdkEvent;
18 #endif
19 #if defined(USE_X11)
20 typedef union _XEvent XEvent;
21 #endif
22 #if defined(USE_WAYLAND)
9 namespace ui { 23 namespace ui {
24 union WaylandEvent;
25 }
26 #endif
27
28 namespace ui {
29
30 // A note about NativeEvent and NativeEvent2.
31 // 1. Eventually TOOLKIT_VIEWS will converge on using XEvent as we remove
32 // Gtk/Gdk from the stack.
33 // 2. TOUCH_UI needs XEvents now for certain event types.
34 // 3. TOUCH_UI also needs GdkEvents for certain event types.
35 //
36 // => NativeEvent and NativeEvent2.
37 //
38 // Once we replace usage of Gtk/Gdk types with Xlib types across the board in
39 // views, we can remove NativeEvent2 and typedef XEvent* to NativeEvent. The
40 // world will then be beautiful(ish).
41
42 #if defined(OS_WIN)
43 typedef MSG NativeEvent;
44 #elif defined(OS_LINUX)
45
46 #if defined(USE_WAYLAND)
47 typedef ui::WaylandEvent* NativeEvent;
48 #else
49 typedef GdkEvent* NativeEvent;
50 #endif
51
52 #else
53 typedef void* NativeEvent;
54 #endif
55
56 #if defined(USE_X11)
57 typedef XEvent* NativeEvent2;
58 #else
59 typedef void* NativeEvent2;
60 #endif
sadrul 2011/09/22 20:15:33 This has to be a bit more complicated at the momen
10 61
11 // Event types. (prefixed because of a conflict with windows headers) 62 // Event types. (prefixed because of a conflict with windows headers)
12 enum EventType { 63 enum EventType {
13 ET_UNKNOWN = 0, 64 ET_UNKNOWN = 0,
14 ET_MOUSE_PRESSED, 65 ET_MOUSE_PRESSED,
15 ET_MOUSE_DRAGGED, 66 ET_MOUSE_DRAGGED,
16 ET_MOUSE_RELEASED, 67 ET_MOUSE_RELEASED,
17 ET_MOUSE_MOVED, 68 ET_MOUSE_MOVED,
18 ET_MOUSE_ENTERED, 69 ET_MOUSE_ENTERED,
19 ET_MOUSE_EXITED, 70 ET_MOUSE_EXITED,
(...skipping 15 matching lines...) Expand all
35 // all platforms. 86 // all platforms.
36 enum EventFlags { 87 enum EventFlags {
37 EF_CAPS_LOCK_DOWN = 1 << 0, 88 EF_CAPS_LOCK_DOWN = 1 << 0,
38 EF_SHIFT_DOWN = 1 << 1, 89 EF_SHIFT_DOWN = 1 << 1,
39 EF_CONTROL_DOWN = 1 << 2, 90 EF_CONTROL_DOWN = 1 << 2,
40 EF_ALT_DOWN = 1 << 3, 91 EF_ALT_DOWN = 1 << 3,
41 EF_LEFT_BUTTON_DOWN = 1 << 4, 92 EF_LEFT_BUTTON_DOWN = 1 << 4,
42 EF_MIDDLE_BUTTON_DOWN = 1 << 5, 93 EF_MIDDLE_BUTTON_DOWN = 1 << 5,
43 EF_RIGHT_BUTTON_DOWN = 1 << 6, 94 EF_RIGHT_BUTTON_DOWN = 1 << 6,
44 EF_COMMAND_DOWN = 1 << 7, // Only useful on OSX 95 EF_COMMAND_DOWN = 1 << 7, // Only useful on OSX
96 EF_EXTENDED = 1 << 8, // Windows extended key (see WM_KEYDOWN doc)
45 }; 97 };
46 98
47 // Flags specific to mouse events 99 // Flags specific to mouse events
48 enum MouseEventFlags { 100 enum MouseEventFlags {
49 EF_IS_DOUBLE_CLICK = 1 << 16, 101 EF_IS_DOUBLE_CLICK = 1 << 16,
50 EF_IS_NON_CLIENT = 1 << 17 102 EF_IS_NON_CLIENT = 1 << 17
51 }; 103 };
52 104
53 enum TouchStatus { 105 enum TouchStatus {
54 TOUCH_STATUS_UNKNOWN = 0, // Unknown touch status. This is used to indicate 106 TOUCH_STATUS_UNKNOWN = 0, // Unknown touch status. This is used to indicate
55 // that the touch event was not handled. 107 // that the touch event was not handled.
56 TOUCH_STATUS_START, // The touch event initiated a touch sequence. 108 TOUCH_STATUS_START, // The touch event initiated a touch sequence.
57 TOUCH_STATUS_CONTINUE, // The touch event is part of a previously 109 TOUCH_STATUS_CONTINUE, // The touch event is part of a previously
58 // started touch sequence. 110 // started touch sequence.
59 TOUCH_STATUS_END, // The touch event ended the touch sequence. 111 TOUCH_STATUS_END, // The touch event ended the touch sequence.
60 TOUCH_STATUS_CANCEL, // The touch event was cancelled, but didn't 112 TOUCH_STATUS_CANCEL, // The touch event was cancelled, but didn't
61 // terminate the touch sequence. 113 // terminate the touch sequence.
62 TOUCH_STATUS_SYNTH_MOUSE // The touch event was not processed, but a 114 TOUCH_STATUS_SYNTH_MOUSE // The touch event was not processed, but a
63 // synthetic mouse event generated from the 115 // synthetic mouse event generated from the
64 // unused touch event was handled. 116 // unused touch event was handled.
65 }; 117 };
66 118
119 // Get the EventType from a native event.
120 UI_EXPORT EventType EventTypeFromNative(const NativeEvent& native_event);
121 UI_EXPORT EventType EventTypeFromNative(const NativeEvent2& native_event);
122
123 // Get the EventFlags from a native event.
124 UI_EXPORT int EventFlagsFromNative(const NativeEvent& native_event);
125 UI_EXPORT int EventFlagsFromNative(const NativeEvent2& native_event);
126
127 // Get the location from a native event.
128 UI_EXPORT gfx::Point EventLocationFromNative(const NativeEvent& native_event);
129 UI_EXPORT gfx::Point EventLocationFromNative(const NativeEvent2& native_event);
130
131 // Returns the KeyboardCode from a native event.
132 UI_EXPORT KeyboardCode KeyboardCodeFromNative(const NativeEvent& native_event);
133 UI_EXPORT KeyboardCode KeyboardCodeFromNative(const NativeEvent2& native_event);
134
135 // Returns true if the message is a mouse event.
136 UI_EXPORT bool IsMouseEvent(const NativeEvent& native_event);
137 UI_EXPORT bool IsMouseEvent(const NativeEvent2& native_event);
138
139 // Get the mouse wheel offset from a native event.
140 UI_EXPORT int GetMouseWheelOffset(const NativeEvent& native_event);
141 UI_EXPORT int GetMouseWheelOffset(const NativeEvent2& native_event);
142
67 } // namespace ui 143 } // namespace ui
68 144
69 #endif // UI_BASE_EVENTS_H_ 145 #endif // UI_BASE_EVENTS_H_
70
OLDNEW
« no previous file with comments | « ui/aura/event_x.cc ('k') | ui/base/gtk/events_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698