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 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 } | 401 } |
402 | 402 |
403 bool WidgetWin::IsAccessibleWidget() const { | 403 bool WidgetWin::IsAccessibleWidget() const { |
404 return screen_reader_active_; | 404 return screen_reader_active_; |
405 } | 405 } |
406 | 406 |
407 TooltipManager* WidgetWin::GetTooltipManager() { | 407 TooltipManager* WidgetWin::GetTooltipManager() { |
408 return tooltip_manager_.get(); | 408 return tooltip_manager_.get(); |
409 } | 409 } |
410 | 410 |
411 void WidgetWin::GenerateMousePressedForView(View* view, | |
412 const gfx::Point& point) { | |
413 gfx::Point point_in_widget(point); | |
414 View::ConvertPointToWidget(view, &point_in_widget); | |
415 GetRootView()->SetMouseHandler(view); | |
416 ProcessMousePressed(point_in_widget.ToPOINT(), MK_LBUTTON, false, false); | |
417 } | |
418 | |
419 bool WidgetWin::GetAccelerator(int cmd_id, ui::Accelerator* accelerator) { | 411 bool WidgetWin::GetAccelerator(int cmd_id, ui::Accelerator* accelerator) { |
420 return false; | 412 return false; |
421 } | 413 } |
422 | 414 |
423 Window* WidgetWin::GetWindow() { | 415 Window* WidgetWin::GetWindow() { |
424 return GetWindowImpl(hwnd()); | 416 return GetWindowImpl(hwnd()); |
425 } | 417 } |
426 | 418 |
427 const Window* WidgetWin::GetWindow() const { | 419 const Window* WidgetWin::GetWindow() const { |
428 return GetWindowImpl(hwnd()); | 420 return GetWindowImpl(hwnd()); |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 return 0; | 740 return 0; |
749 } | 741 } |
750 | 742 |
751 void WidgetWin::OnKillFocus(HWND focused_window) { | 743 void WidgetWin::OnKillFocus(HWND focused_window) { |
752 GetFocusManager()->GetWidgetFocusManager()->OnWidgetFocusEvent( | 744 GetFocusManager()->GetWidgetFocusManager()->OnWidgetFocusEvent( |
753 this->GetNativeView(), | 745 this->GetNativeView(), |
754 focused_window); | 746 focused_window); |
755 SetMsgHandled(FALSE); | 747 SetMsgHandled(FALSE); |
756 } | 748 } |
757 | 749 |
758 // TODO(pkasting): ORing the pressed/released button into the flags is _wrong_. | |
759 // It makes it impossible to tell which button was modified when multiple | |
760 // buttons are/were held down. We need to instead put the modified button into | |
761 // a separate member on the MouseEvent, then audit all consumers of MouseEvents | |
762 // to fix them to use the resulting values correctly. | |
763 | 750 |
764 void WidgetWin::OnLButtonDown(UINT flags, const CPoint& point) { | 751 LRESULT WidgetWin::OnLButtonDblClk(UINT message, |
765 ProcessMousePressed(point, flags | MK_LBUTTON, false, false); | 752 WPARAM w_param, |
| 753 LPARAM l_param) { |
| 754 ProcessMousePressed(message, w_param, l_param); |
| 755 return 0; |
766 } | 756 } |
767 | 757 |
768 void WidgetWin::OnLButtonUp(UINT flags, const CPoint& point) { | 758 LRESULT WidgetWin::OnLButtonDown(UINT message, WPARAM w_param, LPARAM l_param) { |
769 ProcessMouseReleased(point, flags | MK_LBUTTON); | 759 ProcessMousePressed(message, w_param, l_param); |
| 760 return 0; |
770 } | 761 } |
771 | 762 |
772 void WidgetWin::OnLButtonDblClk(UINT flags, const CPoint& point) { | 763 LRESULT WidgetWin::OnLButtonUp(UINT message, WPARAM w_param, LPARAM l_param) { |
773 ProcessMousePressed(point, flags | MK_LBUTTON, true, false); | 764 ProcessMouseReleased(message, w_param, l_param); |
| 765 return 0; |
774 } | 766 } |
775 | 767 |
776 void WidgetWin::OnMButtonDown(UINT flags, const CPoint& point) { | 768 LRESULT WidgetWin::OnMButtonDblClk(UINT message, |
777 ProcessMousePressed(point, flags | MK_MBUTTON, false, false); | 769 WPARAM w_param, |
| 770 LPARAM l_param) { |
| 771 ProcessMousePressed(message, w_param, l_param); |
| 772 return 0; |
778 } | 773 } |
779 | 774 |
780 void WidgetWin::OnMButtonUp(UINT flags, const CPoint& point) { | 775 LRESULT WidgetWin::OnMButtonDown(UINT message, WPARAM w_param, LPARAM l_param) { |
781 ProcessMouseReleased(point, flags | MK_MBUTTON); | 776 ProcessMousePressed(message, w_param, l_param); |
| 777 return 0; |
782 } | 778 } |
783 | 779 |
784 void WidgetWin::OnMButtonDblClk(UINT flags, const CPoint& point) { | 780 LRESULT WidgetWin::OnMButtonUp(UINT message, WPARAM w_param, LPARAM l_param) { |
785 ProcessMousePressed(point, flags | MK_MBUTTON, true, false); | 781 ProcessMouseReleased(message, w_param, l_param); |
| 782 return 0; |
786 } | 783 } |
787 | 784 |
788 LRESULT WidgetWin::OnMouseActivate(HWND window, UINT hittest_code, | 785 LRESULT WidgetWin::OnMouseActivate(UINT message, |
789 UINT message) { | 786 WPARAM w_param, |
| 787 LPARAM l_param) { |
790 SetMsgHandled(FALSE); | 788 SetMsgHandled(FALSE); |
791 return MA_ACTIVATE; | 789 return MA_ACTIVATE; |
792 } | 790 } |
793 | 791 |
794 void WidgetWin::OnMouseMove(UINT flags, const CPoint& point) { | 792 LRESULT WidgetWin::OnMouseMove(UINT message, WPARAM w_param, LPARAM l_param) { |
795 ProcessMouseMoved(point, flags, false); | 793 ProcessMouseMoved(message, w_param, l_param); |
| 794 return 0; |
796 } | 795 } |
797 | 796 |
798 LRESULT WidgetWin::OnMouseLeave(UINT message, WPARAM w_param, LPARAM l_param) { | 797 LRESULT WidgetWin::OnMouseLeave(UINT message, WPARAM w_param, LPARAM l_param) { |
799 tooltip_manager_->OnMouseLeave(); | 798 tooltip_manager_->OnMouseLeave(); |
800 ProcessMouseExited(); | 799 ProcessMouseExited(); |
801 return 0; | 800 return 0; |
802 } | 801 } |
803 | 802 |
804 LRESULT WidgetWin::OnMouseWheel(UINT message, WPARAM w_param, LPARAM l_param) { | 803 LRESULT WidgetWin::OnMouseWheel(UINT message, WPARAM w_param, LPARAM l_param) { |
805 // Reroute the mouse-wheel to the window under the mouse pointer if | 804 // Reroute the mouse-wheel to the window under the mouse pointer if |
(...skipping 30 matching lines...) Expand all Loading... |
836 LRESULT WidgetWin::OnNCCalcSize(BOOL w_param, LPARAM l_param) { | 835 LRESULT WidgetWin::OnNCCalcSize(BOOL w_param, LPARAM l_param) { |
837 SetMsgHandled(FALSE); | 836 SetMsgHandled(FALSE); |
838 return 0; | 837 return 0; |
839 } | 838 } |
840 | 839 |
841 LRESULT WidgetWin::OnNCHitTest(const CPoint& pt) { | 840 LRESULT WidgetWin::OnNCHitTest(const CPoint& pt) { |
842 SetMsgHandled(FALSE); | 841 SetMsgHandled(FALSE); |
843 return 0; | 842 return 0; |
844 } | 843 } |
845 | 844 |
846 void WidgetWin::OnNCLButtonDblClk(UINT flags, const CPoint& point) { | 845 LRESULT WidgetWin::OnNCLButtonDblClk(UINT message, |
847 SetMsgHandled(ProcessMousePressed(point, flags | MK_LBUTTON, true, true)); | 846 WPARAM w_param, |
| 847 LPARAM l_param) { |
| 848 SetMsgHandled(ProcessMousePressed(message, w_param, l_param)); |
| 849 return 0; |
848 } | 850 } |
849 | 851 |
850 void WidgetWin::OnNCLButtonDown(UINT flags, const CPoint& point) { | 852 LRESULT WidgetWin::OnNCLButtonDown(UINT message, |
851 SetMsgHandled(ProcessMousePressed(point, flags | MK_LBUTTON, false, true)); | 853 WPARAM w_param, |
| 854 LPARAM l_param) { |
| 855 SetMsgHandled(ProcessMousePressed(message, w_param, l_param)); |
| 856 return 0; |
852 } | 857 } |
853 | 858 |
854 void WidgetWin::OnNCLButtonUp(UINT flags, const CPoint& point) { | 859 LRESULT WidgetWin::OnNCLButtonUp(UINT message, WPARAM w_param, LPARAM l_param) { |
855 SetMsgHandled(FALSE); | 860 SetMsgHandled(FALSE); |
| 861 return 0; |
856 } | 862 } |
857 | 863 |
858 void WidgetWin::OnNCMButtonDblClk(UINT flags, const CPoint& point) { | 864 LRESULT WidgetWin::OnNCMButtonDblClk(UINT message, |
859 SetMsgHandled(ProcessMousePressed(point, flags | MK_MBUTTON, true, true)); | 865 WPARAM w_param, |
| 866 LPARAM l_param) { |
| 867 SetMsgHandled(ProcessMousePressed(message, w_param, l_param)); |
| 868 return 0; |
860 } | 869 } |
861 | 870 |
862 void WidgetWin::OnNCMButtonDown(UINT flags, const CPoint& point) { | 871 LRESULT WidgetWin::OnNCMButtonDown(UINT message, |
863 SetMsgHandled(ProcessMousePressed(point, flags | MK_MBUTTON, false, true)); | 872 WPARAM w_param, |
| 873 LPARAM l_param) { |
| 874 SetMsgHandled(ProcessMousePressed(message, w_param, l_param)); |
| 875 return 0; |
864 } | 876 } |
865 | 877 |
866 void WidgetWin::OnNCMButtonUp(UINT flags, const CPoint& point) { | 878 LRESULT WidgetWin::OnNCMButtonUp(UINT message, |
| 879 WPARAM w_param, |
| 880 LPARAM l_param) { |
867 SetMsgHandled(FALSE); | 881 SetMsgHandled(FALSE); |
| 882 return 0; |
868 } | 883 } |
869 | 884 |
870 LRESULT WidgetWin::OnNCMouseLeave(UINT uMsg, WPARAM w_param, LPARAM l_param) { | 885 LRESULT WidgetWin::OnNCMouseLeave(UINT message, |
| 886 WPARAM w_param, |
| 887 LPARAM l_param) { |
871 ProcessMouseExited(); | 888 ProcessMouseExited(); |
872 return 0; | 889 return 0; |
873 } | 890 } |
874 | 891 |
875 LRESULT WidgetWin::OnNCMouseMove(UINT flags, const CPoint& point) { | 892 LRESULT WidgetWin::OnNCMouseMove(UINT message, WPARAM w_param, LPARAM l_param) { |
876 // NC points are in screen coordinates. | 893 // NC points are in screen coordinates. |
877 CPoint temp = point; | 894 // TODO(msw): Ensure point translation is correct. Move into ProcessMouseMoved
??? |
878 MapWindowPoints(HWND_DESKTOP, hwnd(), &temp, 1); | 895 CPoint point(GET_X_LPARAM(l_param), GET_Y_LPARAM(l_param)); |
879 ProcessMouseMoved(temp, 0, true); | 896 MapWindowPoints(HWND_DESKTOP, hwnd(), &point, 1); |
| 897 l_param = MAKELPARAM(point.x, point.y); |
| 898 ProcessMouseMoved(message, w_param, l_param); |
880 | 899 |
881 // We need to process this message to stop Windows from drawing the window | 900 // We need to process this message to stop Windows from drawing the window |
882 // controls as the mouse moves over the title bar area when the window is | 901 // controls as the mouse moves over the title bar area when the window is |
883 // maximized. | 902 // maximized. |
884 return 0; | 903 return 0; |
885 } | 904 } |
886 | 905 |
887 void WidgetWin::OnNCPaint(HRGN rgn) { | 906 void WidgetWin::OnNCPaint(HRGN rgn) { |
888 SetMsgHandled(FALSE); | 907 SetMsgHandled(FALSE); |
889 } | 908 } |
890 | 909 |
891 void WidgetWin::OnNCRButtonDblClk(UINT flags, const CPoint& point) { | 910 LRESULT WidgetWin::OnNCRButtonDblClk(UINT message, |
892 SetMsgHandled(ProcessMousePressed(point, flags | MK_RBUTTON, true, true)); | 911 WPARAM w_param, |
| 912 LPARAM l_param) { |
| 913 SetMsgHandled(ProcessMousePressed(message, w_param, l_param)); |
| 914 return 0; |
893 } | 915 } |
894 | 916 |
895 void WidgetWin::OnNCRButtonDown(UINT flags, const CPoint& point) { | 917 LRESULT WidgetWin::OnNCRButtonDown(UINT message, |
896 SetMsgHandled(ProcessMousePressed(point, flags | MK_RBUTTON, false, true)); | 918 WPARAM w_param, |
| 919 LPARAM l_param) { |
| 920 SetMsgHandled(ProcessMousePressed(message, w_param, l_param)); |
| 921 return 0; |
897 } | 922 } |
898 | 923 |
899 void WidgetWin::OnNCRButtonUp(UINT flags, const CPoint& point) { | 924 LRESULT WidgetWin::OnNCRButtonUp(UINT message, WPARAM w_param, LPARAM l_param) { |
900 SetMsgHandled(FALSE); | 925 SetMsgHandled(FALSE); |
| 926 return 0; |
901 } | 927 } |
902 | 928 |
903 LRESULT WidgetWin::OnNCUAHDrawCaption(UINT msg, | 929 LRESULT WidgetWin::OnNCUAHDrawCaption(UINT msg, |
904 WPARAM w_param, | 930 WPARAM w_param, |
905 LPARAM l_param) { | 931 LPARAM l_param) { |
906 SetMsgHandled(FALSE); | 932 SetMsgHandled(FALSE); |
907 return 0; | 933 return 0; |
908 } | 934 } |
909 | 935 |
910 LRESULT WidgetWin::OnNCUAHDrawFrame(UINT msg, WPARAM w_param, LPARAM l_param) { | 936 LRESULT WidgetWin::OnNCUAHDrawFrame(UINT msg, WPARAM w_param, LPARAM l_param) { |
(...skipping 22 matching lines...) Expand all Loading... |
933 } | 959 } |
934 | 960 |
935 LRESULT WidgetWin::OnPowerBroadcast(DWORD power_event, DWORD data) { | 961 LRESULT WidgetWin::OnPowerBroadcast(DWORD power_event, DWORD data) { |
936 ui::SystemMonitor* monitor = ui::SystemMonitor::Get(); | 962 ui::SystemMonitor* monitor = ui::SystemMonitor::Get(); |
937 if (monitor) | 963 if (monitor) |
938 monitor->ProcessWmPowerBroadcastMessage(power_event); | 964 monitor->ProcessWmPowerBroadcastMessage(power_event); |
939 SetMsgHandled(FALSE); | 965 SetMsgHandled(FALSE); |
940 return 0; | 966 return 0; |
941 } | 967 } |
942 | 968 |
943 void WidgetWin::OnRButtonDown(UINT flags, const CPoint& point) { | 969 LRESULT WidgetWin::OnRButtonDblClk(UINT message, WPARAM w_param, |
944 ProcessMousePressed(point, flags | MK_RBUTTON, false, false); | 970 LPARAM l_param) { |
| 971 ProcessMousePressed(message, w_param, l_param); |
| 972 return 0; |
945 } | 973 } |
946 | 974 |
947 void WidgetWin::OnRButtonUp(UINT flags, const CPoint& point) { | 975 LRESULT WidgetWin::OnRButtonDown(UINT message, WPARAM w_param, LPARAM l_param) { |
948 ProcessMouseReleased(point, flags | MK_RBUTTON); | 976 ProcessMousePressed(message, w_param, l_param); |
| 977 return 0; |
949 } | 978 } |
950 | 979 |
951 void WidgetWin::OnRButtonDblClk(UINT flags, const CPoint& point) { | 980 LRESULT WidgetWin::OnRButtonUp(UINT message, WPARAM w_param, LPARAM l_param) { |
952 ProcessMousePressed(point, flags | MK_RBUTTON, true, false); | 981 ProcessMouseReleased(message, w_param, l_param); |
| 982 return 0; |
953 } | 983 } |
954 | 984 |
955 LRESULT WidgetWin::OnReflectedMessage(UINT msg, | 985 LRESULT WidgetWin::OnReflectedMessage(UINT msg, |
956 WPARAM w_param, | 986 WPARAM w_param, |
957 LPARAM l_param) { | 987 LPARAM l_param) { |
958 SetMsgHandled(FALSE); | 988 SetMsgHandled(FALSE); |
959 return 0; | 989 return 0; |
960 } | 990 } |
961 | 991 |
962 void WidgetWin::OnSetFocus(HWND focused_window) { | 992 void WidgetWin::OnSetFocus(HWND focused_window) { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1041 tme.dwFlags = mouse_tracking_flags; | 1071 tme.dwFlags = mouse_tracking_flags; |
1042 tme.hwndTrack = hwnd(); | 1072 tme.hwndTrack = hwnd(); |
1043 tme.dwHoverTime = 0; | 1073 tme.dwHoverTime = 0; |
1044 TrackMouseEvent(&tme); | 1074 TrackMouseEvent(&tme); |
1045 } else if (mouse_tracking_flags != active_mouse_tracking_flags_) { | 1075 } else if (mouse_tracking_flags != active_mouse_tracking_flags_) { |
1046 TrackMouseEvents(active_mouse_tracking_flags_ | TME_CANCEL); | 1076 TrackMouseEvents(active_mouse_tracking_flags_ | TME_CANCEL); |
1047 TrackMouseEvents(mouse_tracking_flags); | 1077 TrackMouseEvents(mouse_tracking_flags); |
1048 } | 1078 } |
1049 } | 1079 } |
1050 | 1080 |
1051 bool WidgetWin::ProcessMousePressed(const CPoint& point, | 1081 bool WidgetWin::ProcessMousePressed(UINT message, |
1052 UINT flags, | 1082 WPARAM w_param, |
1053 bool dbl_click, | 1083 LPARAM l_param) { |
1054 bool non_client) { | |
1055 last_mouse_event_was_move_ = false; | 1084 last_mouse_event_was_move_ = false; |
| 1085 |
| 1086 MSG msg; |
| 1087 MakeMSG(&msg, message, w_param, l_param, 0, GET_X_LPARAM(l_param), |
| 1088 GET_Y_LPARAM(l_param)); |
| 1089 MouseEvent mouse_pressed(msg); |
| 1090 |
| 1091 // TODO(msw): this is awkward... can this pattern be improved? |
| 1092 // Make a separate ProcessNCMousePressed that translates and then c
alls this? |
1056 // Windows gives screen coordinates for nonclient events, while the RootView | 1093 // Windows gives screen coordinates for nonclient events, while the RootView |
1057 // expects window coordinates; convert if necessary. | 1094 // expects window coordinates; convert if necessary. |
1058 gfx::Point converted_point(point); | 1095 bool result = false; |
1059 if (non_client) | 1096 if (mouse_pressed.flags() & ui::EF_IS_NON_CLIENT) |
1060 View::ConvertPointToView(NULL, GetRootView(), &converted_point); | 1097 result = GetRootView()->OnMousePressed( |
1061 MouseEvent mouse_pressed(ui::ET_MOUSE_PRESSED, | 1098 MouseEvent(mouse_pressed, NULL, GetRootView())); |
1062 converted_point.x(), | 1099 else |
1063 converted_point.y(), | 1100 result = GetRootView()->OnMousePressed(mouse_pressed); |
1064 (dbl_click ? ui::EF_IS_DOUBLE_CLICK : 0) | | 1101 |
1065 (non_client ? ui::EF_IS_NON_CLIENT : 0) | | 1102 if (result) { |
1066 Event::ConvertWindowsFlags(flags)); | |
1067 if (GetRootView()->OnMousePressed(mouse_pressed)) { | |
1068 is_mouse_down_ = true; | 1103 is_mouse_down_ = true; |
1069 if (!has_capture_) { | 1104 if (!has_capture_) { |
1070 SetCapture(); | 1105 SetCapture(); |
1071 has_capture_ = true; | 1106 has_capture_ = true; |
1072 } | 1107 } |
1073 return true; | 1108 return true; |
1074 } | 1109 } |
1075 return false; | 1110 return false; |
1076 } | 1111 } |
1077 | 1112 |
1078 void WidgetWin::ProcessMouseDragged(const CPoint& point, UINT flags) { | 1113 void WidgetWin::ProcessMouseDragged(UINT message, |
| 1114 WPARAM w_param, |
| 1115 LPARAM l_param) { |
1079 last_mouse_event_was_move_ = false; | 1116 last_mouse_event_was_move_ = false; |
1080 MouseEvent mouse_drag(ui::ET_MOUSE_DRAGGED, | 1117 |
1081 point.x, | 1118 MSG msg; |
1082 point.y, | 1119 MakeMSG(&msg, message, w_param, l_param, 0, GET_X_LPARAM(l_param), |
1083 Event::ConvertWindowsFlags(flags)); | 1120 GET_Y_LPARAM(l_param)); |
1084 GetRootView()->OnMouseDragged(mouse_drag); | 1121 GetRootView()->OnMouseDragged(MouseEvent(msg)); |
1085 } | 1122 } |
1086 | 1123 |
1087 void WidgetWin::ProcessMouseReleased(const CPoint& point, UINT flags) { | 1124 void WidgetWin::ProcessMouseReleased(UINT message, |
| 1125 WPARAM w_param, |
| 1126 LPARAM l_param) { |
1088 last_mouse_event_was_move_ = false; | 1127 last_mouse_event_was_move_ = false; |
1089 MouseEvent mouse_up(ui::ET_MOUSE_RELEASED, | 1128 |
1090 point.x, | |
1091 point.y, | |
1092 Event::ConvertWindowsFlags(flags)); | |
1093 // Release the capture first, that way we don't get confused if | 1129 // Release the capture first, that way we don't get confused if |
1094 // OnMouseReleased blocks. | 1130 // OnMouseReleased blocks. |
1095 if (has_capture_ && ReleaseCaptureOnMouseReleased()) { | 1131 if (has_capture_ && ReleaseCaptureOnMouseReleased()) { |
1096 has_capture_ = false; | 1132 has_capture_ = false; |
1097 ReleaseCapture(); | 1133 ReleaseCapture(); |
1098 } | 1134 } |
1099 is_mouse_down_ = false; | 1135 is_mouse_down_ = false; |
1100 GetRootView()->OnMouseReleased(mouse_up, false); | 1136 |
| 1137 MSG msg; |
| 1138 MakeMSG(&msg, message, w_param, l_param, 0, GET_X_LPARAM(l_param), |
| 1139 GET_Y_LPARAM(l_param)); |
| 1140 GetRootView()->OnMouseReleased(MouseEvent(msg), false); |
1101 } | 1141 } |
1102 | 1142 |
1103 void WidgetWin::ProcessMouseMoved(const CPoint &point, UINT flags, | 1143 void WidgetWin::ProcessMouseMoved(UINT message, |
1104 bool is_nonclient) { | 1144 WPARAM w_param, |
| 1145 LPARAM l_param) { |
| 1146 MSG msg; |
| 1147 MakeMSG(&msg, message, w_param, l_param, 0, GET_X_LPARAM(l_param), |
| 1148 GET_Y_LPARAM(l_param)); |
| 1149 MouseEvent mouse_move(msg); |
| 1150 |
1105 // Windows only fires WM_MOUSELEAVE events if the application begins | 1151 // Windows only fires WM_MOUSELEAVE events if the application begins |
1106 // "tracking" mouse events for a given HWND during WM_MOUSEMOVE events. | 1152 // "tracking" mouse events for a given HWND during WM_MOUSEMOVE events. |
1107 // We need to call |TrackMouseEvents| to listen for WM_MOUSELEAVE. | 1153 // We need to call |TrackMouseEvents| to listen for WM_MOUSELEAVE. |
1108 if (!has_capture_) | 1154 if (!has_capture_) |
1109 TrackMouseEvents(is_nonclient ? TME_NONCLIENT | TME_LEAVE : TME_LEAVE); | 1155 TrackMouseEvents((mouse_move.flags() & ui::EF_IS_NON_CLIENT) ? |
| 1156 TME_NONCLIENT | TME_LEAVE : TME_LEAVE); |
1110 if (has_capture_ && is_mouse_down_) { | 1157 if (has_capture_ && is_mouse_down_) { |
1111 ProcessMouseDragged(point, flags); | 1158 ProcessMouseDragged(message, w_param, l_param); |
1112 } else { | 1159 } else { |
1113 gfx::Point screen_loc(point); | 1160 if (last_mouse_event_was_move_ && last_mouse_move_x_ == msg.pt.x && |
1114 View::ConvertPointToScreen(GetRootView(), &screen_loc); | 1161 last_mouse_move_y_ == msg.pt.y) { |
1115 if (last_mouse_event_was_move_ && last_mouse_move_x_ == screen_loc.x() && | |
1116 last_mouse_move_y_ == screen_loc.y()) { | |
1117 // Don't generate a mouse event for the same location as the last. | 1162 // Don't generate a mouse event for the same location as the last. |
1118 return; | 1163 return; |
1119 } | 1164 } |
1120 last_mouse_move_x_ = screen_loc.x(); | 1165 last_mouse_move_x_ = msg.pt.x; |
1121 last_mouse_move_y_ = screen_loc.y(); | 1166 last_mouse_move_y_ = msg.pt.y; |
| 1167 |
| 1168 // TODO(msw): this is awkward... can this pattern be improved? |
| 1169 gfx::Point screen_loc(msg.pt.x, msg.pt.y); |
| 1170 View::ConvertPointToScreen(GetRootView(), &screen_loc); |
| 1171 msg.pt.x = screen_loc.x(); |
| 1172 msg.pt.y = screen_loc.y(); |
| 1173 msg.lParam = MAKELPARAM(screen_loc.x(), screen_loc.y()); |
| 1174 MouseEvent mouse_move_converted(msg); |
1122 last_mouse_event_was_move_ = true; | 1175 last_mouse_event_was_move_ = true; |
1123 MouseEvent mouse_move(ui::ET_MOUSE_MOVED, | 1176 GetRootView()->OnMouseMoved(mouse_move_converted); |
1124 point.x, | |
1125 point.y, | |
1126 Event::ConvertWindowsFlags(flags)); | |
1127 GetRootView()->OnMouseMoved(mouse_move); | |
1128 } | 1177 } |
1129 } | 1178 } |
1130 | 1179 |
1131 void WidgetWin::ProcessMouseExited() { | 1180 void WidgetWin::ProcessMouseExited() { |
1132 last_mouse_event_was_move_ = false; | 1181 last_mouse_event_was_move_ = false; |
1133 GetRootView()->ProcessOnMouseExited(); | 1182 GetRootView()->ProcessOnMouseExited(); |
1134 // Reset our tracking flag so that future mouse movement over this WidgetWin | 1183 // Reset our tracking flag so that future mouse movement over this WidgetWin |
1135 // results in a new tracking session. | 1184 // results in a new tracking session. |
1136 active_mouse_tracking_flags_ = 0; | 1185 active_mouse_tracking_flags_ = 0; |
1137 } | 1186 } |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1333 Widget* Widget::GetWidgetFromNativeWindow(gfx::NativeWindow native_window) { | 1382 Widget* Widget::GetWidgetFromNativeWindow(gfx::NativeWindow native_window) { |
1334 return Widget::GetWidgetFromNativeView(native_window); | 1383 return Widget::GetWidgetFromNativeView(native_window); |
1335 } | 1384 } |
1336 | 1385 |
1337 // static | 1386 // static |
1338 void Widget::NotifyLocaleChanged() { | 1387 void Widget::NotifyLocaleChanged() { |
1339 NOTIMPLEMENTED(); | 1388 NOTIMPLEMENTED(); |
1340 } | 1389 } |
1341 | 1390 |
1342 } // namespace views | 1391 } // namespace views |
OLD | NEW |