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

Side by Side Diff: ui/views/widget/widget.cc

Issue 11592011: events: Update mouse-event handlers to not return EventResult. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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/widget/widget.h ('k') | ui/views/widget/widget_unittest.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 #include "ui/views/widget/widget.h" 5 #include "ui/views/widget/widget.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "ui/base/events/event.h" 10 #include "ui/base/events/event.h"
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 non_client_view_->NonClientHitTest(point) : 1110 non_client_view_->NonClientHitTest(point) :
1111 HTNOWHERE; 1111 HTNOWHERE;
1112 } 1112 }
1113 1113
1114 void Widget::OnKeyEvent(ui::KeyEvent* event) { 1114 void Widget::OnKeyEvent(ui::KeyEvent* event) {
1115 ScopedEvent scoped(this, *event); 1115 ScopedEvent scoped(this, *event);
1116 static_cast<internal::RootView*>(GetRootView())-> 1116 static_cast<internal::RootView*>(GetRootView())->
1117 DispatchKeyEvent(event); 1117 DispatchKeyEvent(event);
1118 } 1118 }
1119 1119
1120 bool Widget::OnMouseEvent(const ui::MouseEvent& event) { 1120 void Widget::OnMouseEvent(ui::MouseEvent* event) {
1121 ScopedEvent scoped(this, event); 1121 ScopedEvent scoped(this, *event);
1122 switch (event.type()) { 1122 switch (event->type()) {
1123 case ui::ET_MOUSE_PRESSED: 1123 case ui::ET_MOUSE_PRESSED:
1124 last_mouse_event_was_move_ = false; 1124 last_mouse_event_was_move_ = false;
1125 // Make sure we're still visible before we attempt capture as the mouse 1125 // Make sure we're still visible before we attempt capture as the mouse
1126 // press processing may have made the window hide (as happens with menus). 1126 // press processing may have made the window hide (as happens with menus).
1127 if (GetRootView()->OnMousePressed(event) && IsVisible()) { 1127 if (GetRootView()->OnMousePressed(*event) && IsVisible()) {
1128 is_mouse_button_pressed_ = true; 1128 is_mouse_button_pressed_ = true;
1129 if (!native_widget_->HasCapture()) 1129 if (!native_widget_->HasCapture())
1130 native_widget_->SetCapture(); 1130 native_widget_->SetCapture();
1131 return true; 1131 event->SetHandled();
1132 } 1132 }
1133 return false; 1133 return;
1134 case ui::ET_MOUSE_RELEASED: 1134 case ui::ET_MOUSE_RELEASED:
1135 last_mouse_event_was_move_ = false; 1135 last_mouse_event_was_move_ = false;
1136 is_mouse_button_pressed_ = false; 1136 is_mouse_button_pressed_ = false;
1137 // Release capture first, to avoid confusion if OnMouseReleased blocks. 1137 // Release capture first, to avoid confusion if OnMouseReleased blocks.
1138 if (native_widget_->HasCapture() && 1138 if (native_widget_->HasCapture() &&
1139 ShouldReleaseCaptureOnMouseReleased()) { 1139 ShouldReleaseCaptureOnMouseReleased()) {
1140 native_widget_->ReleaseCapture(); 1140 native_widget_->ReleaseCapture();
1141 } 1141 }
1142 GetRootView()->OnMouseReleased(event); 1142 GetRootView()->OnMouseReleased(*event);
1143 return ((event.flags() & ui::EF_IS_NON_CLIENT) == 0); 1143 if ((event->flags() & ui::EF_IS_NON_CLIENT) == 0)
1144 event->SetHandled();
1145 return;
1144 case ui::ET_MOUSE_MOVED: 1146 case ui::ET_MOUSE_MOVED:
1145 case ui::ET_MOUSE_DRAGGED: 1147 case ui::ET_MOUSE_DRAGGED:
1146 if (native_widget_->HasCapture() && is_mouse_button_pressed_) { 1148 if (native_widget_->HasCapture() && is_mouse_button_pressed_) {
1147 last_mouse_event_was_move_ = false; 1149 last_mouse_event_was_move_ = false;
1148 GetRootView()->OnMouseDragged(event); 1150 GetRootView()->OnMouseDragged(*event);
1149 } else if (!last_mouse_event_was_move_ || 1151 } else if (!last_mouse_event_was_move_ ||
1150 last_mouse_event_position_ != event.location()) { 1152 last_mouse_event_position_ != event->location()) {
1151 last_mouse_event_position_ = event.location(); 1153 last_mouse_event_position_ = event->location();
1152 last_mouse_event_was_move_ = true; 1154 last_mouse_event_was_move_ = true;
1153 GetRootView()->OnMouseMoved(event); 1155 GetRootView()->OnMouseMoved(*event);
1154 } 1156 }
1155 return false; 1157 return;
1156 case ui::ET_MOUSE_EXITED: 1158 case ui::ET_MOUSE_EXITED:
1157 last_mouse_event_was_move_ = false; 1159 last_mouse_event_was_move_ = false;
1158 GetRootView()->OnMouseExited(event); 1160 GetRootView()->OnMouseExited(*event);
1159 return false; 1161 return;
1160 case ui::ET_MOUSEWHEEL: 1162 case ui::ET_MOUSEWHEEL:
1161 return GetRootView()->OnMouseWheel( 1163 if (GetRootView()->OnMouseWheel(
1162 reinterpret_cast<const ui::MouseWheelEvent&>(event)); 1164 reinterpret_cast<const ui::MouseWheelEvent&>(*event)))
1165 event->SetHandled();
1166 return;
1163 default: 1167 default:
1164 return false; 1168 return;
1165 } 1169 }
1166 return true; 1170 event->SetHandled();
1167 } 1171 }
1168 1172
1169 void Widget::OnMouseCaptureLost() { 1173 void Widget::OnMouseCaptureLost() {
1170 if (is_mouse_button_pressed_ || is_touch_down_) 1174 if (is_mouse_button_pressed_ || is_touch_down_)
1171 GetRootView()->OnMouseCaptureLost(); 1175 GetRootView()->OnMouseCaptureLost();
1172 is_touch_down_ = false; 1176 is_touch_down_ = false;
1173 is_mouse_button_pressed_ = false; 1177 is_mouse_button_pressed_ = false;
1174 } 1178 }
1175 1179
1176 void Widget::OnTouchEvent(ui::TouchEvent* event) { 1180 void Widget::OnTouchEvent(ui::TouchEvent* event) {
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1386 1390
1387 //////////////////////////////////////////////////////////////////////////////// 1391 ////////////////////////////////////////////////////////////////////////////////
1388 // internal::NativeWidgetPrivate, NativeWidget implementation: 1392 // internal::NativeWidgetPrivate, NativeWidget implementation:
1389 1393
1390 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { 1394 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() {
1391 return this; 1395 return this;
1392 } 1396 }
1393 1397
1394 } // namespace internal 1398 } // namespace internal
1395 } // namespace views 1399 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/widget.h ('k') | ui/views/widget/widget_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698