| OLD | NEW |
| 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/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1157 if (root_view && root_view->OnMousePressed(*event) && | 1157 if (root_view && root_view->OnMousePressed(*event) && |
| 1158 widget_deletion_observer.IsWidgetAlive() && IsVisible() && | 1158 widget_deletion_observer.IsWidgetAlive() && IsVisible() && |
| 1159 internal::NativeWidgetPrivate::IsMouseButtonDown()) { | 1159 internal::NativeWidgetPrivate::IsMouseButtonDown()) { |
| 1160 is_mouse_button_pressed_ = true; | 1160 is_mouse_button_pressed_ = true; |
| 1161 if (!native_widget_->HasCapture()) | 1161 if (!native_widget_->HasCapture()) |
| 1162 native_widget_->SetCapture(); | 1162 native_widget_->SetCapture(); |
| 1163 event->SetHandled(); | 1163 event->SetHandled(); |
| 1164 } | 1164 } |
| 1165 return; | 1165 return; |
| 1166 } | 1166 } |
| 1167 |
| 1167 case ui::ET_MOUSE_RELEASED: | 1168 case ui::ET_MOUSE_RELEASED: |
| 1168 last_mouse_event_was_move_ = false; | 1169 last_mouse_event_was_move_ = false; |
| 1169 is_mouse_button_pressed_ = false; | 1170 is_mouse_button_pressed_ = false; |
| 1170 // Release capture first, to avoid confusion if OnMouseReleased blocks. | 1171 // Release capture first, to avoid confusion if OnMouseReleased blocks. |
| 1171 if (auto_release_capture_ && native_widget_->HasCapture()) | 1172 if (auto_release_capture_ && native_widget_->HasCapture()) |
| 1172 native_widget_->ReleaseCapture(); | 1173 native_widget_->ReleaseCapture(); |
| 1173 if (root_view) | 1174 if (root_view) |
| 1174 root_view->OnMouseReleased(*event); | 1175 root_view->OnMouseReleased(*event); |
| 1175 if ((event->flags() & ui::EF_IS_NON_CLIENT) == 0) | 1176 if ((event->flags() & ui::EF_IS_NON_CLIENT) == 0) |
| 1176 event->SetHandled(); | 1177 event->SetHandled(); |
| 1177 return; | 1178 return; |
| 1179 |
| 1178 case ui::ET_MOUSE_MOVED: | 1180 case ui::ET_MOUSE_MOVED: |
| 1179 case ui::ET_MOUSE_DRAGGED: | 1181 case ui::ET_MOUSE_DRAGGED: |
| 1180 if (native_widget_->HasCapture() && is_mouse_button_pressed_) { | 1182 if (native_widget_->HasCapture() && is_mouse_button_pressed_) { |
| 1181 last_mouse_event_was_move_ = false; | 1183 last_mouse_event_was_move_ = false; |
| 1182 if (root_view) | 1184 if (root_view) |
| 1183 root_view->OnMouseDragged(*event); | 1185 root_view->OnMouseDragged(*event); |
| 1184 } else if (!last_mouse_event_was_move_ || | 1186 } else if (!last_mouse_event_was_move_ || |
| 1185 last_mouse_event_position_ != event->location()) { | 1187 last_mouse_event_position_ != event->location()) { |
| 1186 last_mouse_event_position_ = event->location(); | 1188 last_mouse_event_position_ = event->location(); |
| 1187 last_mouse_event_was_move_ = true; | 1189 last_mouse_event_was_move_ = true; |
| 1188 if (root_view) | 1190 if (root_view) |
| 1189 root_view->OnMouseMoved(*event); | 1191 root_view->OnMouseMoved(*event); |
| 1190 } | 1192 } |
| 1191 return; | 1193 return; |
| 1194 |
| 1192 case ui::ET_MOUSE_EXITED: | 1195 case ui::ET_MOUSE_EXITED: |
| 1193 last_mouse_event_was_move_ = false; | 1196 last_mouse_event_was_move_ = false; |
| 1194 if (root_view) | 1197 if (root_view) |
| 1195 root_view->OnMouseExited(*event); | 1198 root_view->OnMouseExited(*event); |
| 1196 return; | 1199 return; |
| 1200 |
| 1197 case ui::ET_MOUSEWHEEL: | 1201 case ui::ET_MOUSEWHEEL: |
| 1198 if (root_view && root_view->OnMouseWheel( | 1202 if (root_view && root_view->OnMouseWheel( |
| 1199 static_cast<const ui::MouseWheelEvent&>(*event))) | 1203 static_cast<const ui::MouseWheelEvent&>(*event))) |
| 1200 event->SetHandled(); | 1204 event->SetHandled(); |
| 1201 return; | 1205 return; |
| 1206 |
| 1202 default: | 1207 default: |
| 1203 return; | 1208 return; |
| 1204 } | 1209 } |
| 1205 event->SetHandled(); | |
| 1206 } | 1210 } |
| 1207 | 1211 |
| 1208 void Widget::OnMouseCaptureLost() { | 1212 void Widget::OnMouseCaptureLost() { |
| 1209 if (is_mouse_button_pressed_ || is_touch_down_) { | 1213 if (is_mouse_button_pressed_ || is_touch_down_) { |
| 1210 View* root_view = GetRootView(); | 1214 View* root_view = GetRootView(); |
| 1211 if (root_view) | 1215 if (root_view) |
| 1212 root_view->OnMouseCaptureLost(); | 1216 root_view->OnMouseCaptureLost(); |
| 1213 } | 1217 } |
| 1214 is_touch_down_ = false; | 1218 is_touch_down_ = false; |
| 1215 is_mouse_button_pressed_ = false; | 1219 is_mouse_button_pressed_ = false; |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1444 | 1448 |
| 1445 //////////////////////////////////////////////////////////////////////////////// | 1449 //////////////////////////////////////////////////////////////////////////////// |
| 1446 // internal::NativeWidgetPrivate, NativeWidget implementation: | 1450 // internal::NativeWidgetPrivate, NativeWidget implementation: |
| 1447 | 1451 |
| 1448 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { | 1452 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { |
| 1449 return this; | 1453 return this; |
| 1450 } | 1454 } |
| 1451 | 1455 |
| 1452 } // namespace internal | 1456 } // namespace internal |
| 1453 } // namespace views | 1457 } // namespace views |
| OLD | NEW |