| 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_window.h" | 5 #include "ash/wm_window.h" |
| 6 | 6 |
| 7 #include "ash/ash_constants.h" | 7 #include "ash/ash_constants.h" |
| 8 #include "ash/public/cpp/config.h" | 8 #include "ash/public/cpp/config.h" |
| 9 #include "ash/public/cpp/shell_window_ids.h" | 9 #include "ash/public/cpp/shell_window_ids.h" |
| 10 #include "ash/public/cpp/window_properties.h" | 10 #include "ash/public/cpp/window_properties.h" |
| 11 #include "ash/root_window_controller.h" | 11 #include "ash/root_window_controller.h" |
| 12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 13 #include "ash/wm/resize_handle_window_targeter.h" | 13 #include "ash/wm/resize_handle_window_targeter.h" |
| 14 #include "ash/wm/resize_shadow_controller.h" | |
| 15 #include "ash/wm/widget_finder.h" | 14 #include "ash/wm/widget_finder.h" |
| 16 #include "ash/wm/window_animations.h" | 15 #include "ash/wm/window_animations.h" |
| 17 #include "ash/wm/window_properties.h" | 16 #include "ash/wm/window_properties.h" |
| 18 #include "ash/wm/window_state.h" | 17 #include "ash/wm/window_state.h" |
| 19 #include "ash/wm/window_util.h" | 18 #include "ash/wm/window_util.h" |
| 20 #include "ash/wm_transient_window_observer.h" | 19 #include "ash/wm_transient_window_observer.h" |
| 21 #include "base/memory/ptr_util.h" | 20 #include "base/memory/ptr_util.h" |
| 22 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" | 21 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" |
| 23 #include "ui/aura/client/aura_constants.h" | 22 #include "ui/aura/client/aura_constants.h" |
| 24 #include "ui/aura/client/focus_client.h" | 23 #include "ui/aura/client/focus_client.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 49 | 48 |
| 50 namespace ash { | 49 namespace ash { |
| 51 namespace { | 50 namespace { |
| 52 DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(WmWindow, kWmWindowKey, nullptr); | 51 DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(WmWindow, kWmWindowKey, nullptr); |
| 53 | 52 |
| 54 static_assert(aura::Window::kInitialId == kShellWindowId_Invalid, | 53 static_assert(aura::Window::kInitialId == kShellWindowId_Invalid, |
| 55 "ids must match"); | 54 "ids must match"); |
| 56 | 55 |
| 57 } // namespace | 56 } // namespace |
| 58 | 57 |
| 59 // static | |
| 60 bool WmWindow::default_use_empty_minimum_size_for_testing_ = false; | |
| 61 | |
| 62 WmWindow::~WmWindow() { | 58 WmWindow::~WmWindow() { |
| 63 if (added_transient_observer_) | 59 if (added_transient_observer_) |
| 64 ::wm::TransientWindowManager::Get(window_)->RemoveObserver(this); | 60 ::wm::TransientWindowManager::Get(window_)->RemoveObserver(this); |
| 65 } | 61 } |
| 66 | 62 |
| 67 // static | 63 // static |
| 68 const WmWindow* WmWindow::Get(const aura::Window* window) { | 64 const WmWindow* WmWindow::Get(const aura::Window* window) { |
| 69 if (!window) | 65 if (!window) |
| 70 return nullptr; | 66 return nullptr; |
| 71 | 67 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 144 |
| 149 display::Display WmWindow::GetDisplayNearestWindow() { | 145 display::Display WmWindow::GetDisplayNearestWindow() { |
| 150 return display::Screen::GetScreen()->GetDisplayNearestWindow(window_); | 146 return display::Screen::GetScreen()->GetDisplayNearestWindow(window_); |
| 151 } | 147 } |
| 152 | 148 |
| 153 bool WmWindow::HasNonClientArea() { | 149 bool WmWindow::HasNonClientArea() { |
| 154 return window_->delegate() ? true : false; | 150 return window_->delegate() ? true : false; |
| 155 } | 151 } |
| 156 | 152 |
| 157 int WmWindow::GetNonClientComponent(const gfx::Point& location) { | 153 int WmWindow::GetNonClientComponent(const gfx::Point& location) { |
| 158 return window_->delegate() | 154 return wm::GetNonClientComponent(window_, location); |
| 159 ? window_->delegate()->GetNonClientComponent(location) | |
| 160 : HTNOWHERE; | |
| 161 } | 155 } |
| 162 | 156 |
| 163 gfx::Point WmWindow::ConvertPointToTarget(const WmWindow* target, | 157 gfx::Point WmWindow::ConvertPointToTarget(const WmWindow* target, |
| 164 const gfx::Point& point) const { | 158 const gfx::Point& point) const { |
| 165 gfx::Point result(point); | 159 gfx::Point result(point); |
| 166 aura::Window::ConvertPointToTarget(window_, GetAuraWindow(target), &result); | 160 aura::Window::ConvertPointToTarget(window_, GetAuraWindow(target), &result); |
| 167 return result; | 161 return result; |
| 168 } | 162 } |
| 169 | 163 |
| 170 gfx::Point WmWindow::ConvertPointToScreen(const gfx::Point& point) const { | 164 gfx::Point WmWindow::ConvertPointToScreen(const gfx::Point& point) const { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 185 return result; | 179 return result; |
| 186 } | 180 } |
| 187 | 181 |
| 188 gfx::Rect WmWindow::ConvertRectFromScreen(const gfx::Rect& rect) const { | 182 gfx::Rect WmWindow::ConvertRectFromScreen(const gfx::Rect& rect) const { |
| 189 gfx::Rect result(rect); | 183 gfx::Rect result(rect); |
| 190 ::wm::ConvertRectFromScreen(window_, &result); | 184 ::wm::ConvertRectFromScreen(window_, &result); |
| 191 return result; | 185 return result; |
| 192 } | 186 } |
| 193 | 187 |
| 194 gfx::Size WmWindow::GetMinimumSize() const { | 188 gfx::Size WmWindow::GetMinimumSize() const { |
| 195 return window_->delegate() && !use_empty_minimum_size_for_testing_ | 189 return window_->delegate() ? window_->delegate()->GetMinimumSize() |
| 196 ? window_->delegate()->GetMinimumSize() | 190 : gfx::Size(); |
| 197 : gfx::Size(); | |
| 198 } | 191 } |
| 199 | 192 |
| 200 gfx::Size WmWindow::GetMaximumSize() const { | 193 gfx::Size WmWindow::GetMaximumSize() const { |
| 201 return window_->delegate() ? window_->delegate()->GetMaximumSize() | 194 return window_->delegate() ? window_->delegate()->GetMaximumSize() |
| 202 : gfx::Size(); | 195 : gfx::Size(); |
| 203 } | 196 } |
| 204 | 197 |
| 205 bool WmWindow::GetTargetVisibility() const { | 198 bool WmWindow::GetTargetVisibility() const { |
| 206 return window_->TargetVisibility(); | 199 return window_->TargetVisibility(); |
| 207 } | 200 } |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 } | 503 } |
| 511 | 504 |
| 512 std::vector<WmWindow*> WmWindow::GetChildren() { | 505 std::vector<WmWindow*> WmWindow::GetChildren() { |
| 513 return FromAuraWindows(window_->children()); | 506 return FromAuraWindows(window_->children()); |
| 514 } | 507 } |
| 515 | 508 |
| 516 WmWindow* WmWindow::GetChildByShellWindowId(int id) { | 509 WmWindow* WmWindow::GetChildByShellWindowId(int id) { |
| 517 return Get(window_->GetChildById(id)); | 510 return Get(window_->GetChildById(id)); |
| 518 } | 511 } |
| 519 | 512 |
| 520 void WmWindow::ShowResizeShadow(int component) { | |
| 521 if (Shell::GetAshConfig() == Config::MASH) { | |
| 522 // TODO: http://crbug.com/640773. | |
| 523 return; | |
| 524 } | |
| 525 ResizeShadowController* resize_shadow_controller = | |
| 526 Shell::Get()->resize_shadow_controller(); | |
| 527 if (resize_shadow_controller) | |
| 528 resize_shadow_controller->ShowShadow(window_, component); | |
| 529 } | |
| 530 | |
| 531 void WmWindow::HideResizeShadow() { | |
| 532 if (Shell::GetAshConfig() == Config::MASH) { | |
| 533 // TODO: http://crbug.com/640773. | |
| 534 return; | |
| 535 } | |
| 536 ResizeShadowController* resize_shadow_controller = | |
| 537 Shell::Get()->resize_shadow_controller(); | |
| 538 if (resize_shadow_controller) | |
| 539 resize_shadow_controller->HideShadow(window_); | |
| 540 } | |
| 541 | |
| 542 void WmWindow::InstallResizeHandleWindowTargeter( | 513 void WmWindow::InstallResizeHandleWindowTargeter( |
| 543 ImmersiveFullscreenController* immersive_fullscreen_controller) { | 514 ImmersiveFullscreenController* immersive_fullscreen_controller) { |
| 544 window_->SetEventTargeter(base::MakeUnique<ResizeHandleWindowTargeter>( | 515 window_->SetEventTargeter(base::MakeUnique<ResizeHandleWindowTargeter>( |
| 545 window_, immersive_fullscreen_controller)); | 516 window_, immersive_fullscreen_controller)); |
| 546 } | 517 } |
| 547 | 518 |
| 548 void WmWindow::SetBoundsInScreenBehaviorForChildren( | 519 void WmWindow::SetBoundsInScreenBehaviorForChildren( |
| 549 BoundsInScreenBehavior behavior) { | 520 BoundsInScreenBehavior behavior) { |
| 550 window_->SetProperty( | 521 window_->SetProperty( |
| 551 kUsesScreenCoordinatesKey, | 522 kUsesScreenCoordinatesKey, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 DCHECK(Shell::GetAshConfig() != Config::MASH || | 570 DCHECK(Shell::GetAshConfig() != Config::MASH || |
| 600 Shell::window_tree_client()->WasCreatedByThisClient( | 571 Shell::window_tree_client()->WasCreatedByThisClient( |
| 601 aura::WindowMus::Get(window_))); | 572 aura::WindowMus::Get(window_))); |
| 602 window_->AddPreTargetHandler(handler); | 573 window_->AddPreTargetHandler(handler); |
| 603 } | 574 } |
| 604 | 575 |
| 605 void WmWindow::RemoveLimitedPreTargetHandler(ui::EventHandler* handler) { | 576 void WmWindow::RemoveLimitedPreTargetHandler(ui::EventHandler* handler) { |
| 606 window_->RemovePreTargetHandler(handler); | 577 window_->RemovePreTargetHandler(handler); |
| 607 } | 578 } |
| 608 | 579 |
| 609 WmWindow::WmWindow(aura::Window* window) | 580 WmWindow::WmWindow(aura::Window* window) : window_(window) { |
| 610 : window_(window), | |
| 611 use_empty_minimum_size_for_testing_( | |
| 612 default_use_empty_minimum_size_for_testing_) { | |
| 613 window_->SetProperty(kWmWindowKey, this); | 581 window_->SetProperty(kWmWindowKey, this); |
| 614 } | 582 } |
| 615 | 583 |
| 616 void WmWindow::OnTransientChildAdded(aura::Window* window, | 584 void WmWindow::OnTransientChildAdded(aura::Window* window, |
| 617 aura::Window* transient) { | 585 aura::Window* transient) { |
| 618 for (auto& observer : transient_observers_) | 586 for (auto& observer : transient_observers_) |
| 619 observer.OnTransientChildAdded(this, Get(transient)); | 587 observer.OnTransientChildAdded(this, Get(transient)); |
| 620 } | 588 } |
| 621 | 589 |
| 622 void WmWindow::OnTransientChildRemoved(aura::Window* window, | 590 void WmWindow::OnTransientChildRemoved(aura::Window* window, |
| 623 aura::Window* transient) { | 591 aura::Window* transient) { |
| 624 for (auto& observer : transient_observers_) | 592 for (auto& observer : transient_observers_) |
| 625 observer.OnTransientChildRemoved(this, Get(transient)); | 593 observer.OnTransientChildRemoved(this, Get(transient)); |
| 626 } | 594 } |
| 627 | 595 |
| 628 } // namespace ash | 596 } // namespace ash |
| OLD | NEW |