Index: ash/wm/system_modal_container_layout_manager.cc |
diff --git a/ash/wm/system_modal_container_layout_manager.cc b/ash/wm/system_modal_container_layout_manager.cc |
index 1a2d65902e38b9fd5c8b8ccc387f8594eb686182..333ae9e70ca41136077b5fd53d1e807f3db1c41d 100644 |
--- a/ash/wm/system_modal_container_layout_manager.cc |
+++ b/ash/wm/system_modal_container_layout_manager.cc |
@@ -13,12 +13,12 @@ |
#include "ash/shell_port.h" |
#include "ash/wm/window_dimmer.h" |
#include "ash/wm/window_util.h" |
-#include "ash/wm_window.h" |
#include "base/memory/ptr_util.h" |
#include "base/stl_util.h" |
#include "ui/aura/client/aura_constants.h" |
#include "ui/aura/window.h" |
#include "ui/keyboard/keyboard_controller.h" |
+#include "ui/wm/core/window_util.h" |
namespace ash { |
namespace { |
@@ -27,13 +27,13 @@ namespace { |
// of the container to be kept centered upon resizing operations. |
const int kCenterPixelDelta = 32; |
-ui::ModalType GetModalType(WmWindow* window) { |
- return static_cast<ui::ModalType>( |
- window->aura_window()->GetProperty(aura::client::kModalKey)); |
+ui::ModalType GetModalType(aura::Window* window) { |
+ return window->GetProperty(aura::client::kModalKey); |
} |
-bool HasTransientAncestor(const WmWindow* window, const WmWindow* ancestor) { |
- const WmWindow* transient_parent = window->GetTransientParent(); |
+bool HasTransientAncestor(const aura::Window* window, |
+ const aura::Window* ancestor) { |
+ const aura::Window* transient_parent = ::wm::GetTransientParent(window); |
if (transient_parent == ancestor) |
return true; |
return transient_parent ? HasTransientAncestor(transient_parent, ancestor) |
@@ -45,7 +45,7 @@ bool HasTransientAncestor(const WmWindow* window, const WmWindow* ancestor) { |
// SystemModalContainerLayoutManager, public: |
SystemModalContainerLayoutManager::SystemModalContainerLayoutManager( |
- WmWindow* container) |
+ aura::Window* container) |
: container_(container) {} |
SystemModalContainerLayoutManager::~SystemModalContainerLayoutManager() { |
@@ -54,10 +54,10 @@ SystemModalContainerLayoutManager::~SystemModalContainerLayoutManager() { |
} |
//////////////////////////////////////////////////////////////////////////////// |
-// SystemModalContainerLayoutManager, WmLayoutManager implementation: |
+// SystemModalContainerLayoutManager, aura::LayoutManager implementation: |
void SystemModalContainerLayoutManager::OnChildWindowVisibilityChanged( |
- WmWindow* window, |
+ aura::Window* window, |
bool visible) { |
if (GetModalType(window) != ui::MODAL_TYPE_SYSTEM) |
return; |
@@ -75,14 +75,14 @@ void SystemModalContainerLayoutManager::OnWindowResized() { |
PositionDialogsAfterWorkAreaResize(); |
} |
-void SystemModalContainerLayoutManager::OnWindowAddedToLayout(WmWindow* child) { |
- DCHECK(child->GetType() == ui::wm::WINDOW_TYPE_NORMAL || |
- child->GetType() == ui::wm::WINDOW_TYPE_POPUP); |
+void SystemModalContainerLayoutManager::OnWindowAddedToLayout( |
+ aura::Window* child) { |
+ DCHECK(child->type() == ui::wm::WINDOW_TYPE_NORMAL || |
+ child->type() == ui::wm::WINDOW_TYPE_POPUP); |
// TODO(mash): IsUserSessionBlocked() depends on knowing the login state. We |
// need a non-stub version of SessionStateDelegate. crbug.com/648964 |
if (Shell::GetAshConfig() != Config::MASH) { |
- DCHECK(container_->aura_window()->id() != |
- kShellWindowId_LockSystemModalContainer || |
+ DCHECK(container_->id() != kShellWindowId_LockSystemModalContainer || |
Shell::Get()->session_controller()->IsUserSessionBlocked()); |
} |
// Since this is for SystemModal, there is no good reason to add windows |
@@ -91,21 +91,21 @@ void SystemModalContainerLayoutManager::OnWindowAddedToLayout(WmWindow* child) { |
DCHECK_NE(GetModalType(child), ui::MODAL_TYPE_CHILD); |
DCHECK_NE(GetModalType(child), ui::MODAL_TYPE_WINDOW); |
- child->aura_window()->AddObserver(this); |
+ child->AddObserver(this); |
if (GetModalType(child) == ui::MODAL_TYPE_SYSTEM && child->IsVisible()) |
AddModalWindow(child); |
} |
void SystemModalContainerLayoutManager::OnWillRemoveWindowFromLayout( |
- WmWindow* child) { |
- child->aura_window()->RemoveObserver(this); |
+ aura::Window* child) { |
+ child->RemoveObserver(this); |
windows_to_center_.erase(child); |
if (GetModalType(child) == ui::MODAL_TYPE_SYSTEM) |
RemoveModalWindow(child); |
} |
void SystemModalContainerLayoutManager::SetChildBounds( |
- WmWindow* child, |
+ aura::Window* child, |
const gfx::Rect& requested_bounds) { |
WmSnapToPixelLayoutManager::SetChildBounds(child, requested_bounds); |
if (IsBoundsCentered(requested_bounds)) |
@@ -124,14 +124,13 @@ void SystemModalContainerLayoutManager::OnWindowPropertyChanged( |
if (key != aura::client::kModalKey || !window->IsVisible()) |
return; |
- WmWindow* wm_window = WmWindow::Get(window); |
if (window->GetProperty(aura::client::kModalKey) == ui::MODAL_TYPE_SYSTEM) { |
- if (base::ContainsValue(modal_windows_, wm_window)) |
+ if (base::ContainsValue(modal_windows_, window)) |
return; |
- AddModalWindow(wm_window); |
+ AddModalWindow(window); |
} else { |
- if (RemoveModalWindow(wm_window)) |
- ShellPort::Get()->OnModalWindowRemoved(wm_window); |
+ if (RemoveModalWindow(window)) |
+ ShellPort::Get()->OnModalWindowRemoved(window); |
} |
} |
@@ -147,23 +146,23 @@ void SystemModalContainerLayoutManager::OnKeyboardBoundsChanging( |
void SystemModalContainerLayoutManager::OnKeyboardClosed() {} |
bool SystemModalContainerLayoutManager::IsPartOfActiveModalWindow( |
- WmWindow* window) { |
+ aura::Window* window) { |
return modal_window() && |
(modal_window()->Contains(window) || |
- HasTransientAncestor(window->GetToplevelWindowForFocus(), |
+ HasTransientAncestor(::wm::GetToplevelWindow(window), |
modal_window())); |
} |
bool SystemModalContainerLayoutManager::ActivateNextModalWindow() { |
if (modal_windows_.empty()) |
return false; |
- modal_window()->Activate(); |
+ wm::ActivateWindow(modal_window()); |
return true; |
} |
void SystemModalContainerLayoutManager::CreateModalBackground() { |
if (!window_dimmer_) { |
- window_dimmer_ = base::MakeUnique<WindowDimmer>(container_->aura_window()); |
+ window_dimmer_ = base::MakeUnique<WindowDimmer>(container_); |
window_dimmer_->window()->SetName( |
"SystemModalContainerLayoutManager.ModalBackground"); |
// There isn't always a keyboard controller. |
@@ -183,24 +182,25 @@ void SystemModalContainerLayoutManager::DestroyModalBackground() { |
} |
// static |
-bool SystemModalContainerLayoutManager::IsModalBackground(WmWindow* window) { |
- int id = window->GetParent()->aura_window()->id(); |
+bool SystemModalContainerLayoutManager::IsModalBackground( |
+ aura::Window* window) { |
+ int id = window->parent()->id(); |
if (id != kShellWindowId_SystemModalContainer && |
id != kShellWindowId_LockSystemModalContainer) |
return false; |
SystemModalContainerLayoutManager* layout_manager = |
static_cast<SystemModalContainerLayoutManager*>( |
- window->GetParent()->GetLayoutManager()); |
+ window->parent()->layout_manager()); |
return layout_manager->window_dimmer_ && |
- WmWindow::Get(layout_manager->window_dimmer_->window()) == window; |
+ layout_manager->window_dimmer_->window() == window; |
} |
//////////////////////////////////////////////////////////////////////////////// |
// SystemModalContainerLayoutManager, private: |
-void SystemModalContainerLayoutManager::AddModalWindow(WmWindow* window) { |
+void SystemModalContainerLayoutManager::AddModalWindow(aura::Window* window) { |
if (modal_windows_.empty()) { |
- WmWindow* capture_window = WmWindow::Get(wm::GetCaptureWindow()); |
+ aura::Window* capture_window = wm::GetCaptureWindow(); |
if (capture_window) |
capture_window->ReleaseCapture(); |
} |
@@ -209,14 +209,15 @@ void SystemModalContainerLayoutManager::AddModalWindow(WmWindow* window) { |
modal_windows_.push_back(window); |
ShellPort::Get()->CreateModalBackground(window); |
- window->GetParent()->StackChildAtTop(window); |
+ window->parent()->StackChildAtTop(window); |
- gfx::Rect target_bounds = window->GetBounds(); |
+ gfx::Rect target_bounds = window->bounds(); |
target_bounds.AdjustToFit(GetUsableDialogArea()); |
window->SetBounds(target_bounds); |
} |
-bool SystemModalContainerLayoutManager::RemoveModalWindow(WmWindow* window) { |
+bool SystemModalContainerLayoutManager::RemoveModalWindow( |
+ aura::Window* window) { |
auto it = std::find(modal_windows_.begin(), modal_windows_.end(), window); |
if (it == modal_windows_.end()) |
return false; |
@@ -228,7 +229,7 @@ void SystemModalContainerLayoutManager::PositionDialogsAfterWorkAreaResize() { |
if (modal_windows_.empty()) |
return; |
- for (WmWindow* window : modal_windows_) |
+ for (aura::Window* window : modal_windows_) |
window->SetBounds(GetCenteredAndOrFittedBounds(window)); |
} |
@@ -236,7 +237,7 @@ gfx::Rect SystemModalContainerLayoutManager::GetUsableDialogArea() const { |
// Instead of resizing the system modal container, we move only the modal |
// windows. This way we avoid flashing lines upon resize animation and if the |
// keyboard will not fill left to right, the background is still covered. |
- gfx::Rect valid_bounds = container_->GetBounds(); |
+ gfx::Rect valid_bounds = container_->bounds(); |
keyboard::KeyboardController* keyboard_controller = |
keyboard::KeyboardController::GetInstance(); |
if (keyboard_controller) { |
@@ -250,23 +251,23 @@ gfx::Rect SystemModalContainerLayoutManager::GetUsableDialogArea() const { |
} |
gfx::Rect SystemModalContainerLayoutManager::GetCenteredAndOrFittedBounds( |
- const WmWindow* window) { |
+ const aura::Window* window) { |
gfx::Rect target_bounds; |
gfx::Rect usable_area = GetUsableDialogArea(); |
if (windows_to_center_.count(window) > 0) { |
// Keep the dialog centered if it was centered before. |
target_bounds = usable_area; |
- target_bounds.ClampToCenteredSize(window->GetBounds().size()); |
+ target_bounds.ClampToCenteredSize(window->bounds().size()); |
} else { |
// Keep the dialog within the usable area. |
- target_bounds = window->GetBounds(); |
+ target_bounds = window->bounds(); |
target_bounds.AdjustToFit(usable_area); |
} |
- if (usable_area != container_->GetBounds()) { |
+ if (usable_area != container_->bounds()) { |
// Don't clamp the dialog for the keyboard. Keep the size as it is but make |
// sure that the top remains visible. |
// TODO(skuhne): M37 should add over scroll functionality to address this. |
- target_bounds.set_size(window->GetBounds().size()); |
+ target_bounds.set_size(window->bounds().size()); |
} |
return target_bounds; |
} |