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

Side by Side Diff: ui/aura/event.cc

Issue 7942004: Consolidate/cleanup event cracking code; single out GdkEvents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge removal of compact nav. Created 9 years, 2 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.h ('k') | ui/aura/event_win.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 #include "ui/aura/event.h" 5 #include "ui/aura/event.h"
6 6
7 #include "ui/aura/window.h" 7 #include "ui/aura/window.h"
8 8
9 namespace aura { 9 namespace aura {
10 10
11 Event::Event(ui::EventType type, int flags) 11 Event::Event(ui::EventType type, int flags)
12 : type_(type), 12 : type_(type),
13 time_stamp_(base::Time::NowFromSystemTime()), 13 time_stamp_(base::Time::NowFromSystemTime()),
14 flags_(flags) { 14 flags_(flags) {
15 Init(); 15 Init();
16 } 16 }
17 17
18 Event::Event(NativeEvent native_event, ui::EventType type, int flags) 18 Event::Event(const ui::NativeEvent& native_event, ui::EventType type, int flags)
19 : type_(type), 19 : type_(type),
20 time_stamp_(base::Time::NowFromSystemTime()), 20 time_stamp_(base::Time::NowFromSystemTime()),
21 flags_(flags) { 21 flags_(flags) {
22 InitWithNativeEvent(native_event); 22 InitWithNativeEvent(native_event);
23 } 23 }
24 24
25 Event::Event(const Event& copy) 25 Event::Event(const Event& copy)
26 : native_event_(copy.native_event_), 26 : native_event_(copy.native_event_),
27 type_(copy.type_), 27 type_(copy.type_),
28 time_stamp_(copy.time_stamp_), 28 time_stamp_(copy.time_stamp_),
29 flags_(copy.flags_) { 29 flags_(copy.flags_) {
30 } 30 }
31 31
32 void Event::Init() {
33 memset(&native_event_, 0, sizeof(native_event_));
34 }
35
36 void Event::InitWithNativeEvent(const ui::NativeEvent& native_event) {
37 native_event_ = native_event;
38 }
39
40 LocatedEvent::LocatedEvent(const ui::NativeEvent& native_event)
41 : Event(native_event,
42 ui::EventTypeFromNative(native_event),
43 ui::EventFlagsFromNative(native_event)),
44 location_(ui::EventLocationFromNative(native_event)) {
45 }
46
32 LocatedEvent::LocatedEvent(const LocatedEvent& model, 47 LocatedEvent::LocatedEvent(const LocatedEvent& model,
33 Window* source, 48 Window* source,
34 Window* target) 49 Window* target)
35 : Event(model), 50 : Event(model),
36 location_(model.location_) { 51 location_(model.location_) {
37 if (target && target != source) 52 if (target && target != source)
38 Window::ConvertPointToWindow(source, target, &location_); 53 Window::ConvertPointToWindow(source, target, &location_);
39 } 54 }
40 55
41 LocatedEvent::LocatedEvent(ui::EventType type, 56 LocatedEvent::LocatedEvent(ui::EventType type,
42 const gfx::Point& location, 57 const gfx::Point& location,
43 int flags) 58 int flags)
44 : Event(type, flags), 59 : Event(type, flags),
45 location_(location) { 60 location_(location) {
46 } 61 }
47 62
63 MouseEvent::MouseEvent(const ui::NativeEvent& native_event)
64 : LocatedEvent(native_event) {
65 }
66
48 MouseEvent::MouseEvent(const MouseEvent& model, Window* source, Window* target) 67 MouseEvent::MouseEvent(const MouseEvent& model, Window* source, Window* target)
49 : LocatedEvent(model, source, target) { 68 : LocatedEvent(model, source, target) {
50 } 69 }
51 70
52 MouseEvent::MouseEvent(const MouseEvent& model, 71 MouseEvent::MouseEvent(const MouseEvent& model,
53 Window* source, 72 Window* source,
54 Window* target, 73 Window* target,
55 ui::EventType type) 74 ui::EventType type)
56 : LocatedEvent(model, source, target) { 75 : LocatedEvent(model, source, target) {
57 set_type(type); 76 set_type(type);
58 } 77 }
59 78
60 MouseEvent::MouseEvent(ui::EventType type, 79 MouseEvent::MouseEvent(ui::EventType type,
61 const gfx::Point& location, 80 const gfx::Point& location,
62 int flags) 81 int flags)
63 : LocatedEvent(type, location, flags) { 82 : LocatedEvent(type, location, flags) {
64 } 83 }
65 84
85 KeyEvent::KeyEvent(const ui::NativeEvent& native_event)
86 : Event(native_event,
87 ui::EventTypeFromNative(native_event),
88 ui::EventFlagsFromNative(native_event)),
89 key_code_(ui::KeyboardCodeFromNative(native_event)) {
90 }
91
66 KeyEvent::KeyEvent(ui::EventType type, 92 KeyEvent::KeyEvent(ui::EventType type,
67 ui::KeyboardCode key_code, 93 ui::KeyboardCode key_code,
68 int flags) 94 int flags)
69 : Event(type, flags), 95 : Event(type, flags),
70 key_code_(key_code) { 96 key_code_(key_code) {
71 } 97 }
72 98
73 } // namespace aura 99 } // namespace aura
74 100
OLDNEW
« no previous file with comments | « ui/aura/event.h ('k') | ui/aura/event_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698