| 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/widget_win.h" | 5 #include "views/widget/widget_win.h" |
| 6 | 6 |
| 7 #include <dwmapi.h> | 7 #include <dwmapi.h> |
| 8 | 8 |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/win/windows_version.h" | 10 #include "base/win/windows_version.h" |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 } | 208 } |
| 209 | 209 |
| 210 void WidgetWin::InitWithWidget(Widget* parent, const gfx::Rect& bounds) { | 210 void WidgetWin::InitWithWidget(Widget* parent, const gfx::Rect& bounds) { |
| 211 Init(parent->GetNativeView(), bounds); | 211 Init(parent->GetNativeView(), bounds); |
| 212 } | 212 } |
| 213 | 213 |
| 214 gfx::NativeView WidgetWin::GetNativeView() const { | 214 gfx::NativeView WidgetWin::GetNativeView() const { |
| 215 return WindowImpl::hwnd(); | 215 return WindowImpl::hwnd(); |
| 216 } | 216 } |
| 217 | 217 |
| 218 void WidgetWin::GenerateMousePressedForView(View* view, | |
| 219 const gfx::Point& point) { | |
| 220 gfx::Point point_in_widget(point); | |
| 221 View::ConvertPointToWidget(view, &point_in_widget); | |
| 222 GetRootView()->SetMouseHandler(view); | |
| 223 ProcessMousePressed(point_in_widget.ToPOINT(), MK_LBUTTON, false, false); | |
| 224 } | |
| 225 | |
| 226 bool WidgetWin::GetAccelerator(int cmd_id, ui::Accelerator* accelerator) { | 218 bool WidgetWin::GetAccelerator(int cmd_id, ui::Accelerator* accelerator) { |
| 227 return false; | 219 return false; |
| 228 } | 220 } |
| 229 | 221 |
| 230 Window* WidgetWin::GetWindow() { | 222 Window* WidgetWin::GetWindow() { |
| 231 return GetWindowImpl(hwnd()); | 223 return GetWindowImpl(hwnd()); |
| 232 } | 224 } |
| 233 | 225 |
| 234 const Window* WidgetWin::GetWindow() const { | 226 const Window* WidgetWin::GetWindow() const { |
| 235 return GetWindowImpl(hwnd()); | 227 return GetWindowImpl(hwnd()); |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 MakeMSG(&msg, message, w_param, l_param); | 648 MakeMSG(&msg, message, w_param, l_param); |
| 657 SetMsgHandled(root_view->ProcessKeyEvent(KeyEvent(msg))); | 649 SetMsgHandled(root_view->ProcessKeyEvent(KeyEvent(msg))); |
| 658 return 0; | 650 return 0; |
| 659 } | 651 } |
| 660 | 652 |
| 661 void WidgetWin::OnKillFocus(HWND focused_window) { | 653 void WidgetWin::OnKillFocus(HWND focused_window) { |
| 662 delegate_->OnNativeBlur(focused_window); | 654 delegate_->OnNativeBlur(focused_window); |
| 663 SetMsgHandled(FALSE); | 655 SetMsgHandled(FALSE); |
| 664 } | 656 } |
| 665 | 657 |
| 666 // TODO(pkasting): ORing the pressed/released button into the flags is _wrong_. | 658 LRESULT WidgetWin::OnMouseActivate(UINT message, |
| 667 // It makes it impossible to tell which button was modified when multiple | 659 WPARAM w_param, |
| 668 // buttons are/were held down. We need to instead put the modified button into | 660 LPARAM l_param) { |
| 669 // a separate member on the MouseEvent, then audit all consumers of MouseEvents | |
| 670 // to fix them to use the resulting values correctly. | |
| 671 | |
| 672 void WidgetWin::OnLButtonDown(UINT flags, const CPoint& point) { | |
| 673 ProcessMousePressed(point, flags | MK_LBUTTON, false, false); | |
| 674 } | |
| 675 | |
| 676 void WidgetWin::OnLButtonUp(UINT flags, const CPoint& point) { | |
| 677 ProcessMouseReleased(point, flags | MK_LBUTTON); | |
| 678 } | |
| 679 | |
| 680 void WidgetWin::OnLButtonDblClk(UINT flags, const CPoint& point) { | |
| 681 ProcessMousePressed(point, flags | MK_LBUTTON, true, false); | |
| 682 } | |
| 683 | |
| 684 void WidgetWin::OnMButtonDown(UINT flags, const CPoint& point) { | |
| 685 ProcessMousePressed(point, flags | MK_MBUTTON, false, false); | |
| 686 } | |
| 687 | |
| 688 void WidgetWin::OnMButtonUp(UINT flags, const CPoint& point) { | |
| 689 ProcessMouseReleased(point, flags | MK_MBUTTON); | |
| 690 } | |
| 691 | |
| 692 void WidgetWin::OnMButtonDblClk(UINT flags, const CPoint& point) { | |
| 693 ProcessMousePressed(point, flags | MK_MBUTTON, true, false); | |
| 694 } | |
| 695 | |
| 696 LRESULT WidgetWin::OnMouseActivate(HWND window, UINT hittest_code, | |
| 697 UINT message) { | |
| 698 SetMsgHandled(FALSE); | 661 SetMsgHandled(FALSE); |
| 699 return MA_ACTIVATE; | 662 return MA_ACTIVATE; |
| 700 } | 663 } |
| 701 | 664 |
| 702 void WidgetWin::OnMouseMove(UINT flags, const CPoint& point) { | |
| 703 ProcessMouseMoved(point, flags, false); | |
| 704 } | |
| 705 | |
| 706 LRESULT WidgetWin::OnMouseLeave(UINT message, WPARAM w_param, LPARAM l_param) { | 665 LRESULT WidgetWin::OnMouseLeave(UINT message, WPARAM w_param, LPARAM l_param) { |
| 707 tooltip_manager_->OnMouseLeave(); | 666 tooltip_manager_->OnMouseLeave(); |
| 708 ProcessMouseExited(); | 667 ProcessMouseExited(); |
| 709 return 0; | 668 return 0; |
| 710 } | 669 } |
| 711 | 670 |
| 671 LRESULT WidgetWin::OnMouseMove(UINT message, WPARAM w_param, LPARAM l_param) { |
| 672 ProcessMouseMoved(message, w_param, l_param); |
| 673 return 0; |
| 674 } |
| 675 |
| 676 LRESULT WidgetWin::OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param) { |
| 677 tooltip_manager_->OnMouse(message, w_param, l_param); |
| 678 |
| 679 switch (message) { |
| 680 case WM_LBUTTONDBLCLK: |
| 681 case WM_LBUTTONDOWN: |
| 682 case WM_MBUTTONDBLCLK: |
| 683 case WM_MBUTTONDOWN: |
| 684 case WM_RBUTTONDBLCLK: |
| 685 case WM_RBUTTONDOWN: |
| 686 SetMsgHandled(ProcessMousePressed(message, w_param, l_param)); |
| 687 break; |
| 688 case WM_LBUTTONUP: |
| 689 case WM_MBUTTONUP: |
| 690 case WM_RBUTTONUP: |
| 691 SetMsgHandled(ProcessMouseReleased(message, w_param, l_param)); |
| 692 break; |
| 693 default: |
| 694 SetMsgHandled(FALSE); |
| 695 } |
| 696 |
| 697 return 0; |
| 698 } |
| 699 |
| 712 LRESULT WidgetWin::OnMouseWheel(UINT message, WPARAM w_param, LPARAM l_param) { | 700 LRESULT WidgetWin::OnMouseWheel(UINT message, WPARAM w_param, LPARAM l_param) { |
| 713 // Reroute the mouse-wheel to the window under the mouse pointer if | 701 // Reroute the mouse-wheel to the window under the mouse pointer if |
| 714 // applicable. | 702 // applicable. |
| 715 if (message == WM_MOUSEWHEEL && | 703 if (message == WM_MOUSEWHEEL && |
| 716 views::RerouteMouseWheel(hwnd(), w_param, l_param)) { | 704 views::RerouteMouseWheel(hwnd(), w_param, l_param)) { |
| 717 return 0; | 705 return 0; |
| 718 } | 706 } |
| 719 | 707 |
| 720 MSG msg; | 708 MSG msg; |
| 721 MakeMSG(&msg, message, w_param, l_param, 0, | 709 MakeMSG(&msg, message, w_param, l_param, 0, |
| 722 GET_X_LPARAM(l_param), GET_Y_LPARAM(l_param)); | 710 GET_X_LPARAM(l_param), GET_Y_LPARAM(l_param)); |
| 723 return GetRootView()->OnMouseWheel(MouseWheelEvent(msg)) ? 0 : 1; | 711 return GetRootView()->OnMouseWheel(MouseWheelEvent(msg)) ? 0 : 1; |
| 724 } | 712 } |
| 725 | 713 |
| 726 void WidgetWin::OnMove(const CPoint& point) { | 714 void WidgetWin::OnMove(const CPoint& point) { |
| 727 SetMsgHandled(FALSE); | 715 SetMsgHandled(FALSE); |
| 728 } | 716 } |
| 729 | 717 |
| 730 void WidgetWin::OnMoving(UINT param, const LPRECT new_bounds) { | 718 void WidgetWin::OnMoving(UINT param, const LPRECT new_bounds) { |
| 731 } | 719 } |
| 732 | 720 |
| 733 LRESULT WidgetWin::OnMouseRange(UINT msg, WPARAM w_param, LPARAM l_param) { | |
| 734 tooltip_manager_->OnMouse(msg, w_param, l_param); | |
| 735 SetMsgHandled(FALSE); | |
| 736 return 0; | |
| 737 } | |
| 738 | |
| 739 LRESULT WidgetWin::OnNCActivate(BOOL active) { | 721 LRESULT WidgetWin::OnNCActivate(BOOL active) { |
| 740 SetMsgHandled(FALSE); | 722 SetMsgHandled(FALSE); |
| 741 return 0; | 723 return 0; |
| 742 } | 724 } |
| 743 | 725 |
| 744 LRESULT WidgetWin::OnNCCalcSize(BOOL w_param, LPARAM l_param) { | 726 LRESULT WidgetWin::OnNCCalcSize(BOOL w_param, LPARAM l_param) { |
| 745 SetMsgHandled(FALSE); | 727 SetMsgHandled(FALSE); |
| 746 return 0; | 728 return 0; |
| 747 } | 729 } |
| 748 | 730 |
| 749 LRESULT WidgetWin::OnNCHitTest(const CPoint& pt) { | 731 LRESULT WidgetWin::OnNCHitTest(const CPoint& pt) { |
| 750 SetMsgHandled(FALSE); | 732 SetMsgHandled(FALSE); |
| 751 return 0; | 733 return 0; |
| 752 } | 734 } |
| 753 | 735 |
| 754 void WidgetWin::OnNCLButtonDblClk(UINT flags, const CPoint& point) { | 736 LRESULT WidgetWin::OnNCMouseLeave(UINT message, |
| 755 SetMsgHandled(ProcessMousePressed(point, flags | MK_LBUTTON, true, true)); | 737 WPARAM w_param, |
| 756 } | 738 LPARAM l_param) { |
| 757 | |
| 758 void WidgetWin::OnNCLButtonDown(UINT flags, const CPoint& point) { | |
| 759 SetMsgHandled(ProcessMousePressed(point, flags | MK_LBUTTON, false, true)); | |
| 760 } | |
| 761 | |
| 762 void WidgetWin::OnNCLButtonUp(UINT flags, const CPoint& point) { | |
| 763 SetMsgHandled(FALSE); | |
| 764 } | |
| 765 | |
| 766 void WidgetWin::OnNCMButtonDblClk(UINT flags, const CPoint& point) { | |
| 767 SetMsgHandled(ProcessMousePressed(point, flags | MK_MBUTTON, true, true)); | |
| 768 } | |
| 769 | |
| 770 void WidgetWin::OnNCMButtonDown(UINT flags, const CPoint& point) { | |
| 771 SetMsgHandled(ProcessMousePressed(point, flags | MK_MBUTTON, false, true)); | |
| 772 } | |
| 773 | |
| 774 void WidgetWin::OnNCMButtonUp(UINT flags, const CPoint& point) { | |
| 775 SetMsgHandled(FALSE); | |
| 776 } | |
| 777 | |
| 778 LRESULT WidgetWin::OnNCMouseLeave(UINT uMsg, WPARAM w_param, LPARAM l_param) { | |
| 779 ProcessMouseExited(); | 739 ProcessMouseExited(); |
| 780 return 0; | 740 return 0; |
| 781 } | 741 } |
| 782 | 742 |
| 783 LRESULT WidgetWin::OnNCMouseMove(UINT flags, const CPoint& point) { | 743 LRESULT WidgetWin::OnNCMouseMove(UINT message, WPARAM w_param, LPARAM l_param) { |
| 784 // NC points are in screen coordinates. | 744 tooltip_manager_->OnMouse(message, w_param, l_param); |
| 785 CPoint temp = point; | 745 ProcessMouseMoved(message, w_param, l_param); |
| 786 MapWindowPoints(HWND_DESKTOP, hwnd(), &temp, 1); | |
| 787 ProcessMouseMoved(temp, 0, true); | |
| 788 | 746 |
| 789 // We need to process this message to stop Windows from drawing the window | 747 // We need to process this message to stop Windows from drawing the window |
| 790 // controls as the mouse moves over the title bar area when the window is | 748 // controls as the mouse moves over the title bar area when the window is |
| 791 // maximized. | 749 // maximized. |
| 792 return 0; | 750 return 0; |
| 793 } | 751 } |
| 794 | 752 |
| 753 LRESULT WidgetWin::OnNCMouseRange(UINT message, |
| 754 WPARAM w_param, |
| 755 LPARAM l_param) { |
| 756 switch (message) { |
| 757 case WM_NCLBUTTONDBLCLK: |
| 758 case WM_NCLBUTTONDOWN: |
| 759 case WM_NCMBUTTONDBLCLK: |
| 760 case WM_NCMBUTTONDOWN: |
| 761 case WM_NCRBUTTONDBLCLK: |
| 762 case WM_NCRBUTTONDOWN: |
| 763 SetMsgHandled(ProcessMousePressed(message, w_param, l_param)); |
| 764 break; |
| 765 case WM_NCLBUTTONUP: |
| 766 case WM_NCMBUTTONUP: |
| 767 case WM_NCRBUTTONUP: |
| 768 default: |
| 769 SetMsgHandled(FALSE); |
| 770 } |
| 771 |
| 772 return 0; |
| 773 } |
| 774 |
| 795 void WidgetWin::OnNCPaint(HRGN rgn) { | 775 void WidgetWin::OnNCPaint(HRGN rgn) { |
| 796 SetMsgHandled(FALSE); | 776 SetMsgHandled(FALSE); |
| 797 } | 777 } |
| 798 | 778 |
| 799 void WidgetWin::OnNCRButtonDblClk(UINT flags, const CPoint& point) { | |
| 800 SetMsgHandled(ProcessMousePressed(point, flags | MK_RBUTTON, true, true)); | |
| 801 } | |
| 802 | |
| 803 void WidgetWin::OnNCRButtonDown(UINT flags, const CPoint& point) { | |
| 804 SetMsgHandled(ProcessMousePressed(point, flags | MK_RBUTTON, false, true)); | |
| 805 } | |
| 806 | |
| 807 void WidgetWin::OnNCRButtonUp(UINT flags, const CPoint& point) { | |
| 808 SetMsgHandled(FALSE); | |
| 809 } | |
| 810 | |
| 811 LRESULT WidgetWin::OnNCUAHDrawCaption(UINT msg, | 779 LRESULT WidgetWin::OnNCUAHDrawCaption(UINT msg, |
| 812 WPARAM w_param, | 780 WPARAM w_param, |
| 813 LPARAM l_param) { | 781 LPARAM l_param) { |
| 814 SetMsgHandled(FALSE); | 782 SetMsgHandled(FALSE); |
| 815 return 0; | 783 return 0; |
| 816 } | 784 } |
| 817 | 785 |
| 818 LRESULT WidgetWin::OnNCUAHDrawFrame(UINT msg, WPARAM w_param, LPARAM l_param) { | 786 LRESULT WidgetWin::OnNCUAHDrawFrame(UINT msg, WPARAM w_param, LPARAM l_param) { |
| 819 SetMsgHandled(FALSE); | 787 SetMsgHandled(FALSE); |
| 820 return 0; | 788 return 0; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 841 } | 809 } |
| 842 | 810 |
| 843 LRESULT WidgetWin::OnPowerBroadcast(DWORD power_event, DWORD data) { | 811 LRESULT WidgetWin::OnPowerBroadcast(DWORD power_event, DWORD data) { |
| 844 ui::SystemMonitor* monitor = ui::SystemMonitor::Get(); | 812 ui::SystemMonitor* monitor = ui::SystemMonitor::Get(); |
| 845 if (monitor) | 813 if (monitor) |
| 846 monitor->ProcessWmPowerBroadcastMessage(power_event); | 814 monitor->ProcessWmPowerBroadcastMessage(power_event); |
| 847 SetMsgHandled(FALSE); | 815 SetMsgHandled(FALSE); |
| 848 return 0; | 816 return 0; |
| 849 } | 817 } |
| 850 | 818 |
| 851 void WidgetWin::OnRButtonDown(UINT flags, const CPoint& point) { | |
| 852 ProcessMousePressed(point, flags | MK_RBUTTON, false, false); | |
| 853 } | |
| 854 | |
| 855 void WidgetWin::OnRButtonUp(UINT flags, const CPoint& point) { | |
| 856 ProcessMouseReleased(point, flags | MK_RBUTTON); | |
| 857 } | |
| 858 | |
| 859 void WidgetWin::OnRButtonDblClk(UINT flags, const CPoint& point) { | |
| 860 ProcessMousePressed(point, flags | MK_RBUTTON, true, false); | |
| 861 } | |
| 862 | |
| 863 LRESULT WidgetWin::OnReflectedMessage(UINT msg, | 819 LRESULT WidgetWin::OnReflectedMessage(UINT msg, |
| 864 WPARAM w_param, | 820 WPARAM w_param, |
| 865 LPARAM l_param) { | 821 LPARAM l_param) { |
| 866 SetMsgHandled(FALSE); | 822 SetMsgHandled(FALSE); |
| 867 return 0; | 823 return 0; |
| 868 } | 824 } |
| 869 | 825 |
| 870 void WidgetWin::OnSetFocus(HWND focused_window) { | 826 void WidgetWin::OnSetFocus(HWND focused_window) { |
| 871 delegate_->OnNativeFocus(focused_window); | 827 delegate_->OnNativeFocus(focused_window); |
| 872 SetMsgHandled(FALSE); | 828 SetMsgHandled(FALSE); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 939 tme.dwFlags = mouse_tracking_flags; | 895 tme.dwFlags = mouse_tracking_flags; |
| 940 tme.hwndTrack = hwnd(); | 896 tme.hwndTrack = hwnd(); |
| 941 tme.dwHoverTime = 0; | 897 tme.dwHoverTime = 0; |
| 942 TrackMouseEvent(&tme); | 898 TrackMouseEvent(&tme); |
| 943 } else if (mouse_tracking_flags != active_mouse_tracking_flags_) { | 899 } else if (mouse_tracking_flags != active_mouse_tracking_flags_) { |
| 944 TrackMouseEvents(active_mouse_tracking_flags_ | TME_CANCEL); | 900 TrackMouseEvents(active_mouse_tracking_flags_ | TME_CANCEL); |
| 945 TrackMouseEvents(mouse_tracking_flags); | 901 TrackMouseEvents(mouse_tracking_flags); |
| 946 } | 902 } |
| 947 } | 903 } |
| 948 | 904 |
| 949 bool WidgetWin::ProcessMousePressed(const CPoint& point, | 905 bool WidgetWin::ProcessMousePressed(UINT message, |
| 950 UINT flags, | 906 WPARAM w_param, |
| 951 bool dbl_click, | 907 LPARAM l_param) { |
| 952 bool non_client) { | |
| 953 last_mouse_event_was_move_ = false; | 908 last_mouse_event_was_move_ = false; |
| 954 // Windows gives screen coordinates for nonclient events, while the RootView | 909 |
| 955 // expects window coordinates; convert if necessary. | 910 MSG msg; |
| 956 gfx::Point converted_point(point); | 911 MakeMSG(&msg, message, w_param, l_param, 0, GET_X_LPARAM(l_param), |
| 957 if (non_client) | 912 GET_Y_LPARAM(l_param)); |
| 958 View::ConvertPointToView(NULL, GetRootView(), &converted_point); | 913 if (GetRootView()->OnMousePressed(MouseEvent(msg))) { |
| 959 MouseEvent mouse_pressed(ui::ET_MOUSE_PRESSED, | |
| 960 converted_point.x(), | |
| 961 converted_point.y(), | |
| 962 (dbl_click ? ui::EF_IS_DOUBLE_CLICK : 0) | | |
| 963 (non_client ? ui::EF_IS_NON_CLIENT : 0) | | |
| 964 Event::ConvertWindowsFlags(flags)); | |
| 965 if (GetRootView()->OnMousePressed(mouse_pressed)) { | |
| 966 is_mouse_down_ = true; | 914 is_mouse_down_ = true; |
| 967 if (!has_capture_) { | 915 if (!has_capture_) { |
| 968 SetCapture(); | 916 SetCapture(); |
| 969 has_capture_ = true; | 917 has_capture_ = true; |
| 970 } | 918 } |
| 971 return true; | 919 return true; |
| 972 } | 920 } |
| 973 return false; | 921 return false; |
| 974 } | 922 } |
| 975 | 923 |
| 976 void WidgetWin::ProcessMouseDragged(const CPoint& point, UINT flags) { | 924 bool WidgetWin::ProcessMouseReleased(UINT message, |
| 925 WPARAM w_param, |
| 926 LPARAM l_param) { |
| 977 last_mouse_event_was_move_ = false; | 927 last_mouse_event_was_move_ = false; |
| 978 MouseEvent mouse_drag(ui::ET_MOUSE_DRAGGED, | |
| 979 point.x, | |
| 980 point.y, | |
| 981 Event::ConvertWindowsFlags(flags)); | |
| 982 GetRootView()->OnMouseDragged(mouse_drag); | |
| 983 } | |
| 984 | 928 |
| 985 void WidgetWin::ProcessMouseReleased(const CPoint& point, UINT flags) { | |
| 986 last_mouse_event_was_move_ = false; | |
| 987 MouseEvent mouse_up(ui::ET_MOUSE_RELEASED, | |
| 988 point.x, | |
| 989 point.y, | |
| 990 Event::ConvertWindowsFlags(flags)); | |
| 991 // Release the capture first, that way we don't get confused if | 929 // Release the capture first, that way we don't get confused if |
| 992 // OnMouseReleased blocks. | 930 // OnMouseReleased blocks. |
| 993 if (has_capture_ && ReleaseCaptureOnMouseReleased()) { | 931 if (has_capture_ && ReleaseCaptureOnMouseReleased()) { |
| 994 has_capture_ = false; | 932 has_capture_ = false; |
| 995 ReleaseCapture(); | 933 ReleaseCapture(); |
| 996 } | 934 } |
| 997 is_mouse_down_ = false; | 935 is_mouse_down_ = false; |
| 998 GetRootView()->OnMouseReleased(mouse_up, false); | 936 |
| 937 MSG msg; |
| 938 MakeMSG(&msg, message, w_param, l_param, 0, GET_X_LPARAM(l_param), |
| 939 GET_Y_LPARAM(l_param)); |
| 940 GetRootView()->OnMouseReleased(MouseEvent(msg), false); |
| 941 return true; |
| 999 } | 942 } |
| 1000 | 943 |
| 1001 void WidgetWin::ProcessMouseMoved(const CPoint &point, UINT flags, | 944 bool WidgetWin::ProcessMouseMoved(UINT message, |
| 1002 bool is_nonclient) { | 945 WPARAM w_param, |
| 946 LPARAM l_param) { |
| 1003 // Windows only fires WM_MOUSELEAVE events if the application begins | 947 // Windows only fires WM_MOUSELEAVE events if the application begins |
| 1004 // "tracking" mouse events for a given HWND during WM_MOUSEMOVE events. | 948 // "tracking" mouse events for a given HWND during WM_MOUSEMOVE events. |
| 1005 // We need to call |TrackMouseEvents| to listen for WM_MOUSELEAVE. | 949 // We need to call |TrackMouseEvents| to listen for WM_MOUSELEAVE. |
| 1006 if (!has_capture_) | 950 if (!has_capture_) |
| 1007 TrackMouseEvents(is_nonclient ? TME_NONCLIENT | TME_LEAVE : TME_LEAVE); | 951 TrackMouseEvents((message == WM_NCMOUSEMOVE) ? |
| 1008 if (has_capture_ && is_mouse_down_) { | 952 TME_NONCLIENT | TME_LEAVE : TME_LEAVE); |
| 1009 ProcessMouseDragged(point, flags); | 953 MSG msg; |
| 1010 } else { | 954 MakeMSG(&msg, message, w_param, l_param, 0, GET_X_LPARAM(l_param), |
| 1011 gfx::Point screen_loc(point); | 955 GET_Y_LPARAM(l_param)); |
| 1012 View::ConvertPointToScreen(GetRootView(), &screen_loc); | 956 if (has_capture_ && is_mouse_down_) |
| 1013 if (last_mouse_event_was_move_ && last_mouse_move_x_ == screen_loc.x() && | 957 GetRootView()->OnMouseDragged(MouseEvent(msg)); |
| 1014 last_mouse_move_y_ == screen_loc.y()) { | 958 else if (!last_mouse_event_was_move_ || |
| 1015 // Don't generate a mouse event for the same location as the last. | 959 (last_mouse_move_x_ != GET_X_LPARAM(l_param) && |
| 1016 return; | 960 last_mouse_move_y_ != GET_Y_LPARAM(l_param))) { |
| 1017 } | 961 last_mouse_move_x_ = GET_X_LPARAM(l_param); |
| 1018 last_mouse_move_x_ = screen_loc.x(); | 962 last_mouse_move_y_ = GET_Y_LPARAM(l_param); |
| 1019 last_mouse_move_y_ = screen_loc.y(); | |
| 1020 last_mouse_event_was_move_ = true; | 963 last_mouse_event_was_move_ = true; |
| 1021 MouseEvent mouse_move(ui::ET_MOUSE_MOVED, | 964 GetRootView()->OnMouseMoved(MouseEvent(msg)); |
| 1022 point.x, | |
| 1023 point.y, | |
| 1024 Event::ConvertWindowsFlags(flags)); | |
| 1025 GetRootView()->OnMouseMoved(mouse_move); | |
| 1026 } | 965 } |
| 966 return true; |
| 1027 } | 967 } |
| 1028 | 968 |
| 1029 void WidgetWin::ProcessMouseExited() { | 969 void WidgetWin::ProcessMouseExited() { |
| 1030 last_mouse_event_was_move_ = false; | 970 last_mouse_event_was_move_ = false; |
| 1031 GetRootView()->ProcessOnMouseExited(); | 971 GetRootView()->ProcessOnMouseExited(); |
| 1032 // Reset our tracking flag so that future mouse movement over this WidgetWin | 972 // Reset our tracking flag so that future mouse movement over this WidgetWin |
| 1033 // results in a new tracking session. | 973 // results in a new tracking session. |
| 1034 active_mouse_tracking_flags_ = 0; | 974 active_mouse_tracking_flags_ = 0; |
| 1035 } | 975 } |
| 1036 | 976 |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1240 return; | 1180 return; |
| 1241 | 1181 |
| 1242 NativeWidget* native_widget = GetNativeWidgetForNativeView(native_view); | 1182 NativeWidget* native_widget = GetNativeWidgetForNativeView(native_view); |
| 1243 if (native_widget) | 1183 if (native_widget) |
| 1244 children->insert(native_widget); | 1184 children->insert(native_widget); |
| 1245 EnumChildWindows(native_view, EnumerateChildWindowsForNativeWidgets, | 1185 EnumChildWindows(native_view, EnumerateChildWindowsForNativeWidgets, |
| 1246 reinterpret_cast<LPARAM>(children)); | 1186 reinterpret_cast<LPARAM>(children)); |
| 1247 } | 1187 } |
| 1248 | 1188 |
| 1249 } // namespace views | 1189 } // namespace views |
| OLD | NEW |