| 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 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1021 while (parent) { | 1021 while (parent) { |
| 1022 WidgetWin* widget = | 1022 WidgetWin* widget = |
| 1023 reinterpret_cast<WidgetWin*>(ui::GetWindowUserData(parent)); | 1023 reinterpret_cast<WidgetWin*>(ui::GetWindowUserData(parent)); |
| 1024 if (widget && widget->is_window_) | 1024 if (widget && widget->is_window_) |
| 1025 return static_cast<WindowWin*>(widget); | 1025 return static_cast<WindowWin*>(widget); |
| 1026 parent = ::GetParent(parent); | 1026 parent = ::GetParent(parent); |
| 1027 } | 1027 } |
| 1028 return NULL; | 1028 return NULL; |
| 1029 } | 1029 } |
| 1030 | 1030 |
| 1031 RootView* WidgetWin::GetFocusedViewRootView() { | |
| 1032 // TODO(beng): get rid of this | |
| 1033 FocusManager* focus_manager = GetFocusManager(); | |
| 1034 if (!focus_manager) { | |
| 1035 NOTREACHED(); | |
| 1036 return NULL; | |
| 1037 } | |
| 1038 View* focused_view = focus_manager->GetFocusedView(); | |
| 1039 if (!focused_view) | |
| 1040 return NULL; | |
| 1041 return focused_view->GetRootView(); | |
| 1042 } | |
| 1043 | |
| 1044 // static | 1031 // static |
| 1045 void WidgetWin::PostProcessActivateMessage(WidgetWin* widget, | 1032 void WidgetWin::PostProcessActivateMessage(WidgetWin* widget, |
| 1046 int activation_state) { | 1033 int activation_state) { |
| 1047 if (!widget->delegate_->HasFocusManager()) { | 1034 if (!widget->delegate_->HasFocusManager()) { |
| 1048 NOTREACHED(); | 1035 NOTREACHED(); |
| 1049 return; | 1036 return; |
| 1050 } | 1037 } |
| 1051 FocusManager* focus_manager = widget->GetWidget()->GetFocusManager(); | 1038 FocusManager* focus_manager = widget->GetWidget()->GetFocusManager(); |
| 1052 if (WA_INACTIVE == activation_state) { | 1039 if (WA_INACTIVE == activation_state) { |
| 1053 // We might get activated/inactivated without being enabled, so we need to | 1040 // We might get activated/inactivated without being enabled, so we need to |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1122 new gfx::CanvasSkia(s.width(), s.height(), false)); | 1109 new gfx::CanvasSkia(s.width(), s.height(), false)); |
| 1123 } | 1110 } |
| 1124 } | 1111 } |
| 1125 | 1112 |
| 1126 gfx::AcceleratedWidget WidgetWin::GetAcceleratedWidget() { | 1113 gfx::AcceleratedWidget WidgetWin::GetAcceleratedWidget() { |
| 1127 // TODO(beng): | 1114 // TODO(beng): |
| 1128 return gfx::kNullAcceleratedWidget; | 1115 return gfx::kNullAcceleratedWidget; |
| 1129 } | 1116 } |
| 1130 | 1117 |
| 1131 void WidgetWin::DispatchKeyEventPostIME(const KeyEvent& key) { | 1118 void WidgetWin::DispatchKeyEventPostIME(const KeyEvent& key) { |
| 1132 RootView* root_view = GetFocusedViewRootView(); | 1119 SetMsgHandled(delegate_->OnKeyEvent(key)); |
| 1133 if (!root_view) | |
| 1134 root_view = GetRootView(); | |
| 1135 | |
| 1136 SetMsgHandled(root_view->ProcessKeyEvent(key)); | |
| 1137 } | 1120 } |
| 1138 | 1121 |
| 1139 //////////////////////////////////////////////////////////////////////////////// | 1122 //////////////////////////////////////////////////////////////////////////////// |
| 1140 // Widget, public: | 1123 // Widget, public: |
| 1141 | 1124 |
| 1142 // static | 1125 // static |
| 1143 Widget* Widget::CreateWidget(const CreateParams& params) { | 1126 Widget* Widget::CreateWidget(const CreateParams& params) { |
| 1144 WidgetWin* widget = new WidgetWin; | 1127 WidgetWin* widget = new WidgetWin; |
| 1145 widget->SetCreateParams(params); | 1128 widget->SetCreateParams(params); |
| 1146 return widget; | 1129 return widget; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1253 | 1236 |
| 1254 // And now, notify them that they have a brand new parent. | 1237 // And now, notify them that they have a brand new parent. |
| 1255 for (NativeWidgets::iterator it = widgets.begin(); | 1238 for (NativeWidgets::iterator it = widgets.begin(); |
| 1256 it != widgets.end(); ++it) { | 1239 it != widgets.end(); ++it) { |
| 1257 (*it)->GetWidget()->NotifyNativeViewHierarchyChanged(true, | 1240 (*it)->GetWidget()->NotifyNativeViewHierarchyChanged(true, |
| 1258 new_parent); | 1241 new_parent); |
| 1259 } | 1242 } |
| 1260 } | 1243 } |
| 1261 | 1244 |
| 1262 } // namespace views | 1245 } // namespace views |
| OLD | NEW |