| 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 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1011 while (parent) { | 1011 while (parent) { |
| 1012 WidgetWin* widget = | 1012 WidgetWin* widget = |
| 1013 reinterpret_cast<WidgetWin*>(ui::GetWindowUserData(parent)); | 1013 reinterpret_cast<WidgetWin*>(ui::GetWindowUserData(parent)); |
| 1014 if (widget && widget->is_window_) | 1014 if (widget && widget->is_window_) |
| 1015 return static_cast<WindowWin*>(widget); | 1015 return static_cast<WindowWin*>(widget); |
| 1016 parent = ::GetParent(parent); | 1016 parent = ::GetParent(parent); |
| 1017 } | 1017 } |
| 1018 return NULL; | 1018 return NULL; |
| 1019 } | 1019 } |
| 1020 | 1020 |
| 1021 RootView* WidgetWin::GetFocusedViewRootView() { | |
| 1022 // TODO(beng): get rid of this | |
| 1023 FocusManager* focus_manager = GetFocusManager(); | |
| 1024 if (!focus_manager) { | |
| 1025 NOTREACHED(); | |
| 1026 return NULL; | |
| 1027 } | |
| 1028 View* focused_view = focus_manager->GetFocusedView(); | |
| 1029 if (!focused_view) | |
| 1030 return NULL; | |
| 1031 return focused_view->GetRootView(); | |
| 1032 } | |
| 1033 | |
| 1034 // static | 1021 // static |
| 1035 void WidgetWin::PostProcessActivateMessage(WidgetWin* widget, | 1022 void WidgetWin::PostProcessActivateMessage(WidgetWin* widget, |
| 1036 int activation_state) { | 1023 int activation_state) { |
| 1037 if (!widget->delegate_->HasFocusManager()) { | 1024 if (!widget->delegate_->HasFocusManager()) { |
| 1038 NOTREACHED(); | 1025 NOTREACHED(); |
| 1039 return; | 1026 return; |
| 1040 } | 1027 } |
| 1041 FocusManager* focus_manager = widget->GetWidget()->GetFocusManager(); | 1028 FocusManager* focus_manager = widget->GetWidget()->GetFocusManager(); |
| 1042 if (WA_INACTIVE == activation_state) { | 1029 if (WA_INACTIVE == activation_state) { |
| 1043 // We might get activated/inactivated without being enabled, so we need to | 1030 // 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... |
| 1109 new gfx::CanvasSkia(s.width(), s.height(), false)); | 1096 new gfx::CanvasSkia(s.width(), s.height(), false)); |
| 1110 } | 1097 } |
| 1111 } | 1098 } |
| 1112 | 1099 |
| 1113 gfx::AcceleratedWidget WidgetWin::GetAcceleratedWidget() { | 1100 gfx::AcceleratedWidget WidgetWin::GetAcceleratedWidget() { |
| 1114 // TODO(beng): | 1101 // TODO(beng): |
| 1115 return gfx::kNullAcceleratedWidget; | 1102 return gfx::kNullAcceleratedWidget; |
| 1116 } | 1103 } |
| 1117 | 1104 |
| 1118 void WidgetWin::DispatchKeyEventPostIME(const KeyEvent& key) { | 1105 void WidgetWin::DispatchKeyEventPostIME(const KeyEvent& key) { |
| 1119 RootView* root_view = GetFocusedViewRootView(); | 1106 SetMsgHandled(delegate_->OnKeyEvent(key)); |
| 1120 if (!root_view) | |
| 1121 root_view = GetRootView(); | |
| 1122 | |
| 1123 SetMsgHandled(root_view->ProcessKeyEvent(key)); | |
| 1124 } | 1107 } |
| 1125 | 1108 |
| 1126 //////////////////////////////////////////////////////////////////////////////// | 1109 //////////////////////////////////////////////////////////////////////////////// |
| 1127 // Widget, public: | 1110 // Widget, public: |
| 1128 | 1111 |
| 1129 // static | 1112 // static |
| 1130 Widget* Widget::CreateWidget(const CreateParams& params) { | 1113 Widget* Widget::CreateWidget(const CreateParams& params) { |
| 1131 WidgetWin* widget = new WidgetWin; | 1114 WidgetWin* widget = new WidgetWin; |
| 1132 widget->SetCreateParams(params); | 1115 widget->SetCreateParams(params); |
| 1133 return widget; | 1116 return widget; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1240 | 1223 |
| 1241 // And now, notify them that they have a brand new parent. | 1224 // And now, notify them that they have a brand new parent. |
| 1242 for (NativeWidgets::iterator it = widgets.begin(); | 1225 for (NativeWidgets::iterator it = widgets.begin(); |
| 1243 it != widgets.end(); ++it) { | 1226 it != widgets.end(); ++it) { |
| 1244 (*it)->GetWidget()->NotifyNativeViewHierarchyChanged(true, | 1227 (*it)->GetWidget()->NotifyNativeViewHierarchyChanged(true, |
| 1245 new_parent); | 1228 new_parent); |
| 1246 } | 1229 } |
| 1247 } | 1230 } |
| 1248 | 1231 |
| 1249 } // namespace views | 1232 } // namespace views |
| OLD | NEW |