| 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 | 132 |
| 133 WidgetWin::WidgetWin() | 133 WidgetWin::WidgetWin() |
| 134 : ALLOW_THIS_IN_INITIALIZER_LIST(delegate_(this)), | 134 : ALLOW_THIS_IN_INITIALIZER_LIST(delegate_(this)), |
| 135 close_widget_factory_(this), | 135 close_widget_factory_(this), |
| 136 active_mouse_tracking_flags_(0), | 136 active_mouse_tracking_flags_(0), |
| 137 use_layered_buffer_(false), | 137 use_layered_buffer_(false), |
| 138 layered_alpha_(255), | 138 layered_alpha_(255), |
| 139 ALLOW_THIS_IN_INITIALIZER_LIST(paint_layered_window_factory_(this)), | 139 ALLOW_THIS_IN_INITIALIZER_LIST(paint_layered_window_factory_(this)), |
| 140 delete_on_destroy_(true), | 140 delete_on_destroy_(true), |
| 141 can_update_layered_window_(true), | 141 can_update_layered_window_(true), |
| 142 last_mouse_event_was_move_(false), | |
| 143 is_mouse_down_(false), | |
| 144 is_window_(false), | 142 is_window_(false), |
| 145 restore_focus_when_enabled_(false), | 143 restore_focus_when_enabled_(false), |
| 146 accessibility_view_events_index_(-1), | 144 accessibility_view_events_index_(-1), |
| 147 accessibility_view_events_(kMaxAccessibilityViewEvents), | 145 accessibility_view_events_(kMaxAccessibilityViewEvents), |
| 148 previous_cursor_(NULL) { | 146 previous_cursor_(NULL) { |
| 149 set_native_widget(this); | 147 set_native_widget(this); |
| 150 } | 148 } |
| 151 | 149 |
| 152 WidgetWin::~WidgetWin() { | 150 WidgetWin::~WidgetWin() { |
| 153 DestroyRootView(); | 151 DestroyRootView(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 183 switch (params.type) { | 181 switch (params.type) { |
| 184 case CreateParams::TYPE_WINDOW: | 182 case CreateParams::TYPE_WINDOW: |
| 185 case CreateParams::TYPE_CONTROL: | 183 case CreateParams::TYPE_CONTROL: |
| 186 break; | 184 break; |
| 187 case CreateParams::TYPE_POPUP: | 185 case CreateParams::TYPE_POPUP: |
| 188 style |= WS_POPUP; | 186 style |= WS_POPUP; |
| 189 ex_style |= WS_EX_TOOLWINDOW; | 187 ex_style |= WS_EX_TOOLWINDOW; |
| 190 break; | 188 break; |
| 191 case CreateParams::TYPE_MENU: | 189 case CreateParams::TYPE_MENU: |
| 192 style |= WS_POPUP; | 190 style |= WS_POPUP; |
| 193 is_mouse_down_ = | 191 is_mouse_button_pressed_ = |
| 194 ((GetKeyState(VK_LBUTTON) & 0x80) || | 192 ((GetKeyState(VK_LBUTTON) & 0x80) || |
| 195 (GetKeyState(VK_RBUTTON) & 0x80) || | 193 (GetKeyState(VK_RBUTTON) & 0x80) || |
| 196 (GetKeyState(VK_MBUTTON) & 0x80) || | 194 (GetKeyState(VK_MBUTTON) & 0x80) || |
| 197 (GetKeyState(VK_XBUTTON1) & 0x80) || | 195 (GetKeyState(VK_XBUTTON1) & 0x80) || |
| 198 (GetKeyState(VK_XBUTTON2) & 0x80)); | 196 (GetKeyState(VK_XBUTTON2) & 0x80)); |
| 199 break; | 197 break; |
| 200 default: | 198 default: |
| 201 NOTREACHED(); | 199 NOTREACHED(); |
| 202 } | 200 } |
| 203 | 201 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 } | 313 } |
| 316 | 314 |
| 317 TooltipManager* WidgetWin::GetTooltipManager() const { | 315 TooltipManager* WidgetWin::GetTooltipManager() const { |
| 318 return tooltip_manager_.get(); | 316 return tooltip_manager_.get(); |
| 319 } | 317 } |
| 320 | 318 |
| 321 bool WidgetWin::IsScreenReaderActive() const { | 319 bool WidgetWin::IsScreenReaderActive() const { |
| 322 return screen_reader_active_; | 320 return screen_reader_active_; |
| 323 } | 321 } |
| 324 | 322 |
| 325 void WidgetWin::SetNativeCapture() { | 323 void WidgetWin::SetMouseCapture() { |
| 326 DCHECK(!HasNativeCapture()); | 324 DCHECK(!HasMouseCapture()); |
| 327 SetCapture(hwnd()); | 325 SetCapture(hwnd()); |
| 328 } | 326 } |
| 329 | 327 |
| 330 void WidgetWin::ReleaseNativeCapture() { | 328 void WidgetWin::ReleaseMouseCapture() { |
| 331 ReleaseCapture(); | 329 ReleaseCapture(); |
| 332 } | 330 } |
| 333 | 331 |
| 334 bool WidgetWin::HasNativeCapture() const { | 332 bool WidgetWin::HasMouseCapture() const { |
| 335 return GetCapture() == hwnd(); | 333 return GetCapture() == hwnd(); |
| 336 } | 334 } |
| 337 | 335 |
| 336 bool WidgetWin::ShouldReleaseCaptureOnMouseReleased() const { |
| 337 return true; |
| 338 } |
| 339 |
| 338 gfx::Rect WidgetWin::GetWindowScreenBounds() const { | 340 gfx::Rect WidgetWin::GetWindowScreenBounds() const { |
| 339 RECT r; | 341 RECT r; |
| 340 GetWindowRect(&r); | 342 GetWindowRect(&r); |
| 341 return gfx::Rect(r); | 343 return gfx::Rect(r); |
| 342 } | 344 } |
| 343 | 345 |
| 344 gfx::Rect WidgetWin::GetClientAreaScreenBounds() const { | 346 gfx::Rect WidgetWin::GetClientAreaScreenBounds() const { |
| 345 RECT r; | 347 RECT r; |
| 346 GetClientRect(&r); | 348 GetClientRect(&r); |
| 347 POINT point = { r.left, r.top }; | 349 POINT point = { r.left, r.top }; |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 LRESULT WidgetWin::OnAppCommand(HWND window, short app_command, WORD device, | 561 LRESULT WidgetWin::OnAppCommand(HWND window, short app_command, WORD device, |
| 560 int keystate) { | 562 int keystate) { |
| 561 SetMsgHandled(FALSE); | 563 SetMsgHandled(FALSE); |
| 562 return 0; | 564 return 0; |
| 563 } | 565 } |
| 564 | 566 |
| 565 void WidgetWin::OnCancelMode() { | 567 void WidgetWin::OnCancelMode() { |
| 566 } | 568 } |
| 567 | 569 |
| 568 void WidgetWin::OnCaptureChanged(HWND hwnd) { | 570 void WidgetWin::OnCaptureChanged(HWND hwnd) { |
| 569 if (is_mouse_down_) | 571 delegate_->OnMouseCaptureLost(); |
| 570 GetRootView()->OnMouseCaptureLost(); | |
| 571 is_mouse_down_ = false; | |
| 572 } | 572 } |
| 573 | 573 |
| 574 void WidgetWin::OnClose() { | 574 void WidgetWin::OnClose() { |
| 575 Close(); | 575 Close(); |
| 576 } | 576 } |
| 577 | 577 |
| 578 void WidgetWin::OnCommand(UINT notification_code, int command_id, HWND window) { | 578 void WidgetWin::OnCommand(UINT notification_code, int command_id, HWND window) { |
| 579 SetMsgHandled(FALSE); | 579 SetMsgHandled(FALSE); |
| 580 } | 580 } |
| 581 | 581 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 UINT position, | 711 UINT position, |
| 712 BOOL is_system_menu) { | 712 BOOL is_system_menu) { |
| 713 SetMsgHandled(FALSE); | 713 SetMsgHandled(FALSE); |
| 714 } | 714 } |
| 715 | 715 |
| 716 LRESULT WidgetWin::OnKeyDown(UINT message, WPARAM w_param, LPARAM l_param) { | 716 LRESULT WidgetWin::OnKeyDown(UINT message, WPARAM w_param, LPARAM l_param) { |
| 717 RootView* root_view = GetFocusedViewRootView(); | 717 RootView* root_view = GetFocusedViewRootView(); |
| 718 if (!root_view) | 718 if (!root_view) |
| 719 root_view = GetRootView(); | 719 root_view = GetRootView(); |
| 720 | 720 |
| 721 MSG msg; | 721 MSG msg = { hwnd(), message, w_param, l_param }; |
| 722 MakeMSG(&msg, message, w_param, l_param); | |
| 723 SetMsgHandled(root_view->ProcessKeyEvent(KeyEvent(msg))); | 722 SetMsgHandled(root_view->ProcessKeyEvent(KeyEvent(msg))); |
| 724 return 0; | 723 return 0; |
| 725 } | 724 } |
| 726 | 725 |
| 727 LRESULT WidgetWin::OnKeyUp(UINT message, WPARAM w_param, LPARAM l_param) { | 726 LRESULT WidgetWin::OnKeyUp(UINT message, WPARAM w_param, LPARAM l_param) { |
| 728 RootView* root_view = GetFocusedViewRootView(); | 727 RootView* root_view = GetFocusedViewRootView(); |
| 729 if (!root_view) | 728 if (!root_view) |
| 730 root_view = GetRootView(); | 729 root_view = GetRootView(); |
| 731 | 730 |
| 732 MSG msg; | 731 MSG msg = { hwnd(), message, w_param, l_param }; |
| 733 MakeMSG(&msg, message, w_param, l_param); | |
| 734 SetMsgHandled(root_view->ProcessKeyEvent(KeyEvent(msg))); | 732 SetMsgHandled(root_view->ProcessKeyEvent(KeyEvent(msg))); |
| 735 return 0; | 733 return 0; |
| 736 } | 734 } |
| 737 | 735 |
| 738 void WidgetWin::OnKillFocus(HWND focused_window) { | 736 void WidgetWin::OnKillFocus(HWND focused_window) { |
| 739 delegate_->OnNativeBlur(focused_window); | 737 delegate_->OnNativeBlur(focused_window); |
| 740 SetMsgHandled(FALSE); | 738 SetMsgHandled(FALSE); |
| 741 } | 739 } |
| 742 | 740 |
| 743 LRESULT WidgetWin::OnMouseActivate(UINT message, | 741 LRESULT WidgetWin::OnMouseActivate(UINT message, |
| 744 WPARAM w_param, | 742 WPARAM w_param, |
| 745 LPARAM l_param) { | 743 LPARAM l_param) { |
| 746 if (GetWindowLong(GWL_EXSTYLE) & WS_EX_NOACTIVATE) | 744 if (GetWindowLong(GWL_EXSTYLE) & WS_EX_NOACTIVATE) |
| 747 return MA_NOACTIVATE; | 745 return MA_NOACTIVATE; |
| 748 SetMsgHandled(FALSE); | 746 SetMsgHandled(FALSE); |
| 749 return MA_ACTIVATE; | 747 return MA_ACTIVATE; |
| 750 } | 748 } |
| 751 | 749 |
| 752 LRESULT WidgetWin::OnMouseLeave(UINT message, WPARAM w_param, LPARAM l_param) { | 750 LRESULT WidgetWin::OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param) { |
| 753 tooltip_manager_->OnMouseLeave(); | 751 if (message == WM_MOUSEWHEEL) |
| 754 ProcessMouseExited(message, w_param, l_param); | 752 return 0; |
| 753 |
| 754 MSG msg = { hwnd(), message, w_param, l_param, 0, |
| 755 { GET_X_LPARAM(l_param), GET_Y_LPARAM(l_param) } }; |
| 756 MouseEvent event(msg); |
| 757 |
| 758 if (!(event.flags() & ui::EF_IS_NON_CLIENT)) |
| 759 tooltip_manager_->OnMouse(message, w_param, l_param); |
| 760 |
| 761 if (event.type() == ui::ET_MOUSE_MOVED && !HasMouseCapture()) { |
| 762 // Windows only fires WM_MOUSELEAVE events if the application begins |
| 763 // "tracking" mouse events for a given HWND during WM_MOUSEMOVE events. |
| 764 // We need to call |TrackMouseEvents| to listen for WM_MOUSELEAVE. |
| 765 TrackMouseEvents((message == WM_NCMOUSEMOVE) ? |
| 766 TME_NONCLIENT | TME_LEAVE : TME_LEAVE); |
| 767 } else if (event.type() == ui::ET_MOUSE_EXITED) { |
| 768 // Reset our tracking flags so future mouse movement over this WidgetWin |
| 769 // results in a new tracking session. Fall through for OnMouseEvent. |
| 770 active_mouse_tracking_flags_ = 0; |
| 771 } |
| 772 |
| 773 SetMsgHandled(delegate_->OnMouseEvent(event)); |
| 755 return 0; | 774 return 0; |
| 756 } | 775 } |
| 757 | 776 |
| 758 LRESULT WidgetWin::OnMouseMove(UINT message, WPARAM w_param, LPARAM l_param) { | |
| 759 ProcessMouseMoved(message, w_param, l_param); | |
| 760 return 0; | |
| 761 } | |
| 762 | |
| 763 LRESULT WidgetWin::OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param) { | |
| 764 tooltip_manager_->OnMouse(message, w_param, l_param); | |
| 765 | |
| 766 switch (message) { | |
| 767 case WM_LBUTTONDBLCLK: | |
| 768 case WM_LBUTTONDOWN: | |
| 769 case WM_MBUTTONDBLCLK: | |
| 770 case WM_MBUTTONDOWN: | |
| 771 case WM_RBUTTONDBLCLK: | |
| 772 case WM_RBUTTONDOWN: | |
| 773 SetMsgHandled(ProcessMousePressed(message, w_param, l_param)); | |
| 774 break; | |
| 775 case WM_LBUTTONUP: | |
| 776 case WM_MBUTTONUP: | |
| 777 case WM_RBUTTONUP: | |
| 778 SetMsgHandled(ProcessMouseReleased(message, w_param, l_param)); | |
| 779 break; | |
| 780 default: | |
| 781 SetMsgHandled(FALSE); | |
| 782 } | |
| 783 | |
| 784 return 0; | |
| 785 } | |
| 786 | |
| 787 LRESULT WidgetWin::OnMouseWheel(UINT message, WPARAM w_param, LPARAM l_param) { | 777 LRESULT WidgetWin::OnMouseWheel(UINT message, WPARAM w_param, LPARAM l_param) { |
| 788 // Reroute the mouse-wheel to the window under the mouse pointer if | 778 // Reroute the mouse-wheel to the window under the mouse pointer if |
| 789 // applicable. | 779 // applicable. |
| 790 if (message == WM_MOUSEWHEEL && | 780 if (message == WM_MOUSEWHEEL && |
| 791 views::RerouteMouseWheel(hwnd(), w_param, l_param)) { | 781 views::RerouteMouseWheel(hwnd(), w_param, l_param)) { |
| 792 return 0; | 782 return 0; |
| 793 } | 783 } |
| 794 | 784 |
| 795 MSG msg; | 785 MSG msg = { hwnd(), message, w_param, l_param, 0, |
| 796 MakeMSG(&msg, message, w_param, l_param, 0, | 786 { GET_X_LPARAM(l_param), GET_Y_LPARAM(l_param) } }; |
| 797 GET_X_LPARAM(l_param), GET_Y_LPARAM(l_param)); | |
| 798 return GetRootView()->OnMouseWheel(MouseWheelEvent(msg)) ? 0 : 1; | 787 return GetRootView()->OnMouseWheel(MouseWheelEvent(msg)) ? 0 : 1; |
| 799 } | 788 } |
| 800 | 789 |
| 801 void WidgetWin::OnMove(const CPoint& point) { | 790 void WidgetWin::OnMove(const CPoint& point) { |
| 802 if (widget_delegate()) | 791 if (widget_delegate()) |
| 803 widget_delegate()->OnWidgetMove(); | 792 widget_delegate()->OnWidgetMove(); |
| 804 SetMsgHandled(FALSE); | 793 SetMsgHandled(FALSE); |
| 805 } | 794 } |
| 806 | 795 |
| 807 void WidgetWin::OnMoving(UINT param, const LPRECT new_bounds) { | 796 void WidgetWin::OnMoving(UINT param, const LPRECT new_bounds) { |
| 808 if (widget_delegate()) | 797 if (widget_delegate()) |
| 809 widget_delegate()->OnWidgetMove(); | 798 widget_delegate()->OnWidgetMove(); |
| 810 } | 799 } |
| 811 | 800 |
| 812 LRESULT WidgetWin::OnNCActivate(BOOL active) { | 801 LRESULT WidgetWin::OnNCActivate(BOOL active) { |
| 813 SetMsgHandled(FALSE); | 802 SetMsgHandled(FALSE); |
| 814 return 0; | 803 return 0; |
| 815 } | 804 } |
| 816 | 805 |
| 817 LRESULT WidgetWin::OnNCCalcSize(BOOL w_param, LPARAM l_param) { | 806 LRESULT WidgetWin::OnNCCalcSize(BOOL w_param, LPARAM l_param) { |
| 818 SetMsgHandled(FALSE); | 807 SetMsgHandled(FALSE); |
| 819 return 0; | 808 return 0; |
| 820 } | 809 } |
| 821 | 810 |
| 822 LRESULT WidgetWin::OnNCHitTest(const CPoint& pt) { | 811 LRESULT WidgetWin::OnNCHitTest(const CPoint& pt) { |
| 823 SetMsgHandled(FALSE); | 812 SetMsgHandled(FALSE); |
| 824 return 0; | 813 return 0; |
| 825 } | 814 } |
| 826 | 815 |
| 827 LRESULT WidgetWin::OnNCMouseLeave(UINT message, | |
| 828 WPARAM w_param, | |
| 829 LPARAM l_param) { | |
| 830 ProcessMouseExited(message, w_param, l_param); | |
| 831 return 0; | |
| 832 } | |
| 833 | |
| 834 LRESULT WidgetWin::OnNCMouseMove(UINT message, WPARAM w_param, LPARAM l_param) { | |
| 835 tooltip_manager_->OnMouse(message, w_param, l_param); | |
| 836 ProcessMouseMoved(message, w_param, l_param); | |
| 837 | |
| 838 // We need to process this message to stop Windows from drawing the window | |
| 839 // controls as the mouse moves over the title bar area when the window is | |
| 840 // maximized. | |
| 841 return 0; | |
| 842 } | |
| 843 | |
| 844 LRESULT WidgetWin::OnNCMouseRange(UINT message, | |
| 845 WPARAM w_param, | |
| 846 LPARAM l_param) { | |
| 847 switch (message) { | |
| 848 case WM_NCLBUTTONDBLCLK: | |
| 849 case WM_NCLBUTTONDOWN: | |
| 850 case WM_NCMBUTTONDBLCLK: | |
| 851 case WM_NCMBUTTONDOWN: | |
| 852 case WM_NCRBUTTONDBLCLK: | |
| 853 case WM_NCRBUTTONDOWN: | |
| 854 SetMsgHandled(ProcessMousePressed(message, w_param, l_param)); | |
| 855 break; | |
| 856 case WM_NCLBUTTONUP: | |
| 857 case WM_NCMBUTTONUP: | |
| 858 case WM_NCRBUTTONUP: | |
| 859 default: | |
| 860 SetMsgHandled(FALSE); | |
| 861 } | |
| 862 | |
| 863 return 0; | |
| 864 } | |
| 865 | |
| 866 void WidgetWin::OnNCPaint(HRGN rgn) { | 816 void WidgetWin::OnNCPaint(HRGN rgn) { |
| 867 SetMsgHandled(FALSE); | 817 SetMsgHandled(FALSE); |
| 868 } | 818 } |
| 869 | 819 |
| 870 LRESULT WidgetWin::OnNCUAHDrawCaption(UINT msg, | 820 LRESULT WidgetWin::OnNCUAHDrawCaption(UINT msg, |
| 871 WPARAM w_param, | 821 WPARAM w_param, |
| 872 LPARAM l_param) { | 822 LPARAM l_param) { |
| 873 SetMsgHandled(FALSE); | 823 SetMsgHandled(FALSE); |
| 874 return 0; | 824 return 0; |
| 875 } | 825 } |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 986 tme.dwFlags = mouse_tracking_flags; | 936 tme.dwFlags = mouse_tracking_flags; |
| 987 tme.hwndTrack = hwnd(); | 937 tme.hwndTrack = hwnd(); |
| 988 tme.dwHoverTime = 0; | 938 tme.dwHoverTime = 0; |
| 989 TrackMouseEvent(&tme); | 939 TrackMouseEvent(&tme); |
| 990 } else if (mouse_tracking_flags != active_mouse_tracking_flags_) { | 940 } else if (mouse_tracking_flags != active_mouse_tracking_flags_) { |
| 991 TrackMouseEvents(active_mouse_tracking_flags_ | TME_CANCEL); | 941 TrackMouseEvents(active_mouse_tracking_flags_ | TME_CANCEL); |
| 992 TrackMouseEvents(mouse_tracking_flags); | 942 TrackMouseEvents(mouse_tracking_flags); |
| 993 } | 943 } |
| 994 } | 944 } |
| 995 | 945 |
| 996 bool WidgetWin::ProcessMousePressed(UINT message, | |
| 997 WPARAM w_param, | |
| 998 LPARAM l_param) { | |
| 999 last_mouse_event_was_move_ = false; | |
| 1000 | |
| 1001 MSG msg; | |
| 1002 MakeMSG(&msg, message, w_param, l_param, 0, GET_X_LPARAM(l_param), | |
| 1003 GET_Y_LPARAM(l_param)); | |
| 1004 if (GetRootView()->OnMousePressed(MouseEvent(msg))) { | |
| 1005 is_mouse_down_ = true; | |
| 1006 if (!HasNativeCapture()) | |
| 1007 SetNativeCapture(); | |
| 1008 return true; | |
| 1009 } | |
| 1010 return false; | |
| 1011 } | |
| 1012 | |
| 1013 bool WidgetWin::ProcessMouseReleased(UINT message, | |
| 1014 WPARAM w_param, | |
| 1015 LPARAM l_param) { | |
| 1016 last_mouse_event_was_move_ = false; | |
| 1017 is_mouse_down_ = false; | |
| 1018 | |
| 1019 // Release the capture first, that way we don't get confused if | |
| 1020 // OnMouseReleased blocks. | |
| 1021 if (HasNativeCapture() && ReleaseCaptureOnMouseReleased()) | |
| 1022 ReleaseNativeCapture(); | |
| 1023 | |
| 1024 MSG msg; | |
| 1025 MakeMSG(&msg, message, w_param, l_param, 0, GET_X_LPARAM(l_param), | |
| 1026 GET_Y_LPARAM(l_param)); | |
| 1027 GetRootView()->OnMouseReleased(MouseEvent(msg)); | |
| 1028 return true; | |
| 1029 } | |
| 1030 | |
| 1031 bool WidgetWin::ProcessMouseMoved(UINT message, | |
| 1032 WPARAM w_param, | |
| 1033 LPARAM l_param) { | |
| 1034 // Windows only fires WM_MOUSELEAVE events if the application begins | |
| 1035 // "tracking" mouse events for a given HWND during WM_MOUSEMOVE events. | |
| 1036 // We need to call |TrackMouseEvents| to listen for WM_MOUSELEAVE. | |
| 1037 if (!HasNativeCapture()) | |
| 1038 TrackMouseEvents((message == WM_NCMOUSEMOVE) ? | |
| 1039 TME_NONCLIENT | TME_LEAVE : TME_LEAVE); | |
| 1040 MSG msg; | |
| 1041 MakeMSG(&msg, message, w_param, l_param, 0, GET_X_LPARAM(l_param), | |
| 1042 GET_Y_LPARAM(l_param)); | |
| 1043 if (HasNativeCapture() && is_mouse_down_) | |
| 1044 GetRootView()->OnMouseDragged(MouseEvent(msg)); | |
| 1045 else if (!last_mouse_event_was_move_ || | |
| 1046 (last_mouse_move_x_ != GET_X_LPARAM(l_param) || | |
| 1047 last_mouse_move_y_ != GET_Y_LPARAM(l_param))) { | |
| 1048 last_mouse_move_x_ = GET_X_LPARAM(l_param); | |
| 1049 last_mouse_move_y_ = GET_Y_LPARAM(l_param); | |
| 1050 last_mouse_event_was_move_ = true; | |
| 1051 GetRootView()->OnMouseMoved(MouseEvent(msg)); | |
| 1052 } | |
| 1053 return true; | |
| 1054 } | |
| 1055 | |
| 1056 void WidgetWin::ProcessMouseExited(UINT message, | |
| 1057 WPARAM w_param, | |
| 1058 LPARAM l_param) { | |
| 1059 last_mouse_event_was_move_ = false; | |
| 1060 MSG msg; | |
| 1061 MakeMSG(&msg, message, w_param, l_param, 0, GET_X_LPARAM(l_param), | |
| 1062 GET_Y_LPARAM(l_param)); | |
| 1063 GetRootView()->OnMouseExited(MouseEvent(msg)); | |
| 1064 // Reset our tracking flag so that future mouse movement over this WidgetWin | |
| 1065 // results in a new tracking session. | |
| 1066 active_mouse_tracking_flags_ = 0; | |
| 1067 } | |
| 1068 | |
| 1069 void WidgetWin::OnScreenReaderDetected() { | 946 void WidgetWin::OnScreenReaderDetected() { |
| 1070 screen_reader_active_ = true; | 947 screen_reader_active_ = true; |
| 1071 } | 948 } |
| 1072 | 949 |
| 1073 bool WidgetWin::ReleaseCaptureOnMouseReleased() { | |
| 1074 return true; | |
| 1075 } | |
| 1076 | |
| 1077 //////////////////////////////////////////////////////////////////////////////// | 950 //////////////////////////////////////////////////////////////////////////////// |
| 1078 // WidgetWin, private: | 951 // WidgetWin, private: |
| 1079 | 952 |
| 1080 // static | 953 // static |
| 1081 Window* WidgetWin::GetWindowImpl(HWND hwnd) { | 954 Window* WidgetWin::GetWindowImpl(HWND hwnd) { |
| 1082 // NOTE: we can't use GetAncestor here as constrained windows are a Window, | 955 // NOTE: we can't use GetAncestor here as constrained windows are a Window, |
| 1083 // but not a top level window. | 956 // but not a top level window. |
| 1084 HWND parent = hwnd; | 957 HWND parent = hwnd; |
| 1085 while (parent) { | 958 while (parent) { |
| 1086 WidgetWin* widget = | 959 WidgetWin* widget = |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1129 // again. | 1002 // again. |
| 1130 if (!IsWindowEnabled(widget->GetNativeView())) { | 1003 if (!IsWindowEnabled(widget->GetNativeView())) { |
| 1131 DCHECK(!widget->restore_focus_when_enabled_); | 1004 DCHECK(!widget->restore_focus_when_enabled_); |
| 1132 widget->restore_focus_when_enabled_ = true; | 1005 widget->restore_focus_when_enabled_ = true; |
| 1133 return; | 1006 return; |
| 1134 } | 1007 } |
| 1135 focus_manager->RestoreFocusedView(); | 1008 focus_manager->RestoreFocusedView(); |
| 1136 } | 1009 } |
| 1137 } | 1010 } |
| 1138 | 1011 |
| 1139 void WidgetWin::MakeMSG(MSG* msg, UINT message, WPARAM w_param, LPARAM l_param, | |
| 1140 DWORD time, LONG x, LONG y) const { | |
| 1141 msg->hwnd = hwnd(); | |
| 1142 msg->message = message; | |
| 1143 msg->wParam = w_param; | |
| 1144 msg->lParam = l_param; | |
| 1145 msg->time = time; | |
| 1146 msg->pt.x = x; | |
| 1147 msg->pt.y = y; | |
| 1148 } | |
| 1149 | |
| 1150 void WidgetWin::RedrawInvalidRect() { | 1012 void WidgetWin::RedrawInvalidRect() { |
| 1151 if (!use_layered_buffer_) { | 1013 if (!use_layered_buffer_) { |
| 1152 RECT r = { 0, 0, 0, 0 }; | 1014 RECT r = { 0, 0, 0, 0 }; |
| 1153 if (GetUpdateRect(hwnd(), &r, FALSE) && !IsRectEmpty(&r)) { | 1015 if (GetUpdateRect(hwnd(), &r, FALSE) && !IsRectEmpty(&r)) { |
| 1154 RedrawWindow(hwnd(), &r, NULL, | 1016 RedrawWindow(hwnd(), &r, NULL, |
| 1155 RDW_INVALIDATE | RDW_UPDATENOW | RDW_NOCHILDREN); | 1017 RDW_INVALIDATE | RDW_UPDATENOW | RDW_NOCHILDREN); |
| 1156 } | 1018 } |
| 1157 } | 1019 } |
| 1158 } | 1020 } |
| 1159 | 1021 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1263 return; | 1125 return; |
| 1264 | 1126 |
| 1265 NativeWidget* native_widget = GetNativeWidgetForNativeView(native_view); | 1127 NativeWidget* native_widget = GetNativeWidgetForNativeView(native_view); |
| 1266 if (native_widget) | 1128 if (native_widget) |
| 1267 children->insert(native_widget); | 1129 children->insert(native_widget); |
| 1268 EnumChildWindows(native_view, EnumerateChildWindowsForNativeWidgets, | 1130 EnumChildWindows(native_view, EnumerateChildWindowsForNativeWidgets, |
| 1269 reinterpret_cast<LPARAM>(children)); | 1131 reinterpret_cast<LPARAM>(children)); |
| 1270 } | 1132 } |
| 1271 | 1133 |
| 1272 } // namespace views | 1134 } // namespace views |
| OLD | NEW |