| Index: views/widget/widget_win.cc
|
| diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc
|
| index 8cde70fec41b88c698eac7180314996e4cad7de7..05d44c9e923e51a9fd69cec1cae81724e0428d9f 100644
|
| --- a/views/widget/widget_win.cc
|
| +++ b/views/widget/widget_win.cc
|
| @@ -408,14 +408,6 @@ TooltipManager* WidgetWin::GetTooltipManager() {
|
| return tooltip_manager_.get();
|
| }
|
|
|
| -void WidgetWin::GenerateMousePressedForView(View* view,
|
| - const gfx::Point& point) {
|
| - gfx::Point point_in_widget(point);
|
| - View::ConvertPointToWidget(view, &point_in_widget);
|
| - GetRootView()->SetMouseHandler(view);
|
| - ProcessMousePressed(point_in_widget.ToPOINT(), MK_LBUTTON, false, false);
|
| -}
|
| -
|
| bool WidgetWin::GetAccelerator(int cmd_id, ui::Accelerator* accelerator) {
|
| return false;
|
| }
|
| @@ -755,44 +747,51 @@ void WidgetWin::OnKillFocus(HWND focused_window) {
|
| SetMsgHandled(FALSE);
|
| }
|
|
|
| -// TODO(pkasting): ORing the pressed/released button into the flags is _wrong_.
|
| -// It makes it impossible to tell which button was modified when multiple
|
| -// buttons are/were held down. We need to instead put the modified button into
|
| -// a separate member on the MouseEvent, then audit all consumers of MouseEvents
|
| -// to fix them to use the resulting values correctly.
|
|
|
| -void WidgetWin::OnLButtonDown(UINT flags, const CPoint& point) {
|
| - ProcessMousePressed(point, flags | MK_LBUTTON, false, false);
|
| +LRESULT WidgetWin::OnLButtonDblClk(UINT message,
|
| + WPARAM w_param,
|
| + LPARAM l_param) {
|
| + ProcessMousePressed(message, w_param, l_param);
|
| + return 0;
|
| }
|
|
|
| -void WidgetWin::OnLButtonUp(UINT flags, const CPoint& point) {
|
| - ProcessMouseReleased(point, flags | MK_LBUTTON);
|
| +LRESULT WidgetWin::OnLButtonDown(UINT message, WPARAM w_param, LPARAM l_param) {
|
| + ProcessMousePressed(message, w_param, l_param);
|
| + return 0;
|
| }
|
|
|
| -void WidgetWin::OnLButtonDblClk(UINT flags, const CPoint& point) {
|
| - ProcessMousePressed(point, flags | MK_LBUTTON, true, false);
|
| +LRESULT WidgetWin::OnLButtonUp(UINT message, WPARAM w_param, LPARAM l_param) {
|
| + ProcessMouseReleased(message, w_param, l_param);
|
| + return 0;
|
| }
|
|
|
| -void WidgetWin::OnMButtonDown(UINT flags, const CPoint& point) {
|
| - ProcessMousePressed(point, flags | MK_MBUTTON, false, false);
|
| +LRESULT WidgetWin::OnMButtonDblClk(UINT message,
|
| + WPARAM w_param,
|
| + LPARAM l_param) {
|
| + ProcessMousePressed(message, w_param, l_param);
|
| + return 0;
|
| }
|
|
|
| -void WidgetWin::OnMButtonUp(UINT flags, const CPoint& point) {
|
| - ProcessMouseReleased(point, flags | MK_MBUTTON);
|
| +LRESULT WidgetWin::OnMButtonDown(UINT message, WPARAM w_param, LPARAM l_param) {
|
| + ProcessMousePressed(message, w_param, l_param);
|
| + return 0;
|
| }
|
|
|
| -void WidgetWin::OnMButtonDblClk(UINT flags, const CPoint& point) {
|
| - ProcessMousePressed(point, flags | MK_MBUTTON, true, false);
|
| +LRESULT WidgetWin::OnMButtonUp(UINT message, WPARAM w_param, LPARAM l_param) {
|
| + ProcessMouseReleased(message, w_param, l_param);
|
| + return 0;
|
| }
|
|
|
| -LRESULT WidgetWin::OnMouseActivate(HWND window, UINT hittest_code,
|
| - UINT message) {
|
| +LRESULT WidgetWin::OnMouseActivate(UINT message,
|
| + WPARAM w_param,
|
| + LPARAM l_param) {
|
| SetMsgHandled(FALSE);
|
| return MA_ACTIVATE;
|
| }
|
|
|
| -void WidgetWin::OnMouseMove(UINT flags, const CPoint& point) {
|
| - ProcessMouseMoved(point, flags, false);
|
| +LRESULT WidgetWin::OnMouseMove(UINT message, WPARAM w_param, LPARAM l_param) {
|
| + ProcessMouseMoved(message, w_param, l_param);
|
| + return 0;
|
| }
|
|
|
| LRESULT WidgetWin::OnMouseLeave(UINT message, WPARAM w_param, LPARAM l_param) {
|
| @@ -843,40 +842,60 @@ LRESULT WidgetWin::OnNCHitTest(const CPoint& pt) {
|
| return 0;
|
| }
|
|
|
| -void WidgetWin::OnNCLButtonDblClk(UINT flags, const CPoint& point) {
|
| - SetMsgHandled(ProcessMousePressed(point, flags | MK_LBUTTON, true, true));
|
| +LRESULT WidgetWin::OnNCLButtonDblClk(UINT message,
|
| + WPARAM w_param,
|
| + LPARAM l_param) {
|
| + SetMsgHandled(ProcessMousePressed(message, w_param, l_param));
|
| + return 0;
|
| }
|
|
|
| -void WidgetWin::OnNCLButtonDown(UINT flags, const CPoint& point) {
|
| - SetMsgHandled(ProcessMousePressed(point, flags | MK_LBUTTON, false, true));
|
| +LRESULT WidgetWin::OnNCLButtonDown(UINT message,
|
| + WPARAM w_param,
|
| + LPARAM l_param) {
|
| + SetMsgHandled(ProcessMousePressed(message, w_param, l_param));
|
| + return 0;
|
| }
|
|
|
| -void WidgetWin::OnNCLButtonUp(UINT flags, const CPoint& point) {
|
| +LRESULT WidgetWin::OnNCLButtonUp(UINT message, WPARAM w_param, LPARAM l_param) {
|
| SetMsgHandled(FALSE);
|
| + return 0;
|
| }
|
|
|
| -void WidgetWin::OnNCMButtonDblClk(UINT flags, const CPoint& point) {
|
| - SetMsgHandled(ProcessMousePressed(point, flags | MK_MBUTTON, true, true));
|
| +LRESULT WidgetWin::OnNCMButtonDblClk(UINT message,
|
| + WPARAM w_param,
|
| + LPARAM l_param) {
|
| + SetMsgHandled(ProcessMousePressed(message, w_param, l_param));
|
| + return 0;
|
| }
|
|
|
| -void WidgetWin::OnNCMButtonDown(UINT flags, const CPoint& point) {
|
| - SetMsgHandled(ProcessMousePressed(point, flags | MK_MBUTTON, false, true));
|
| +LRESULT WidgetWin::OnNCMButtonDown(UINT message,
|
| + WPARAM w_param,
|
| + LPARAM l_param) {
|
| + SetMsgHandled(ProcessMousePressed(message, w_param, l_param));
|
| + return 0;
|
| }
|
|
|
| -void WidgetWin::OnNCMButtonUp(UINT flags, const CPoint& point) {
|
| +LRESULT WidgetWin::OnNCMButtonUp(UINT message,
|
| + WPARAM w_param,
|
| + LPARAM l_param) {
|
| SetMsgHandled(FALSE);
|
| + return 0;
|
| }
|
|
|
| -LRESULT WidgetWin::OnNCMouseLeave(UINT uMsg, WPARAM w_param, LPARAM l_param) {
|
| +LRESULT WidgetWin::OnNCMouseLeave(UINT message,
|
| + WPARAM w_param,
|
| + LPARAM l_param) {
|
| ProcessMouseExited();
|
| return 0;
|
| }
|
|
|
| -LRESULT WidgetWin::OnNCMouseMove(UINT flags, const CPoint& point) {
|
| +LRESULT WidgetWin::OnNCMouseMove(UINT message, WPARAM w_param, LPARAM l_param) {
|
| // NC points are in screen coordinates.
|
| - CPoint temp = point;
|
| - MapWindowPoints(HWND_DESKTOP, hwnd(), &temp, 1);
|
| - ProcessMouseMoved(temp, 0, true);
|
| + // TODO(msw): Ensure point translation is correct. Move into ProcessMouseMoved???
|
| + CPoint point(GET_X_LPARAM(l_param), GET_Y_LPARAM(l_param));
|
| + MapWindowPoints(HWND_DESKTOP, hwnd(), &point, 1);
|
| + l_param = MAKELPARAM(point.x, point.y);
|
| + ProcessMouseMoved(message, w_param, l_param);
|
|
|
| // We need to process this message to stop Windows from drawing the window
|
| // controls as the mouse moves over the title bar area when the window is
|
| @@ -888,16 +907,23 @@ void WidgetWin::OnNCPaint(HRGN rgn) {
|
| SetMsgHandled(FALSE);
|
| }
|
|
|
| -void WidgetWin::OnNCRButtonDblClk(UINT flags, const CPoint& point) {
|
| - SetMsgHandled(ProcessMousePressed(point, flags | MK_RBUTTON, true, true));
|
| +LRESULT WidgetWin::OnNCRButtonDblClk(UINT message,
|
| + WPARAM w_param,
|
| + LPARAM l_param) {
|
| + SetMsgHandled(ProcessMousePressed(message, w_param, l_param));
|
| + return 0;
|
| }
|
|
|
| -void WidgetWin::OnNCRButtonDown(UINT flags, const CPoint& point) {
|
| - SetMsgHandled(ProcessMousePressed(point, flags | MK_RBUTTON, false, true));
|
| +LRESULT WidgetWin::OnNCRButtonDown(UINT message,
|
| + WPARAM w_param,
|
| + LPARAM l_param) {
|
| + SetMsgHandled(ProcessMousePressed(message, w_param, l_param));
|
| + return 0;
|
| }
|
|
|
| -void WidgetWin::OnNCRButtonUp(UINT flags, const CPoint& point) {
|
| +LRESULT WidgetWin::OnNCRButtonUp(UINT message, WPARAM w_param, LPARAM l_param) {
|
| SetMsgHandled(FALSE);
|
| + return 0;
|
| }
|
|
|
| LRESULT WidgetWin::OnNCUAHDrawCaption(UINT msg,
|
| @@ -940,16 +966,20 @@ LRESULT WidgetWin::OnPowerBroadcast(DWORD power_event, DWORD data) {
|
| return 0;
|
| }
|
|
|
| -void WidgetWin::OnRButtonDown(UINT flags, const CPoint& point) {
|
| - ProcessMousePressed(point, flags | MK_RBUTTON, false, false);
|
| +LRESULT WidgetWin::OnRButtonDblClk(UINT message, WPARAM w_param,
|
| + LPARAM l_param) {
|
| + ProcessMousePressed(message, w_param, l_param);
|
| + return 0;
|
| }
|
|
|
| -void WidgetWin::OnRButtonUp(UINT flags, const CPoint& point) {
|
| - ProcessMouseReleased(point, flags | MK_RBUTTON);
|
| +LRESULT WidgetWin::OnRButtonDown(UINT message, WPARAM w_param, LPARAM l_param) {
|
| + ProcessMousePressed(message, w_param, l_param);
|
| + return 0;
|
| }
|
|
|
| -void WidgetWin::OnRButtonDblClk(UINT flags, const CPoint& point) {
|
| - ProcessMousePressed(point, flags | MK_RBUTTON, true, false);
|
| +LRESULT WidgetWin::OnRButtonUp(UINT message, WPARAM w_param, LPARAM l_param) {
|
| + ProcessMouseReleased(message, w_param, l_param);
|
| + return 0;
|
| }
|
|
|
| LRESULT WidgetWin::OnReflectedMessage(UINT msg,
|
| @@ -1048,23 +1078,28 @@ void WidgetWin::TrackMouseEvents(DWORD mouse_tracking_flags) {
|
| }
|
| }
|
|
|
| -bool WidgetWin::ProcessMousePressed(const CPoint& point,
|
| - UINT flags,
|
| - bool dbl_click,
|
| - bool non_client) {
|
| +bool WidgetWin::ProcessMousePressed(UINT message,
|
| + WPARAM w_param,
|
| + LPARAM l_param) {
|
| last_mouse_event_was_move_ = false;
|
| +
|
| + MSG msg;
|
| + MakeMSG(&msg, message, w_param, l_param, 0, GET_X_LPARAM(l_param),
|
| + GET_Y_LPARAM(l_param));
|
| + MouseEvent mouse_pressed(msg);
|
| +
|
| + // TODO(msw): this is awkward... can this pattern be improved?
|
| + // Make a separate ProcessNCMousePressed that translates and then calls this?
|
| // Windows gives screen coordinates for nonclient events, while the RootView
|
| // expects window coordinates; convert if necessary.
|
| - gfx::Point converted_point(point);
|
| - if (non_client)
|
| - View::ConvertPointToView(NULL, GetRootView(), &converted_point);
|
| - MouseEvent mouse_pressed(ui::ET_MOUSE_PRESSED,
|
| - converted_point.x(),
|
| - converted_point.y(),
|
| - (dbl_click ? ui::EF_IS_DOUBLE_CLICK : 0) |
|
| - (non_client ? ui::EF_IS_NON_CLIENT : 0) |
|
| - Event::ConvertWindowsFlags(flags));
|
| - if (GetRootView()->OnMousePressed(mouse_pressed)) {
|
| + bool result = false;
|
| + if (mouse_pressed.flags() & ui::EF_IS_NON_CLIENT)
|
| + result = GetRootView()->OnMousePressed(
|
| + MouseEvent(mouse_pressed, NULL, GetRootView()));
|
| + else
|
| + result = GetRootView()->OnMousePressed(mouse_pressed);
|
| +
|
| + if (result) {
|
| is_mouse_down_ = true;
|
| if (!has_capture_) {
|
| SetCapture();
|
| @@ -1075,21 +1110,22 @@ bool WidgetWin::ProcessMousePressed(const CPoint& point,
|
| return false;
|
| }
|
|
|
| -void WidgetWin::ProcessMouseDragged(const CPoint& point, UINT flags) {
|
| +void WidgetWin::ProcessMouseDragged(UINT message,
|
| + WPARAM w_param,
|
| + LPARAM l_param) {
|
| last_mouse_event_was_move_ = false;
|
| - MouseEvent mouse_drag(ui::ET_MOUSE_DRAGGED,
|
| - point.x,
|
| - point.y,
|
| - Event::ConvertWindowsFlags(flags));
|
| - GetRootView()->OnMouseDragged(mouse_drag);
|
| +
|
| + MSG msg;
|
| + MakeMSG(&msg, message, w_param, l_param, 0, GET_X_LPARAM(l_param),
|
| + GET_Y_LPARAM(l_param));
|
| + GetRootView()->OnMouseDragged(MouseEvent(msg));
|
| }
|
|
|
| -void WidgetWin::ProcessMouseReleased(const CPoint& point, UINT flags) {
|
| +void WidgetWin::ProcessMouseReleased(UINT message,
|
| + WPARAM w_param,
|
| + LPARAM l_param) {
|
| last_mouse_event_was_move_ = false;
|
| - MouseEvent mouse_up(ui::ET_MOUSE_RELEASED,
|
| - point.x,
|
| - point.y,
|
| - Event::ConvertWindowsFlags(flags));
|
| +
|
| // Release the capture first, that way we don't get confused if
|
| // OnMouseReleased blocks.
|
| if (has_capture_ && ReleaseCaptureOnMouseReleased()) {
|
| @@ -1097,34 +1133,47 @@ void WidgetWin::ProcessMouseReleased(const CPoint& point, UINT flags) {
|
| ReleaseCapture();
|
| }
|
| is_mouse_down_ = false;
|
| - GetRootView()->OnMouseReleased(mouse_up, false);
|
| +
|
| + MSG msg;
|
| + MakeMSG(&msg, message, w_param, l_param, 0, GET_X_LPARAM(l_param),
|
| + GET_Y_LPARAM(l_param));
|
| + GetRootView()->OnMouseReleased(MouseEvent(msg), false);
|
| }
|
|
|
| -void WidgetWin::ProcessMouseMoved(const CPoint &point, UINT flags,
|
| - bool is_nonclient) {
|
| +void WidgetWin::ProcessMouseMoved(UINT message,
|
| + WPARAM w_param,
|
| + LPARAM l_param) {
|
| + MSG msg;
|
| + MakeMSG(&msg, message, w_param, l_param, 0, GET_X_LPARAM(l_param),
|
| + GET_Y_LPARAM(l_param));
|
| + MouseEvent mouse_move(msg);
|
| +
|
| // Windows only fires WM_MOUSELEAVE events if the application begins
|
| // "tracking" mouse events for a given HWND during WM_MOUSEMOVE events.
|
| // We need to call |TrackMouseEvents| to listen for WM_MOUSELEAVE.
|
| if (!has_capture_)
|
| - TrackMouseEvents(is_nonclient ? TME_NONCLIENT | TME_LEAVE : TME_LEAVE);
|
| + TrackMouseEvents((mouse_move.flags() & ui::EF_IS_NON_CLIENT) ?
|
| + TME_NONCLIENT | TME_LEAVE : TME_LEAVE);
|
| if (has_capture_ && is_mouse_down_) {
|
| - ProcessMouseDragged(point, flags);
|
| + ProcessMouseDragged(message, w_param, l_param);
|
| } else {
|
| - gfx::Point screen_loc(point);
|
| - View::ConvertPointToScreen(GetRootView(), &screen_loc);
|
| - if (last_mouse_event_was_move_ && last_mouse_move_x_ == screen_loc.x() &&
|
| - last_mouse_move_y_ == screen_loc.y()) {
|
| + if (last_mouse_event_was_move_ && last_mouse_move_x_ == msg.pt.x &&
|
| + last_mouse_move_y_ == msg.pt.y) {
|
| // Don't generate a mouse event for the same location as the last.
|
| return;
|
| }
|
| - last_mouse_move_x_ = screen_loc.x();
|
| - last_mouse_move_y_ = screen_loc.y();
|
| + last_mouse_move_x_ = msg.pt.x;
|
| + last_mouse_move_y_ = msg.pt.y;
|
| +
|
| + // TODO(msw): this is awkward... can this pattern be improved?
|
| + gfx::Point screen_loc(msg.pt.x, msg.pt.y);
|
| + View::ConvertPointToScreen(GetRootView(), &screen_loc);
|
| + msg.pt.x = screen_loc.x();
|
| + msg.pt.y = screen_loc.y();
|
| + msg.lParam = MAKELPARAM(screen_loc.x(), screen_loc.y());
|
| + MouseEvent mouse_move_converted(msg);
|
| last_mouse_event_was_move_ = true;
|
| - MouseEvent mouse_move(ui::ET_MOUSE_MOVED,
|
| - point.x,
|
| - point.y,
|
| - Event::ConvertWindowsFlags(flags));
|
| - GetRootView()->OnMouseMoved(mouse_move);
|
| + GetRootView()->OnMouseMoved(mouse_move_converted);
|
| }
|
| }
|
|
|
|
|