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

Side by Side Diff: views/events/event_x.cc

Issue 6487002: Add a new constructor to KeyEvent. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "views/events/event.h" 5 #include "views/events/event.h"
6 6
7 #include <gdk/gdkx.h> 7 #include <gdk/gdkx.h>
8 #if defined(HAVE_XINPUT2) 8 #if defined(HAVE_XINPUT2)
9 #include <X11/extensions/XInput2.h> 9 #include <X11/extensions/XInput2.h>
10 #endif 10 #endif
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 case 2: 55 case 2:
56 return ui::EF_MIDDLE_BUTTON_DOWN; 56 return ui::EF_MIDDLE_BUTTON_DOWN;
57 case 3: 57 case 3:
58 return ui::EF_RIGHT_BUTTON_DOWN; 58 return ui::EF_RIGHT_BUTTON_DOWN;
59 } 59 }
60 60
61 DLOG(WARNING) << "Unexpected button (" << button << ") received."; 61 DLOG(WARNING) << "Unexpected button (" << button << ") received.";
62 return 0; 62 return 0;
63 } 63 }
64 64
65 ui::EventType EventTypeFromNative(NativeEvent2 native_event) {
66 switch (native_event->type) {
67 case KeyPress:
68 return ui::ET_KEY_PRESSED;
69 case KeyRelease:
70 return ui::ET_KEY_RELEASED;
71 default:
72 NOTREACHED();
73 break;
74 }
75 return ui::ET_UNKNOWN;
76 }
77
65 #if defined(HAVE_XINPUT2) 78 #if defined(HAVE_XINPUT2)
66 int GetButtonMaskForX2Event(XIDeviceEvent* xievent) { 79 int GetButtonMaskForX2Event(XIDeviceEvent* xievent) {
67 int buttonflags = 0; 80 int buttonflags = 0;
68 81
69 for (int i = 0; i < 8 * xievent->buttons.mask_len; i++) { 82 for (int i = 0; i < 8 * xievent->buttons.mask_len; i++) {
70 if (XIMaskIsSet(xievent->buttons.mask, i)) { 83 if (XIMaskIsSet(xievent->buttons.mask, i)) {
71 buttonflags |= GetEventFlagsForButton(i); 84 buttonflags |= GetEventFlagsForButton(i);
72 } 85 }
73 } 86 }
74 87
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 } 218 }
206 } 219 }
207 #endif 220 #endif
208 } 221 }
209 222
210 return 0; 223 return 0;
211 } 224 }
212 225
213 } // namespace 226 } // namespace
214 227
215 KeyEvent::KeyEvent(XEvent* xev) 228 ////////////////////////////////////////////////////////////////////////////////
216 : Event(xev->type == KeyPress ? 229 // KeyEvent, public:
217 ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED, 230
218 GetEventFlagsFromXState(xev->xkey.state)), 231 KeyEvent::KeyEvent(NativeEvent2 native_event_2)
219 key_code_(ui::KeyboardCodeFromXKeyEvent(xev)), 232 : Event(native_event_2,
220 repeat_count_(0), 233 EventTypeFromNative(native_event_2),
221 message_flags_(0), 234 GetEventFlagsFromXState(native_event_2->xkey.state)),
222 native_event_(NULL) { 235 key_code_(ui::KeyboardCodeFromXKeyEvent(native_event_2)) {
223 } 236 }
224 237
238 ////////////////////////////////////////////////////////////////////////////////
239 // MouseEvent, public:
240
225 MouseEvent::MouseEvent(XEvent* xev) 241 MouseEvent::MouseEvent(XEvent* xev)
226 : LocatedEvent(GetMouseEventType(xev), 242 : LocatedEvent(GetMouseEventType(xev),
227 GetMouseEventLocation(xev), 243 GetMouseEventLocation(xev),
228 GetMouseEventFlags(xev)) { 244 GetMouseEventFlags(xev)) {
229 } 245 }
230 246
247 ////////////////////////////////////////////////////////////////////////////////
248 // MouseWheelEvent, public:
249
231 MouseWheelEvent::MouseWheelEvent(XEvent* xev) 250 MouseWheelEvent::MouseWheelEvent(XEvent* xev)
232 : LocatedEvent(ui::ET_MOUSEWHEEL, 251 : LocatedEvent(ui::ET_MOUSEWHEEL,
233 GetMouseEventLocation(xev), 252 GetMouseEventLocation(xev),
234 GetEventFlagsFromXState(xev->xbutton.state)), 253 GetEventFlagsFromXState(xev->xbutton.state)),
235 offset_(GetMouseWheelOffset(xev)) { 254 offset_(GetMouseWheelOffset(xev)) {
236 } 255 }
237 256
257 ////////////////////////////////////////////////////////////////////////////////
258 // TouchEvent, public:
259
238 #if defined(HAVE_XINPUT2) 260 #if defined(HAVE_XINPUT2)
239 TouchEvent::TouchEvent(XEvent* xev) 261 TouchEvent::TouchEvent(XEvent* xev)
240 : LocatedEvent(GetTouchEventType(xev), 262 : LocatedEvent(GetTouchEventType(xev),
241 GetTouchEventLocation(xev), 263 GetTouchEventLocation(xev),
242 GetTouchEventFlags(xev)), 264 GetTouchEventFlags(xev)),
243 touch_id_(GetTouchIDFromXEvent(xev)) { 265 touch_id_(GetTouchIDFromXEvent(xev)) {
244 } 266 }
245 #endif 267 #endif
246 268
247 } // namespace views 269 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698