diff options
Diffstat (limited to 'views/widget')
-rw-r--r-- | views/widget/root_view.cc | 84 | ||||
-rw-r--r-- | views/widget/root_view.h | 21 | ||||
-rw-r--r-- | views/widget/widget_gtk.cc | 6 | ||||
-rw-r--r-- | views/widget/widget_win.cc | 13 | ||||
-rw-r--r-- | views/widget/widget_win.h | 2 |
5 files changed, 53 insertions, 73 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 diff --git a/views/widget/root_view.h b/views/widget/root_view.h index d9634b2..3eac199 100644 --- a/views/widget/root_view.h +++ b/views/widget/root_view.h @@ -63,10 +63,6 @@ class RootView : public View, // the system. Invokes OnMouseReleased with a value of true for canceled. void ProcessMouseDragCanceled(); - // Invoked by the Widget instance when the mouse moves outside of the Widget - // bounds. - virtual void ProcessOnMouseExited(); - // Process a key event. Send the event to the focused view and up the focus // path, and finally to the default keyboard handler, until someone consumes // it. Returns whether anyone consumed the event. @@ -106,14 +102,15 @@ class RootView : public View, virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE; virtual const Widget* GetWidget() const OVERRIDE; virtual Widget* GetWidget() OVERRIDE; - virtual bool OnMousePressed(const MouseEvent& e) OVERRIDE; - virtual bool OnMouseDragged(const MouseEvent& e) OVERRIDE; - virtual void OnMouseReleased(const MouseEvent& e, bool canceled) OVERRIDE; - virtual void OnMouseMoved(const MouseEvent& e) OVERRIDE; + virtual void OnMouseExited(const MouseEvent& event) OVERRIDE; + virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; + virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE; + virtual void OnMouseReleased(const MouseEvent& event, bool canceled) OVERRIDE; + virtual void OnMouseMoved(const MouseEvent& event) OVERRIDE; virtual void SetMouseHandler(View* new_mouse_handler) OVERRIDE; - virtual bool OnMouseWheel(const MouseWheelEvent& e) OVERRIDE; + virtual bool OnMouseWheel(const MouseWheelEvent& event) OVERRIDE; #if defined(TOUCH_UI) - virtual TouchStatus OnTouchEvent(const TouchEvent& e) OVERRIDE; + virtual TouchStatus OnTouchEvent(const TouchEvent& event) OVERRIDE; #endif virtual bool IsVisibleInRootView() const OVERRIDE; virtual std::string GetClassName() const OVERRIDE; @@ -148,12 +145,12 @@ class RootView : public View, // cursor during drag operations. The location of the mouse should be in the // current coordinate system (i.e. any necessary transformation should be // applied to the point prior to calling this). - void UpdateCursor(const MouseEvent& e); + void UpdateCursor(const MouseEvent& event); // Updates the last_mouse_* fields from e. The location of the mouse should be // in the current coordinate system (i.e. any necessary transformation should // be applied to the point prior to calling this). - void SetMouseLocationAndFlags(const MouseEvent& e); + void SetMouseLocationAndFlags(const MouseEvent& event); ////////////////////////////////////////////////////////////////////////////// diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc index ec9ef0c..d60a0c9 100644 --- a/views/widget/widget_gtk.cc +++ b/views/widget/widget_gtk.cc @@ -1074,8 +1074,10 @@ gboolean WidgetGtk::OnEnterNotify(GtkWidget* widget, GdkEventCrossing* event) { gboolean WidgetGtk::OnLeaveNotify(GtkWidget* widget, GdkEventCrossing* event) { last_mouse_event_was_move_ = false; - if (!has_capture_ && !is_mouse_down_) - GetRootView()->ProcessOnMouseExited(); + if (!has_capture_ && !is_mouse_down_) { + MouseEvent mouse_event(reinterpret_cast<GdkEvent*>(event)); + GetRootView()->OnMouseExited(mouse_event); + } return false; } diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc index 783c5ca..badb66f 100644 --- a/views/widget/widget_win.cc +++ b/views/widget/widget_win.cc @@ -675,7 +675,7 @@ LRESULT WidgetWin::OnMouseActivate(UINT message, LRESULT WidgetWin::OnMouseLeave(UINT message, WPARAM w_param, LPARAM l_param) { tooltip_manager_->OnMouseLeave(); - ProcessMouseExited(); + ProcessMouseExited(message, w_param, l_param); return 0; } @@ -747,7 +747,7 @@ LRESULT WidgetWin::OnNCHitTest(const CPoint& pt) { LRESULT WidgetWin::OnNCMouseLeave(UINT message, WPARAM w_param, LPARAM l_param) { - ProcessMouseExited(); + ProcessMouseExited(message, w_param, l_param); return 0; } @@ -977,9 +977,14 @@ bool WidgetWin::ProcessMouseMoved(UINT message, return true; } -void WidgetWin::ProcessMouseExited() { +void WidgetWin::ProcessMouseExited(UINT message, + WPARAM w_param, + LPARAM l_param) { last_mouse_event_was_move_ = false; - GetRootView()->ProcessOnMouseExited(); + MSG msg; + MakeMSG(&msg, message, w_param, l_param, 0, GET_X_LPARAM(l_param), + GET_Y_LPARAM(l_param)); + GetRootView()->OnMouseExited(MouseEvent(msg)); // Reset our tracking flag so that future mouse movement over this WidgetWin // results in a new tracking session. active_mouse_tracking_flags_ = 0; diff --git a/views/widget/widget_win.h b/views/widget/widget_win.h index 67816e0..ba78268 100644 --- a/views/widget/widget_win.h +++ b/views/widget/widget_win.h @@ -400,7 +400,7 @@ class WidgetWin : public ui::WindowImpl, bool ProcessMousePressed(UINT message, WPARAM w_param, LPARAM l_param); bool ProcessMouseReleased(UINT message, WPARAM w_param, LPARAM l_param); bool ProcessMouseMoved(UINT message, WPARAM w_param, LPARAM l_param); - void ProcessMouseExited(); + void ProcessMouseExited(UINT message, WPARAM w_param, LPARAM l_param); // Called when a MSAA screen reader client is detected. virtual void OnScreenReaderDetected(); |