| 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/widget/native_widget_aura.h" | 5 #include "ui/views/widget/native_widget_aura.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 } | 781 } |
| 782 | 782 |
| 783 void NativeWidgetAura::RepostNativeEvent(gfx::NativeEvent native_event) { | 783 void NativeWidgetAura::RepostNativeEvent(gfx::NativeEvent native_event) { |
| 784 OnEvent(native_event); | 784 OnEvent(native_event); |
| 785 } | 785 } |
| 786 | 786 |
| 787 std::string NativeWidgetAura::GetName() const { | 787 std::string NativeWidgetAura::GetName() const { |
| 788 return window_ ? window_->GetName() : std::string(); | 788 return window_ ? window_->GetName() : std::string(); |
| 789 } | 789 } |
| 790 | 790 |
| 791 Widget::Widgets NativeWidgetAura::GetAllOwnedTopLevelWidgets() const { |
| 792 // Only the root window is top level. |
| 793 return Widget::Widgets(); |
| 794 } |
| 795 |
| 791 //////////////////////////////////////////////////////////////////////////////// | 796 //////////////////////////////////////////////////////////////////////////////// |
| 792 // NativeWidgetAura, aura::WindowDelegate implementation: | 797 // NativeWidgetAura, aura::WindowDelegate implementation: |
| 793 | 798 |
| 794 gfx::Size NativeWidgetAura::GetMinimumSize() const { | 799 gfx::Size NativeWidgetAura::GetMinimumSize() const { |
| 795 return delegate_->GetMinimumSize(); | 800 return delegate_->GetMinimumSize(); |
| 796 } | 801 } |
| 797 | 802 |
| 798 gfx::Size NativeWidgetAura::GetMaximumSize() const { | 803 gfx::Size NativeWidgetAura::GetMaximumSize() const { |
| 799 // A window should not have a maximum size and also be maximizable. | 804 // A window should not have a maximum size and also be maximizable. |
| 800 DCHECK(delegate_->GetMaximumSize().IsEmpty() || | 805 DCHECK(delegate_->GetMaximumSize().IsEmpty() || |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1134 window = window->parent(); | 1139 window = window->parent(); |
| 1135 } | 1140 } |
| 1136 return top_level_native_widget; | 1141 return top_level_native_widget; |
| 1137 } | 1142 } |
| 1138 | 1143 |
| 1139 // static | 1144 // static |
| 1140 void NativeWidgetPrivate::GetAllChildWidgets(gfx::NativeView native_view, | 1145 void NativeWidgetPrivate::GetAllChildWidgets(gfx::NativeView native_view, |
| 1141 Widget::Widgets* children) { | 1146 Widget::Widgets* children) { |
| 1142 { | 1147 { |
| 1143 // Code expects widget for |native_view| to be added to |children|. | 1148 // Code expects widget for |native_view| to be added to |children|. |
| 1144 NativeWidgetPrivate* native_widget = static_cast<NativeWidgetPrivate*>( | 1149 NativeWidgetPrivate* native_widget = |
| 1145 GetNativeWidgetForNativeView(native_view)); | 1150 GetNativeWidgetForNativeView(native_view); |
| 1146 if (native_widget && native_widget->GetWidget()) | 1151 if (native_widget && native_widget->GetWidget()) |
| 1147 children->insert(native_widget->GetWidget()); | 1152 children->insert(native_widget->GetWidget()); |
| 1148 } | 1153 } |
| 1149 | 1154 |
| 1150 const aura::Window::Windows& child_windows = native_view->children(); | 1155 const aura::Window::Windows& child_windows = native_view->children(); |
| 1151 for (aura::Window::Windows::const_iterator i = child_windows.begin(); | 1156 for (aura::Window::Windows::const_iterator i = child_windows.begin(); |
| 1152 i != child_windows.end(); ++i) { | 1157 i != child_windows.end(); ++i) { |
| 1153 GetAllChildWidgets((*i), children); | 1158 GetAllChildWidgets((*i), children); |
| 1154 } | 1159 } |
| 1155 } | 1160 } |
| 1156 | 1161 |
| 1157 // static | 1162 // static |
| 1158 void NativeWidgetPrivate::GetAllOwnedWidgets(gfx::NativeView native_view, | 1163 void NativeWidgetPrivate::GetAllOwnedWidgets(gfx::NativeView native_view, |
| 1159 Widget::Widgets* owned) { | 1164 Widget::Widgets* owned, |
| 1165 bool include_toplevel) { |
| 1160 // Add all owned widgets. | 1166 // Add all owned widgets. |
| 1161 for (aura::Window* transient_child : wm::GetTransientChildren(native_view)) { | 1167 for (aura::Window* transient_child : wm::GetTransientChildren(native_view)) { |
| 1162 NativeWidgetPrivate* native_widget = static_cast<NativeWidgetPrivate*>( | 1168 NativeWidgetPrivate* native_widget = |
| 1163 GetNativeWidgetForNativeView(transient_child)); | 1169 GetNativeWidgetForNativeView(transient_child); |
| 1164 if (native_widget && native_widget->GetWidget()) | 1170 if (native_widget && native_widget->GetWidget()) |
| 1165 owned->insert(native_widget->GetWidget()); | 1171 owned->insert(native_widget->GetWidget()); |
| 1166 GetAllOwnedWidgets(transient_child, owned); | 1172 GetAllOwnedWidgets(transient_child, owned, include_toplevel); |
| 1167 } | 1173 } |
| 1168 | 1174 |
| 1169 // Add all child windows. | 1175 // Add all child windows. |
| 1170 for (aura::Window* child : native_view->children()) | 1176 for (aura::Window* child : native_view->children()) |
| 1171 GetAllChildWidgets(child, owned); | 1177 GetAllChildWidgets(child, owned); |
| 1178 |
| 1179 if (!include_toplevel) |
| 1180 return; |
| 1181 |
| 1182 // Discover potential top-level children owned via the WindowTreeHost. |
| 1183 NativeWidgetPrivate* native_widget = |
| 1184 GetNativeWidgetForNativeView(native_view); |
| 1185 if (!native_widget) |
| 1186 return; |
| 1187 |
| 1188 for (Widget* child : native_widget->GetAllOwnedTopLevelWidgets()) { |
| 1189 owned->insert(child); |
| 1190 GetAllOwnedWidgets(child->GetNativeView(), owned, true); |
| 1191 } |
| 1172 } | 1192 } |
| 1173 | 1193 |
| 1174 // static | 1194 // static |
| 1175 void NativeWidgetPrivate::ReparentNativeView(gfx::NativeView native_view, | 1195 void NativeWidgetPrivate::ReparentNativeView(gfx::NativeView native_view, |
| 1176 gfx::NativeView new_parent) { | 1196 gfx::NativeView new_parent) { |
| 1177 DCHECK(native_view != new_parent); | 1197 DCHECK(native_view != new_parent); |
| 1178 | 1198 |
| 1179 gfx::NativeView previous_parent = native_view->parent(); | 1199 gfx::NativeView previous_parent = native_view->parent(); |
| 1180 if (previous_parent == new_parent) | 1200 if (previous_parent == new_parent) |
| 1181 return; | 1201 return; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1239 gfx::NativeView native_view) { | 1259 gfx::NativeView native_view) { |
| 1240 aura::client::CaptureClient* capture_client = | 1260 aura::client::CaptureClient* capture_client = |
| 1241 aura::client::GetCaptureClient(native_view->GetRootWindow()); | 1261 aura::client::GetCaptureClient(native_view->GetRootWindow()); |
| 1242 if (!capture_client) | 1262 if (!capture_client) |
| 1243 return nullptr; | 1263 return nullptr; |
| 1244 return capture_client->GetGlobalCaptureWindow(); | 1264 return capture_client->GetGlobalCaptureWindow(); |
| 1245 } | 1265 } |
| 1246 | 1266 |
| 1247 } // namespace internal | 1267 } // namespace internal |
| 1248 } // namespace views | 1268 } // namespace views |
| OLD | NEW |