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

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

Issue 862093002: Split the event library into a cross-platform and native part. Part 1. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Rebase to ToT Created 5 years, 11 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
« no previous file with comments | « ui/events/event_unittest.cc ('k') | ui/events/event_utils.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_EVENTS_EVENT_UTILS_H_ 5 #ifndef UI_EVENTS_EVENT_UTILS_H_
6 #define UI_EVENTS_EVENT_UTILS_H_ 6 #define UI_EVENTS_EVENT_UTILS_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/event_types.h" 9 #include "base/event_types.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 18 matching lines...) Expand all
29 } 29 }
30 30
31 namespace ui { 31 namespace ui {
32 32
33 class Event; 33 class Event;
34 class MouseEvent; 34 class MouseEvent;
35 35
36 // Updates the list of devices for cached properties. 36 // Updates the list of devices for cached properties.
37 EVENTS_EXPORT void UpdateDeviceList(); 37 EVENTS_EXPORT void UpdateDeviceList();
38 38
39 // Returns a ui::Event wrapping a native event. Ownership of the returned value
40 // is transferred to the caller.
41 EVENTS_EXPORT scoped_ptr<Event> EventFromNative(
42 const base::NativeEvent& native_event);
43
44 // Get the EventType from a native event. 39 // Get the EventType from a native event.
45 EVENTS_EXPORT EventType EventTypeFromNative( 40 EVENTS_EXPORT EventType EventTypeFromNative(
46 const base::NativeEvent& native_event); 41 const base::NativeEvent& native_event);
47 42
48 // Get the EventFlags from a native event. 43 // Get the EventFlags from a native event.
49 EVENTS_EXPORT int EventFlagsFromNative(const base::NativeEvent& native_event); 44 EVENTS_EXPORT int EventFlagsFromNative(const base::NativeEvent& native_event);
50 45
51 // Get the timestamp from a native event. 46 // Get the timestamp from a native event.
52 EVENTS_EXPORT base::TimeDelta EventTimeFromNative( 47 EVENTS_EXPORT base::TimeDelta EventTimeFromNative(
53 const base::NativeEvent& native_event); 48 const base::NativeEvent& native_event);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 EVENTS_EXPORT bool IsCharFromNative(const base::NativeEvent& native_event); 93 EVENTS_EXPORT bool IsCharFromNative(const base::NativeEvent& native_event);
99 94
100 // Returns the flags of the button that changed during a press/release. 95 // Returns the flags of the button that changed during a press/release.
101 EVENTS_EXPORT int GetChangedMouseButtonFlagsFromNative( 96 EVENTS_EXPORT int GetChangedMouseButtonFlagsFromNative(
102 const base::NativeEvent& native_event); 97 const base::NativeEvent& native_event);
103 98
104 // Gets the mouse wheel offsets from a native event. 99 // Gets the mouse wheel offsets from a native event.
105 EVENTS_EXPORT gfx::Vector2d GetMouseWheelOffset( 100 EVENTS_EXPORT gfx::Vector2d GetMouseWheelOffset(
106 const base::NativeEvent& native_event); 101 const base::NativeEvent& native_event);
107 102
108 // Returns a copy of |native_event|. Depending on the platform, this copy may
109 // need to be deleted with ReleaseCopiedNativeEvent().
110 base::NativeEvent CopyNativeEvent(
111 const base::NativeEvent& native_event);
112
113 // Delete a |native_event| previously created by CopyNativeEvent().
114 void ReleaseCopiedNativeEvent(
115 const base::NativeEvent& native_event);
116
117 // Gets the touch id from a native event. 103 // Gets the touch id from a native event.
118 EVENTS_EXPORT int GetTouchId(const base::NativeEvent& native_event); 104 EVENTS_EXPORT int GetTouchId(const base::NativeEvent& native_event);
119 105
120 // Increases the number of times |ClearTouchIdIfReleased| needs to be called on 106 // Increases the number of times |ClearTouchIdIfReleased| needs to be called on
121 // an event with a given touch id before it will actually be cleared. 107 // an event with a given touch id before it will actually be cleared.
122 EVENTS_EXPORT void IncrementTouchIdRefCount( 108 EVENTS_EXPORT void IncrementTouchIdRefCount(
123 const base::NativeEvent& native_event); 109 const base::NativeEvent& native_event);
124 110
125 // Clear the touch id from bookkeeping if it is a release/cancel event. 111 // Clear the touch id from bookkeeping if it is a release/cancel event.
126 EVENTS_EXPORT void ClearTouchIdIfReleased( 112 EVENTS_EXPORT void ClearTouchIdIfReleased(
(...skipping 21 matching lines...) Expand all
148 // Returns whether this is a scroll event and optionally gets the amount to be 134 // Returns whether this is a scroll event and optionally gets the amount to be
149 // scrolled. |x_offset|, |y_offset| and |finger_count| can be NULL. 135 // scrolled. |x_offset|, |y_offset| and |finger_count| can be NULL.
150 EVENTS_EXPORT bool GetScrollOffsets(const base::NativeEvent& native_event, 136 EVENTS_EXPORT bool GetScrollOffsets(const base::NativeEvent& native_event,
151 float* x_offset, 137 float* x_offset,
152 float* y_offset, 138 float* y_offset,
153 float* x_offset_ordinal, 139 float* x_offset_ordinal,
154 float* y_offset_ordinal, 140 float* y_offset_ordinal,
155 int* finger_count); 141 int* finger_count);
156 142
157 #if defined(OS_WIN) 143 #if defined(OS_WIN)
158 EVENTS_EXPORT int GetModifiersFromACCEL(const ACCEL& accel);
159 EVENTS_EXPORT int GetModifiersFromKeyState();
160
161 // Returns true if |message| identifies a mouse event that was generated as the 144 // Returns true if |message| identifies a mouse event that was generated as the
162 // result of a touch event. 145 // result of a touch event.
163 EVENTS_EXPORT bool IsMouseEventFromTouch(UINT message); 146 EVENTS_EXPORT bool IsMouseEventFromTouch(UINT message);
164 147
165 // Converts scan code and lParam each other. The scan code 148 // Converts scan code and lParam each other. The scan code
166 // representing an extended key contains 0xE000 bits. 149 // representing an extended key contains 0xE000 bits.
167 EVENTS_EXPORT uint16 GetScanCodeFromLParam(LPARAM lParam); 150 EVENTS_EXPORT uint16 GetScanCodeFromLParam(LPARAM lParam);
168 EVENTS_EXPORT LPARAM GetLParamFromScanCode(uint16 scan_code); 151 EVENTS_EXPORT LPARAM GetLParamFromScanCode(uint16 scan_code);
169 152
170 #endif 153 #endif
171 154
172 #if defined(USE_X11)
173 // Update the native X11 event to correspond to the new flags.
174 EVENTS_EXPORT void UpdateX11EventForFlags(Event* event);
175 // Update the native X11 event to correspond to the new button flags.
176 EVENTS_EXPORT void UpdateX11EventForChangedButtonFlags(MouseEvent* event);
177 #endif
178
179 // Registers a custom event type.
180 EVENTS_EXPORT int RegisterCustomEventType();
181
182 } // namespace ui 155 } // namespace ui
183 156
184 #endif // UI_EVENTS_EVENT_UTILS_H_ 157 #endif // UI_EVENTS_EVENT_UTILS_H_
OLDNEW
« no previous file with comments | « ui/events/event_unittest.cc ('k') | ui/events/event_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698