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

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: Fix GdkEvent init, NativeWidgetGtk casting, and Get[Unmodified]Character checks. 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
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(USE_X11)
17 typedef union _XEvent XEvent;
18 #endif
19 #if defined(USE_WAYLAND)
9 namespace ui { 20 namespace ui {
21 union WaylandEvent;
22 }
23 #endif
24
25 namespace ui {
26
27 #if defined(OS_WIN)
28 typedef MSG NativeEvent;
29 #elif defined(USE_WAYLAND)
30 typedef ui::WaylandEvent* NativeEvent;
31 #elif defined(USE_X11)
32 typedef XEvent* NativeEvent;
33 #else
34 typedef void* NativeEvent;
35 #endif
10 36
11 // Event types. (prefixed because of a conflict with windows headers) 37 // Event types. (prefixed because of a conflict with windows headers)
12 enum EventType { 38 enum EventType {
13 ET_UNKNOWN = 0, 39 ET_UNKNOWN = 0,
14 ET_MOUSE_PRESSED, 40 ET_MOUSE_PRESSED,
15 ET_MOUSE_DRAGGED, 41 ET_MOUSE_DRAGGED,
16 ET_MOUSE_RELEASED, 42 ET_MOUSE_RELEASED,
17 ET_MOUSE_MOVED, 43 ET_MOUSE_MOVED,
18 ET_MOUSE_ENTERED, 44 ET_MOUSE_ENTERED,
19 ET_MOUSE_EXITED, 45 ET_MOUSE_EXITED,
(...skipping 15 matching lines...) Expand all
35 // all platforms. 61 // all platforms.
36 enum EventFlags { 62 enum EventFlags {
37 EF_CAPS_LOCK_DOWN = 1 << 0, 63 EF_CAPS_LOCK_DOWN = 1 << 0,
38 EF_SHIFT_DOWN = 1 << 1, 64 EF_SHIFT_DOWN = 1 << 1,
39 EF_CONTROL_DOWN = 1 << 2, 65 EF_CONTROL_DOWN = 1 << 2,
40 EF_ALT_DOWN = 1 << 3, 66 EF_ALT_DOWN = 1 << 3,
41 EF_LEFT_BUTTON_DOWN = 1 << 4, 67 EF_LEFT_BUTTON_DOWN = 1 << 4,
42 EF_MIDDLE_BUTTON_DOWN = 1 << 5, 68 EF_MIDDLE_BUTTON_DOWN = 1 << 5,
43 EF_RIGHT_BUTTON_DOWN = 1 << 6, 69 EF_RIGHT_BUTTON_DOWN = 1 << 6,
44 EF_COMMAND_DOWN = 1 << 7, // Only useful on OSX 70 EF_COMMAND_DOWN = 1 << 7, // Only useful on OSX
71 EF_EXTENDED = 1 << 8, // Windows extended key (see WM_KEYDOWN doc)
45 }; 72 };
46 73
47 // Flags specific to mouse events 74 // Flags specific to mouse events
48 enum MouseEventFlags { 75 enum MouseEventFlags {
49 EF_IS_DOUBLE_CLICK = 1 << 16, 76 EF_IS_DOUBLE_CLICK = 1 << 16,
50 EF_IS_NON_CLIENT = 1 << 17 77 EF_IS_NON_CLIENT = 1 << 17
51 }; 78 };
52 79
53 enum TouchStatus { 80 enum TouchStatus {
54 TOUCH_STATUS_UNKNOWN = 0, // Unknown touch status. This is used to indicate 81 TOUCH_STATUS_UNKNOWN = 0, // Unknown touch status. This is used to indicate
55 // that the touch event was not handled. 82 // that the touch event was not handled.
56 TOUCH_STATUS_START, // The touch event initiated a touch sequence. 83 TOUCH_STATUS_START, // The touch event initiated a touch sequence.
57 TOUCH_STATUS_CONTINUE, // The touch event is part of a previously 84 TOUCH_STATUS_CONTINUE, // The touch event is part of a previously
58 // started touch sequence. 85 // started touch sequence.
59 TOUCH_STATUS_END, // The touch event ended the touch sequence. 86 TOUCH_STATUS_END, // The touch event ended the touch sequence.
60 TOUCH_STATUS_CANCEL, // The touch event was cancelled, but didn't 87 TOUCH_STATUS_CANCEL, // The touch event was cancelled, but didn't
61 // terminate the touch sequence. 88 // terminate the touch sequence.
62 TOUCH_STATUS_SYNTH_MOUSE // The touch event was not processed, but a 89 TOUCH_STATUS_SYNTH_MOUSE // The touch event was not processed, but a
63 // synthetic mouse event generated from the 90 // synthetic mouse event generated from the
64 // unused touch event was handled. 91 // unused touch event was handled.
65 }; 92 };
66 93
94 // Get the EventType from a native event.
95 UI_EXPORT EventType EventTypeFromNative(const NativeEvent& native_event);
96
97 // Get the EventFlags from a native event.
98 UI_EXPORT int EventFlagsFromNative(const NativeEvent& native_event);
99
100 // Get the location from a native event.
101 UI_EXPORT gfx::Point EventLocationFromNative(const NativeEvent& native_event);
102
103 // Returns the KeyboardCode from a native event.
104 UI_EXPORT KeyboardCode KeyboardCodeFromNative(const NativeEvent& native_event);
105
106 // Returns true if the message is a mouse event.
107 UI_EXPORT bool IsMouseEvent(const NativeEvent& native_event);
108
109 // Get the mouse wheel offset from a native event.
110 UI_EXPORT int GetMouseWheelOffset(const NativeEvent& native_event);
111
67 } // namespace ui 112 } // namespace ui
68 113
69 #endif // UI_BASE_EVENTS_H_ 114 #endif // UI_BASE_EVENTS_H_
70
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698