| 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_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 // receive a size notification when its initial bounds are specified at window | 665 // receive a size notification when its initial bounds are specified at window |
| 666 // creation time. | 666 // creation time. |
| 667 ClientAreaSizeChanged(); | 667 ClientAreaSizeChanged(); |
| 668 | 668 |
| 669 delegate_->OnNativeWidgetCreated(); | 669 delegate_->OnNativeWidgetCreated(); |
| 670 | 670 |
| 671 // delegate_->OnNativeWidgetCreated() creates the focus manager for top-level | 671 // delegate_->OnNativeWidgetCreated() creates the focus manager for top-level |
| 672 // widget. Only top-level widget should have an input method. | 672 // widget. Only top-level widget should have an input method. |
| 673 if (delegate_->HasFocusManager() && | 673 if (delegate_->HasFocusManager() && |
| 674 NativeTextfieldViews::IsTextfieldViewsEnabled()) { | 674 NativeTextfieldViews::IsTextfieldViewsEnabled()) { |
| 675 input_method_.reset(new InputMethodWin(this)); | 675 input_method_.reset(new InputMethodWin()); |
| 676 input_method_->Init(GetWidget()); | 676 input_method_->Init(GetWidget()); |
| 677 is_input_method_win_ = true; | 677 is_input_method_win_ = true; |
| 678 } | 678 } |
| 679 return 0; | 679 return 0; |
| 680 } | 680 } |
| 681 | 681 |
| 682 void WidgetWin::OnDestroy() { | 682 void WidgetWin::OnDestroy() { |
| 683 if (drop_target_.get()) { | 683 if (drop_target_.get()) { |
| 684 RevokeDragDrop(hwnd()); | 684 RevokeDragDrop(hwnd()); |
| 685 drop_target_ = NULL; | 685 drop_target_ = NULL; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 | 806 |
| 807 void WidgetWin::OnInputLangChange(DWORD character_set, HKL input_language_id) { | 807 void WidgetWin::OnInputLangChange(DWORD character_set, HKL input_language_id) { |
| 808 if (is_input_method_win_) { | 808 if (is_input_method_win_) { |
| 809 static_cast<InputMethodWin*>(input_method_.get())->OnInputLangChange( | 809 static_cast<InputMethodWin*>(input_method_.get())->OnInputLangChange( |
| 810 character_set, input_language_id); | 810 character_set, input_language_id); |
| 811 } | 811 } |
| 812 } | 812 } |
| 813 | 813 |
| 814 LRESULT WidgetWin::OnKeyEvent(UINT message, WPARAM w_param, LPARAM l_param) { | 814 LRESULT WidgetWin::OnKeyEvent(UINT message, WPARAM w_param, LPARAM l_param) { |
| 815 MSG msg = { hwnd(), message, w_param, l_param }; | 815 MSG msg = { hwnd(), message, w_param, l_param }; |
| 816 KeyEvent key(msg); | 816 SetMsgHandled(delegate_->OnKeyEvent(KeyEvent(msg))); |
| 817 if (input_method_.get()) | |
| 818 input_method_->DispatchKeyEvent(key); | |
| 819 else | |
| 820 DispatchKeyEventPostIME(key); | |
| 821 return 0; | 817 return 0; |
| 822 } | 818 } |
| 823 | 819 |
| 824 void WidgetWin::OnKillFocus(HWND focused_window) { | 820 void WidgetWin::OnKillFocus(HWND focused_window) { |
| 825 delegate_->OnNativeBlur(focused_window); | 821 delegate_->OnNativeBlur(focused_window); |
| 826 if (input_method_.get()) | 822 if (input_method_.get()) |
| 827 input_method_->OnBlur(); | 823 input_method_->OnBlur(); |
| 828 SetMsgHandled(FALSE); | 824 SetMsgHandled(FALSE); |
| 829 } | 825 } |
| 830 | 826 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1038 while (parent) { | 1034 while (parent) { |
| 1039 WidgetWin* widget = | 1035 WidgetWin* widget = |
| 1040 reinterpret_cast<WidgetWin*>(ui::GetWindowUserData(parent)); | 1036 reinterpret_cast<WidgetWin*>(ui::GetWindowUserData(parent)); |
| 1041 if (widget && widget->is_window_) | 1037 if (widget && widget->is_window_) |
| 1042 return static_cast<WindowWin*>(widget); | 1038 return static_cast<WindowWin*>(widget); |
| 1043 parent = ::GetParent(parent); | 1039 parent = ::GetParent(parent); |
| 1044 } | 1040 } |
| 1045 return NULL; | 1041 return NULL; |
| 1046 } | 1042 } |
| 1047 | 1043 |
| 1048 RootView* WidgetWin::GetFocusedViewRootView() { | |
| 1049 // TODO(beng): get rid of this | |
| 1050 FocusManager* focus_manager = GetFocusManager(); | |
| 1051 if (!focus_manager) { | |
| 1052 NOTREACHED(); | |
| 1053 return NULL; | |
| 1054 } | |
| 1055 View* focused_view = focus_manager->GetFocusedView(); | |
| 1056 if (!focused_view) | |
| 1057 return NULL; | |
| 1058 return focused_view->GetRootView(); | |
| 1059 } | |
| 1060 | |
| 1061 // static | 1044 // static |
| 1062 void WidgetWin::PostProcessActivateMessage(WidgetWin* widget, | 1045 void WidgetWin::PostProcessActivateMessage(WidgetWin* widget, |
| 1063 int activation_state) { | 1046 int activation_state) { |
| 1064 if (!widget->delegate_->HasFocusManager()) { | 1047 if (!widget->delegate_->HasFocusManager()) { |
| 1065 NOTREACHED(); | 1048 NOTREACHED(); |
| 1066 return; | 1049 return; |
| 1067 } | 1050 } |
| 1068 FocusManager* focus_manager = widget->GetWidget()->GetFocusManager(); | 1051 FocusManager* focus_manager = widget->GetWidget()->GetFocusManager(); |
| 1069 if (WA_INACTIVE == activation_state) { | 1052 if (WA_INACTIVE == activation_state) { |
| 1070 // We might get activated/inactivated without being enabled, so we need to | 1053 // We might get activated/inactivated without being enabled, so we need to |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1135 layered_window_contents_.reset( | 1118 layered_window_contents_.reset( |
| 1136 new gfx::CanvasSkia(s.width(), s.height(), false)); | 1119 new gfx::CanvasSkia(s.width(), s.height(), false)); |
| 1137 } | 1120 } |
| 1138 } | 1121 } |
| 1139 | 1122 |
| 1140 gfx::AcceleratedWidget WidgetWin::GetAcceleratedWidget() { | 1123 gfx::AcceleratedWidget WidgetWin::GetAcceleratedWidget() { |
| 1141 // TODO(beng): | 1124 // TODO(beng): |
| 1142 return gfx::kNullAcceleratedWidget; | 1125 return gfx::kNullAcceleratedWidget; |
| 1143 } | 1126 } |
| 1144 | 1127 |
| 1145 void WidgetWin::DispatchKeyEventPostIME(const KeyEvent& key) { | |
| 1146 RootView* root_view = GetFocusedViewRootView(); | |
| 1147 if (!root_view) | |
| 1148 root_view = GetRootView(); | |
| 1149 | |
| 1150 SetMsgHandled(root_view->ProcessKeyEvent(key)); | |
| 1151 } | |
| 1152 | |
| 1153 //////////////////////////////////////////////////////////////////////////////// | 1128 //////////////////////////////////////////////////////////////////////////////// |
| 1154 // Widget, public: | 1129 // Widget, public: |
| 1155 | 1130 |
| 1156 // static | 1131 // static |
| 1157 Widget* Widget::CreateWidget(const CreateParams& params) { | 1132 Widget* Widget::CreateWidget(const CreateParams& params) { |
| 1158 WidgetWin* widget = new WidgetWin; | 1133 WidgetWin* widget = new WidgetWin; |
| 1159 widget->SetCreateParams(params); | 1134 widget->SetCreateParams(params); |
| 1160 return widget; | 1135 return widget; |
| 1161 } | 1136 } |
| 1162 | 1137 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1310 | 1285 |
| 1311 // And now, notify them that they have a brand new parent. | 1286 // And now, notify them that they have a brand new parent. |
| 1312 for (NativeWidgets::iterator it = widgets.begin(); | 1287 for (NativeWidgets::iterator it = widgets.begin(); |
| 1313 it != widgets.end(); ++it) { | 1288 it != widgets.end(); ++it) { |
| 1314 (*it)->GetWidget()->NotifyNativeViewHierarchyChanged(true, | 1289 (*it)->GetWidget()->NotifyNativeViewHierarchyChanged(true, |
| 1315 new_parent); | 1290 new_parent); |
| 1316 } | 1291 } |
| 1317 } | 1292 } |
| 1318 | 1293 |
| 1319 } // namespace views | 1294 } // namespace views |
| OLD | NEW |