| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ash/wm/aura/wm_window_aura.h" | 5 #include "ash/wm/aura/wm_window_aura.h" |
| 6 | 6 |
| 7 #include "ash/screen_util.h" | 7 #include "ash/screen_util.h" |
| 8 #include "ash/wm/aura/aura_layout_manager_adapter.h" | 8 #include "ash/wm/aura/aura_layout_manager_adapter.h" |
| 9 #include "ash/wm/aura/wm_globals_aura.h" | 9 #include "ash/wm/aura/wm_globals_aura.h" |
| 10 #include "ash/wm/aura/wm_root_window_controller_aura.h" | 10 #include "ash/wm/aura/wm_root_window_controller_aura.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 return nullptr; | 82 return nullptr; |
| 83 | 83 |
| 84 WmWindow* wm_window = window->GetProperty(kWmWindowKey); | 84 WmWindow* wm_window = window->GetProperty(kWmWindowKey); |
| 85 if (wm_window) | 85 if (wm_window) |
| 86 return wm_window; | 86 return wm_window; |
| 87 // WmWindowAura is owned by the aura::Window. | 87 // WmWindowAura is owned by the aura::Window. |
| 88 return new WmWindowAura(window); | 88 return new WmWindowAura(window); |
| 89 } | 89 } |
| 90 | 90 |
| 91 // static | 91 // static |
| 92 std::vector<WmWindow*> WmWindowAura::FromAuraWindows( |
| 93 const std::vector<aura::Window*>& aura_windows) { |
| 94 std::vector<WmWindow*> result(aura_windows.size()); |
| 95 for (size_t i = 0; i < aura_windows.size(); ++i) |
| 96 result[i] = Get(aura_windows[i]); |
| 97 return result; |
| 98 } |
| 99 |
| 100 // static |
| 92 const aura::Window* WmWindowAura::GetAuraWindow(const WmWindow* wm_window) { | 101 const aura::Window* WmWindowAura::GetAuraWindow(const WmWindow* wm_window) { |
| 93 return static_cast<const WmWindowAura*>(wm_window)->aura_window(); | 102 return static_cast<const WmWindowAura*>(wm_window)->aura_window(); |
| 94 } | 103 } |
| 95 | 104 |
| 96 const WmWindow* WmWindowAura::GetRootWindow() const { | 105 const WmWindow* WmWindowAura::GetRootWindow() const { |
| 97 return Get(window_->GetRootWindow()); | 106 return Get(window_->GetRootWindow()); |
| 98 } | 107 } |
| 99 | 108 |
| 100 WmRootWindowController* WmWindowAura::GetRootWindowController() { | 109 WmRootWindowController* WmWindowAura::GetRootWindowController() { |
| 101 aura::Window* root = window_->GetRootWindow(); | 110 aura::Window* root = window_->GetRootWindow(); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 | 219 |
| 211 WmWindow* WmWindowAura::GetParent() { | 220 WmWindow* WmWindowAura::GetParent() { |
| 212 return Get(window_->parent()); | 221 return Get(window_->parent()); |
| 213 } | 222 } |
| 214 | 223 |
| 215 const WmWindow* WmWindowAura::GetTransientParent() const { | 224 const WmWindow* WmWindowAura::GetTransientParent() const { |
| 216 return Get(::wm::GetTransientParent(window_)); | 225 return Get(::wm::GetTransientParent(window_)); |
| 217 } | 226 } |
| 218 | 227 |
| 219 std::vector<WmWindow*> WmWindowAura::GetTransientChildren() { | 228 std::vector<WmWindow*> WmWindowAura::GetTransientChildren() { |
| 220 const std::vector<aura::Window*> aura_windows( | 229 return FromAuraWindows(::wm::GetTransientChildren(window_)); |
| 221 ::wm::GetTransientChildren(window_)); | |
| 222 std::vector<WmWindow*> wm_windows(aura_windows.size()); | |
| 223 for (size_t i = 0; i < aura_windows.size(); ++i) | |
| 224 wm_windows[i] = Get(aura_windows[i]); | |
| 225 return wm_windows; | |
| 226 } | 230 } |
| 227 | 231 |
| 228 void WmWindowAura::SetLayoutManager( | 232 void WmWindowAura::SetLayoutManager( |
| 229 std::unique_ptr<WmLayoutManager> layout_manager) { | 233 std::unique_ptr<WmLayoutManager> layout_manager) { |
| 230 // |window_| takes ownership of AuraLayoutManagerAdapter. | 234 // |window_| takes ownership of AuraLayoutManagerAdapter. |
| 231 window_->SetLayoutManager( | 235 window_->SetLayoutManager( |
| 232 new AuraLayoutManagerAdapter(std::move(layout_manager))); | 236 new AuraLayoutManagerAdapter(std::move(layout_manager))); |
| 233 } | 237 } |
| 234 | 238 |
| 235 WmLayoutManager* WmWindowAura::GetLayoutManager() { | 239 WmLayoutManager* WmWindowAura::GetLayoutManager() { |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 } | 459 } |
| 456 | 460 |
| 457 void WmWindowAura::Unminimize() { | 461 void WmWindowAura::Unminimize() { |
| 458 window_->SetProperty( | 462 window_->SetProperty( |
| 459 aura::client::kShowStateKey, | 463 aura::client::kShowStateKey, |
| 460 window_->GetProperty(aura::client::kRestoreShowStateKey)); | 464 window_->GetProperty(aura::client::kRestoreShowStateKey)); |
| 461 window_->ClearProperty(aura::client::kRestoreShowStateKey); | 465 window_->ClearProperty(aura::client::kRestoreShowStateKey); |
| 462 } | 466 } |
| 463 | 467 |
| 464 std::vector<WmWindow*> WmWindowAura::GetChildren() { | 468 std::vector<WmWindow*> WmWindowAura::GetChildren() { |
| 465 const std::vector<aura::Window*>& aura_children = window_->children(); | 469 return FromAuraWindows(window_->children()); |
| 466 std::vector<WmWindow*> result(aura_children.size()); | |
| 467 for (size_t i = 0; i < aura_children.size(); ++i) | |
| 468 result[i] = Get(aura_children[i]); | |
| 469 return result; | |
| 470 } | 470 } |
| 471 | 471 |
| 472 WmWindow* WmWindowAura::GetChildByShellWindowId(int id) { | 472 WmWindow* WmWindowAura::GetChildByShellWindowId(int id) { |
| 473 return Get(window_->GetChildById(id)); | 473 return Get(window_->GetChildById(id)); |
| 474 } | 474 } |
| 475 | 475 |
| 476 void WmWindowAura::SnapToPixelBoundaryIfNecessary() { | 476 void WmWindowAura::SnapToPixelBoundaryIfNecessary() { |
| 477 SnapWindowToPixelBoundary(window_); | 477 SnapWindowToPixelBoundary(window_); |
| 478 } | 478 } |
| 479 | 479 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 } | 535 } |
| 536 | 536 |
| 537 void WmWindowAura::OnWindowVisibilityChanging(aura::Window* window, | 537 void WmWindowAura::OnWindowVisibilityChanging(aura::Window* window, |
| 538 bool visible) { | 538 bool visible) { |
| 539 FOR_EACH_OBSERVER(WmWindowObserver, observers_, | 539 FOR_EACH_OBSERVER(WmWindowObserver, observers_, |
| 540 OnWindowVisibilityChanging(this, visible)); | 540 OnWindowVisibilityChanging(this, visible)); |
| 541 } | 541 } |
| 542 | 542 |
| 543 } // namespace wm | 543 } // namespace wm |
| 544 } // namespace ash | 544 } // namespace ash |
| OLD | NEW |