| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1119 new gfx::CanvasSkia(s.width(), s.height(), false)); | 1106 new gfx::CanvasSkia(s.width(), s.height(), false)); |
| 1120 } | 1107 } |
| 1121 } | 1108 } |
| 1122 | 1109 |
| 1123 gfx::AcceleratedWidget WidgetWin::GetAcceleratedWidget() { | 1110 gfx::AcceleratedWidget WidgetWin::GetAcceleratedWidget() { |
| 1124 // TODO(beng): | 1111 // TODO(beng): |
| 1125 return gfx::kNullAcceleratedWidget; | 1112 return gfx::kNullAcceleratedWidget; |
| 1126 } | 1113 } |
| 1127 | 1114 |
| 1128 void WidgetWin::DispatchKeyEventPostIME(const KeyEvent& key) { | 1115 void WidgetWin::DispatchKeyEventPostIME(const KeyEvent& key) { |
| 1129 RootView* root_view = GetFocusedViewRootView(); | 1116 SetMsgHandled(delegate_->OnKeyEvent(key)); |
| 1130 if (!root_view) | |
| 1131 root_view = GetRootView(); | |
| 1132 | |
| 1133 SetMsgHandled(root_view->ProcessKeyEvent(key)); | |
| 1134 } | 1117 } |
| 1135 | 1118 |
| 1136 //////////////////////////////////////////////////////////////////////////////// | 1119 //////////////////////////////////////////////////////////////////////////////// |
| 1137 // Widget, public: | 1120 // Widget, public: |
| 1138 | 1121 |
| 1139 // static | 1122 // static |
| 1140 Widget* Widget::CreateWidget(const CreateParams& params) { | 1123 Widget* Widget::CreateWidget(const CreateParams& params) { |
| 1141 WidgetWin* widget = new WidgetWin; | 1124 WidgetWin* widget = new WidgetWin; |
| 1142 widget->SetCreateParams(params); | 1125 widget->SetCreateParams(params); |
| 1143 return widget; | 1126 return widget; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1250 | 1233 |
| 1251 // And now, notify them that they have a brand new parent. | 1234 // And now, notify them that they have a brand new parent. |
| 1252 for (NativeWidgets::iterator it = widgets.begin(); | 1235 for (NativeWidgets::iterator it = widgets.begin(); |
| 1253 it != widgets.end(); ++it) { | 1236 it != widgets.end(); ++it) { |
| 1254 (*it)->GetWidget()->NotifyNativeViewHierarchyChanged(true, | 1237 (*it)->GetWidget()->NotifyNativeViewHierarchyChanged(true, |
| 1255 new_parent); | 1238 new_parent); |
| 1256 } | 1239 } |
| 1257 } | 1240 } |
| 1258 | 1241 |
| 1259 } // namespace views | 1242 } // namespace views |
| OLD | NEW |