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

Side by Side Diff: ui/views/events/event.cc

Issue 10154005: views: Some code cleanup: touch-events are not used to generate mouse-events anymore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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/views/events/event.h ('k') | no next file » | 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 #include "ui/views/events/event.h" 5 #include "ui/views/events/event.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/base/keycodes/keyboard_code_conversion.h" 8 #include "ui/base/keycodes/keyboard_code_conversion.h"
9 #include "ui/views/view.h" 9 #include "ui/views/view.h"
10 #include "ui/views/widget/root_view.h" 10 #include "ui/views/widget/root_view.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 // MouseEvent, public: 91 // MouseEvent, public:
92 92
93 MouseEvent::MouseEvent(const NativeEvent& native_event) 93 MouseEvent::MouseEvent(const NativeEvent& native_event)
94 : LocatedEvent(native_event) { 94 : LocatedEvent(native_event) {
95 } 95 }
96 96
97 MouseEvent::MouseEvent(const MouseEvent& model, View* source, View* target) 97 MouseEvent::MouseEvent(const MouseEvent& model, View* source, View* target)
98 : LocatedEvent(model, source, target) { 98 : LocatedEvent(model, source, target) {
99 } 99 }
100 100
101 MouseEvent::MouseEvent(const TouchEvent& touch)
102 : LocatedEvent(touch.native_event()) {
103 // The location of the event is correctly extracted from the native event. But
104 // it is necessary to update the event type.
105 ui::EventType mtype = ui::ET_UNKNOWN;
106 switch (touch.type()) {
107 case ui::ET_TOUCH_RELEASED:
108 mtype = ui::ET_MOUSE_RELEASED;
109 break;
110 case ui::ET_TOUCH_PRESSED:
111 mtype = ui::ET_MOUSE_PRESSED;
112 break;
113 case ui::ET_TOUCH_MOVED:
114 mtype = ui::ET_MOUSE_MOVED;
115 break;
116 default:
117 NOTREACHED() << "Invalid mouse event.";
118 }
119 set_type(mtype);
120
121 // It may not be possible to extract the button-information necessary for a
122 // MouseEvent from the native event for a TouchEvent, so the flags are
123 // explicitly updated as well. The button is approximated from the touchpoint
124 // identity.
125 int new_flags = flags() & ~(ui::EF_LEFT_MOUSE_BUTTON |
126 ui::EF_RIGHT_MOUSE_BUTTON |
127 ui::EF_MIDDLE_MOUSE_BUTTON);
128 int button = ui::EF_LEFT_MOUSE_BUTTON;
129 if (touch.identity() == 1)
130 button = ui::EF_RIGHT_MOUSE_BUTTON;
131 else if (touch.identity() == 2)
132 button = ui::EF_MIDDLE_MOUSE_BUTTON;
133 set_flags(new_flags | button);
134 }
135
136 //////////////////////////////////////////////////////////////////////////////// 101 ////////////////////////////////////////////////////////////////////////////////
137 // MouseWheelEvent, public: 102 // MouseWheelEvent, public:
138 103
139 #if !defined(USE_AURA) 104 #if !defined(USE_AURA)
140 MouseWheelEvent::MouseWheelEvent(const NativeEvent& native_event) 105 MouseWheelEvent::MouseWheelEvent(const NativeEvent& native_event)
141 : MouseEvent(native_event), 106 : MouseEvent(native_event),
142 offset_(ui::GetMouseWheelOffset(native_event)) { 107 offset_(ui::GetMouseWheelOffset(native_event)) {
143 } 108 }
144 #endif 109 #endif
145 110
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 #endif 231 #endif
267 232
268 GestureEventForTest::GestureEventForTest(ui::EventType type, 233 GestureEventForTest::GestureEventForTest(ui::EventType type,
269 int x, 234 int x,
270 int y, 235 int y,
271 int flags) 236 int flags)
272 : GestureEvent(type, x, y, flags) { 237 : GestureEvent(type, x, y, flags) {
273 } 238 }
274 239
275 } // namespace views 240 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/events/event.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698