| OLD | NEW |
| 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 "views/widget/root_view.h" | 5 #include "views/widget/root_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 gfx::NativeView native_view) { | 78 gfx::NativeView native_view) { |
| 79 PropagateNativeViewHierarchyChanged(attached, native_view, this); | 79 PropagateNativeViewHierarchyChanged(attached, native_view, this); |
| 80 } | 80 } |
| 81 | 81 |
| 82 // Input ----------------------------------------------------------------------- | 82 // Input ----------------------------------------------------------------------- |
| 83 | 83 |
| 84 void RootView::ProcessMouseDragCanceled() { | 84 void RootView::ProcessMouseDragCanceled() { |
| 85 if (mouse_pressed_handler_) { | 85 if (mouse_pressed_handler_) { |
| 86 // Synthesize a release event. | 86 // Synthesize a release event. |
| 87 MouseEvent release_event(ui::ET_MOUSE_RELEASED, last_mouse_event_x_, | 87 MouseEvent release_event(ui::ET_MOUSE_RELEASED, last_mouse_event_x_, |
| 88 last_mouse_event_y_, last_mouse_event_flags_); | 88 last_mouse_event_y_, last_mouse_event_flags_); |
| 89 OnMouseReleased(release_event, true); | 89 OnMouseReleased(release_event, true); |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 | 92 |
| 93 void RootView::ProcessOnMouseExited() { | 93 void RootView::ProcessOnMouseExited() { |
| 94 if (mouse_move_handler_ != NULL) { | 94 if (mouse_move_handler_ != NULL) { |
| 95 MouseEvent exited_event(ui::ET_MOUSE_EXITED, 0, 0, 0); | 95 MouseEvent exited_event(ui::ET_MOUSE_EXITED, 0, 0, 0); |
| 96 mouse_move_handler_->OnMouseExited(exited_event); | 96 mouse_move_handler_->OnMouseExited(exited_event); |
| 97 mouse_move_handler_ = NULL; | 97 mouse_move_handler_ = NULL; |
| 98 } | 98 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 return widget_; | 166 return widget_; |
| 167 } | 167 } |
| 168 | 168 |
| 169 Widget* RootView::GetWidget() { | 169 Widget* RootView::GetWidget() { |
| 170 return const_cast<Widget*>(const_cast<const RootView*>(this)->GetWidget()); | 170 return const_cast<Widget*>(const_cast<const RootView*>(this)->GetWidget()); |
| 171 } | 171 } |
| 172 | 172 |
| 173 bool RootView::OnMousePressed(const MouseEvent& event) { | 173 bool RootView::OnMousePressed(const MouseEvent& event) { |
| 174 MouseEvent e(event, this); | 174 MouseEvent e(event, this); |
| 175 | 175 |
| 176 // This function does not normally handle non-client messages except for | |
| 177 // non-client double-clicks. Actually, all double-clicks are special as the | |
| 178 // are formed from a single-click followed by a double-click event. When the | |
| 179 // double-click event lands on a different view than its single-click part, | |
| 180 // we transform it into a single-click which prevents odd things. | |
| 181 if ((e.flags() & ui::EF_IS_NON_CLIENT) && | |
| 182 !(e.flags() & ui::EF_IS_DOUBLE_CLICK)) { | |
| 183 last_click_handler_ = NULL; | |
| 184 return false; | |
| 185 } | |
| 186 | |
| 187 UpdateCursor(e); | 176 UpdateCursor(e); |
| 188 SetMouseLocationAndFlags(e); | 177 SetMouseLocationAndFlags(e); |
| 189 | 178 |
| 190 // If mouse_pressed_handler_ is non null, we are currently processing | 179 // If mouse_pressed_handler_ is non null, we are currently processing |
| 191 // a pressed -> drag -> released session. In that case we send the | 180 // a pressed -> drag -> released session. In that case we send the |
| 192 // event to mouse_pressed_handler_ | 181 // event to mouse_pressed_handler_ |
| 193 if (mouse_pressed_handler_) { | 182 if (mouse_pressed_handler_) { |
| 194 MouseEvent mouse_pressed_event(e, this, mouse_pressed_handler_); | 183 MouseEvent mouse_pressed_event(e, this, mouse_pressed_handler_); |
| 195 drag_info.Reset(); | 184 drag_info.Reset(); |
| 196 mouse_pressed_handler_->ProcessMousePressed(mouse_pressed_event, | 185 mouse_pressed_handler_->ProcessMousePressed(mouse_pressed_event, |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 widget_->SetCursor(cursor); | 475 widget_->SetCursor(cursor); |
| 487 } | 476 } |
| 488 | 477 |
| 489 void RootView::SetMouseLocationAndFlags(const MouseEvent& e) { | 478 void RootView::SetMouseLocationAndFlags(const MouseEvent& e) { |
| 490 last_mouse_event_flags_ = e.flags(); | 479 last_mouse_event_flags_ = e.flags(); |
| 491 last_mouse_event_x_ = e.x(); | 480 last_mouse_event_x_ = e.x(); |
| 492 last_mouse_event_y_ = e.y(); | 481 last_mouse_event_y_ = e.y(); |
| 493 } | 482 } |
| 494 | 483 |
| 495 } // namespace views | 484 } // namespace views |
| OLD | NEW |