diff options
Diffstat (limited to 'views/widget/root_view.cc')
-rw-r--r-- | views/widget/root_view.cc | 84 |
1 files changed, 30 insertions, 54 deletions
diff --git a/views/widget/root_view.cc b/views/widget/root_view.cc index 32805df..0ce608c 100644 --- a/views/widget/root_view.cc +++ b/views/widget/root_view.cc @@ -91,14 +91,6 @@ void RootView::ProcessMouseDragCanceled() { } } -void RootView::ProcessOnMouseExited() { - if (mouse_move_handler_ != NULL) { - MouseEvent exited_event(ui::ET_MOUSE_EXITED, 0, 0, 0); - mouse_move_handler_->OnMouseExited(exited_event); - mouse_move_handler_ = NULL; - } -} - bool RootView::ProcessKeyEvent(const KeyEvent& event) { bool consumed = false; @@ -171,6 +163,13 @@ Widget* RootView::GetWidget() { return const_cast<Widget*>(const_cast<const RootView*>(this)->GetWidget()); } +void RootView::OnMouseExited(const MouseEvent& event) { + if (mouse_move_handler_ != NULL) { + mouse_move_handler_->OnMouseExited(event); + mouse_move_handler_ = NULL; + } +} + bool RootView::OnMousePressed(const MouseEvent& event) { MouseEvent e(event, this); @@ -290,33 +289,20 @@ void RootView::OnMouseMoved(const MouseEvent& event) { v = v->parent(); if (v && v != this) { if (v != mouse_move_handler_) { - if (mouse_move_handler_ != NULL) { - MouseEvent exited_event(ui::ET_MOUSE_EXITED, 0, 0, 0); - mouse_move_handler_->OnMouseExited(exited_event); - } - + if (mouse_move_handler_ != NULL) + mouse_move_handler_->OnMouseExited(e); mouse_move_handler_ = v; - - MouseEvent entered_event(ui::ET_MOUSE_ENTERED, - this, - mouse_move_handler_, - e.location(), - 0); + MouseEvent entered_event(e, this, mouse_move_handler_); mouse_move_handler_->OnMouseEntered(entered_event); } - MouseEvent moved_event(ui::ET_MOUSE_MOVED, - this, - mouse_move_handler_, - e.location(), - 0); + MouseEvent moved_event(e, this, mouse_move_handler_); mouse_move_handler_->OnMouseMoved(moved_event); gfx::NativeCursor cursor = mouse_move_handler_->GetCursorForPoint( moved_event.type(), moved_event.location()); widget_->SetCursor(cursor); } else if (mouse_move_handler_ != NULL) { - MouseEvent exited_event(ui::ET_MOUSE_EXITED, 0, 0, 0); - mouse_move_handler_->OnMouseExited(exited_event); + mouse_move_handler_->OnMouseExited(e); widget_->SetCursor(NULL); } } @@ -435,49 +421,39 @@ void RootView::ViewHierarchyChanged(bool is_add, View* parent, View* child) { // Coordinate conversion ------------------------------------------------------- -bool RootView::ConvertPointToMouseHandler(const gfx::Point& l, - gfx::Point* p) { - // - // If the mouse_handler was set explicitly, we need to keep - // sending events even if it was re-parented in a different - // window. (a non explicit mouse handler is automatically - // cleared when the control is removed from the hierarchy) +bool RootView::ConvertPointToMouseHandler(const gfx::Point& l, gfx::Point* p) { + // If the mouse_handler was set explicitly, keep sending events even if it was + // re-parented in a different window. (a non explicit mouse handler is + // automatically cleared when the control is removed from the hierarchy) + *p = l; if (explicit_mouse_handler_) { - if (mouse_pressed_handler_->GetWidget()) { - *p = l; - ConvertPointToScreen(this, p); + // If the mouse_pressed_handler_ is not connected, we send the + // event in screen coordinate system + ConvertPointToScreen(this, p); + if (mouse_pressed_handler_->GetWidget()) ConvertPointToView(NULL, mouse_pressed_handler_, p); - } else { - // If the mouse_pressed_handler_ is not connected, we send the - // event in screen coordinate system - *p = l; - ConvertPointToScreen(this, p); - return true; - } - } else { - *p = l; + } else ConvertPointToView(this, mouse_pressed_handler_, p); - } return true; } // Input ----------------------------------------------------------------------- -void RootView::UpdateCursor(const MouseEvent& e) { +void RootView::UpdateCursor(const MouseEvent& event) { gfx::NativeCursor cursor = NULL; - View* v = GetEventHandlerForPoint(e.location()); + View* v = GetEventHandlerForPoint(event.location()); if (v && v != this) { - gfx::Point l(e.location()); + gfx::Point l(event.location()); View::ConvertPointToView(this, v, &l); - cursor = v->GetCursorForPoint(e.type(), l); + cursor = v->GetCursorForPoint(event.type(), l); } widget_->SetCursor(cursor); } -void RootView::SetMouseLocationAndFlags(const MouseEvent& e) { - last_mouse_event_flags_ = e.flags(); - last_mouse_event_x_ = e.x(); - last_mouse_event_y_ = e.y(); +void RootView::SetMouseLocationAndFlags(const MouseEvent& event) { + last_mouse_event_flags_ = event.flags(); + last_mouse_event_x_ = event.x(); + last_mouse_event_y_ = event.y(); } } // namespace views |