OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/views/win/hwnd_message_handler.h" | 5 #include "ui/views/win/hwnd_message_handler.h" |
6 | 6 |
7 #include <dwmapi.h> | 7 #include <dwmapi.h> |
8 #include <oleacc.h> | 8 #include <oleacc.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #include <tchar.h> | 10 #include <tchar.h> |
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
921 if (!ref || !::IsWindow(window)) | 921 if (!ref || !::IsWindow(window)) |
922 return result; | 922 return result; |
923 } | 923 } |
924 | 924 |
925 if (delegate_) { | 925 if (delegate_) { |
926 delegate_->PostHandleMSG(message, w_param, l_param); | 926 delegate_->PostHandleMSG(message, w_param, l_param); |
927 if (message == WM_NCDESTROY) | 927 if (message == WM_NCDESTROY) |
928 delegate_->HandleDestroyed(); | 928 delegate_->HandleDestroyed(); |
929 } | 929 } |
930 | 930 |
931 if (message == WM_ACTIVATE && IsTopLevelWindow(window)) | 931 if (message == WM_ACTIVATE && IsTopLevelWindow(window)) |
sky
2016/02/18 17:18:47
nit: add {} now
| |
932 PostProcessActivateMessage(LOWORD(w_param), !!HIWORD(w_param)); | 932 PostProcessActivateMessage(LOWORD(w_param), !!HIWORD(w_param), |
933 reinterpret_cast<HWND>(l_param)); | |
933 return result; | 934 return result; |
934 } | 935 } |
935 | 936 |
936 LRESULT HWNDMessageHandler::HandleMouseMessage(unsigned int message, | 937 LRESULT HWNDMessageHandler::HandleMouseMessage(unsigned int message, |
937 WPARAM w_param, | 938 WPARAM w_param, |
938 LPARAM l_param, | 939 LPARAM l_param, |
939 bool* handled) { | 940 bool* handled) { |
940 // Don't track forwarded mouse messages. We expect the caller to track the | 941 // Don't track forwarded mouse messages. We expect the caller to track the |
941 // mouse. | 942 // mouse. |
942 base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); | 943 base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1020 } | 1021 } |
1021 | 1022 |
1022 void HWNDMessageHandler::SetInitialFocus() { | 1023 void HWNDMessageHandler::SetInitialFocus() { |
1023 if (!(GetWindowLong(hwnd(), GWL_EXSTYLE) & WS_EX_TRANSPARENT) && | 1024 if (!(GetWindowLong(hwnd(), GWL_EXSTYLE) & WS_EX_TRANSPARENT) && |
1024 !(GetWindowLong(hwnd(), GWL_EXSTYLE) & WS_EX_NOACTIVATE)) { | 1025 !(GetWindowLong(hwnd(), GWL_EXSTYLE) & WS_EX_NOACTIVATE)) { |
1025 // The window does not get keyboard messages unless we focus it. | 1026 // The window does not get keyboard messages unless we focus it. |
1026 SetFocus(hwnd()); | 1027 SetFocus(hwnd()); |
1027 } | 1028 } |
1028 } | 1029 } |
1029 | 1030 |
1030 void HWNDMessageHandler::PostProcessActivateMessage(int activation_state, | 1031 void HWNDMessageHandler::PostProcessActivateMessage( |
1031 bool minimized) { | 1032 int activation_state, |
1033 bool minimized, | |
1034 HWND window_gaining_or_losing_activation) { | |
1032 DCHECK(IsTopLevelWindow(hwnd())); | 1035 DCHECK(IsTopLevelWindow(hwnd())); |
1033 const bool active = activation_state != WA_INACTIVE && !minimized; | 1036 const bool active = activation_state != WA_INACTIVE && !minimized; |
1034 if (delegate_->CanActivate()) | 1037 if (delegate_->CanActivate()) { |
1035 delegate_->HandleActivationChanged(active); | 1038 delegate_->HandleActivationChanged(active, |
1039 window_gaining_or_losing_activation); | |
1040 } | |
1036 } | 1041 } |
1037 | 1042 |
1038 void HWNDMessageHandler::RestoreEnabledIfNecessary() { | 1043 void HWNDMessageHandler::RestoreEnabledIfNecessary() { |
1039 if (delegate_->IsModal() && !restored_enabled_) { | 1044 if (delegate_->IsModal() && !restored_enabled_) { |
1040 restored_enabled_ = true; | 1045 restored_enabled_ = true; |
1041 // If we were run modally, we need to undo the disabled-ness we inflicted on | 1046 // If we were run modally, we need to undo the disabled-ness we inflicted on |
1042 // the owner's parent hierarchy. | 1047 // the owner's parent hierarchy. |
1043 HWND start = ::GetWindow(hwnd(), GW_OWNER); | 1048 HWND start = ::GetWindow(hwnd(), GW_OWNER); |
1044 while (start) { | 1049 while (start) { |
1045 ::EnableWindow(start, TRUE); | 1050 ::EnableWindow(start, TRUE); |
(...skipping 1524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2570 | 2575 |
2571 default: | 2576 default: |
2572 left_button_down_on_caption_ = false; | 2577 left_button_down_on_caption_ = false; |
2573 break; | 2578 break; |
2574 } | 2579 } |
2575 return handled; | 2580 return handled; |
2576 } | 2581 } |
2577 | 2582 |
2578 | 2583 |
2579 } // namespace views | 2584 } // namespace views |
OLD | NEW |