Chromium Code Reviews| Index: ash/wm/panels/panel_window_resizer.cc |
| diff --git a/ash/wm/panels/panel_window_resizer.cc b/ash/wm/panels/panel_window_resizer.cc |
| index c54fc7acc776dd4ec0f3657d7b5eabf6f1fdddd0..7e35de5ec7d0bb5910e607574919265470c18d13 100644 |
| --- a/ash/wm/panels/panel_window_resizer.cc |
| +++ b/ash/wm/panels/panel_window_resizer.cc |
| @@ -13,10 +13,12 @@ |
| #include "ash/wm/window_parenting_utils.h" |
| #include "ash/wm/window_state.h" |
| #include "ash/wm_window.h" |
| +#include "ui/aura/client/window_parenting_client.h" |
| #include "ui/base/hit_test.h" |
| #include "ui/base/ui_base_types.h" |
| #include "ui/display/display.h" |
| #include "ui/display/screen.h" |
| +#include "ui/wm/core/coordinate_conversion.h" |
| namespace ash { |
| @@ -36,7 +38,8 @@ PanelWindowResizer* PanelWindowResizer::Create( |
| } |
| void PanelWindowResizer::Drag(const gfx::Point& location, int event_flags) { |
| - last_location_ = GetTarget()->GetParent()->ConvertPointToScreen(location); |
| + last_location_ = location; |
| + ::wm::ConvertPointToScreen(GetTarget()->parent(), &last_location_); |
| if (!did_move_or_resize_) { |
| did_move_or_resize_ = true; |
| StartedDragging(); |
| @@ -47,24 +50,25 @@ void PanelWindowResizer::Drag(const gfx::Point& location, int event_flags) { |
| const display::Display dst_display = |
| screen->GetDisplayNearestPoint(last_location_); |
| if (dst_display.id() != |
| - panel_container_->GetRootWindow()->GetDisplayNearestWindow().id()) { |
| + display::Screen::GetScreen() |
| + ->GetDisplayNearestWindow(panel_container_->GetRootWindow()) |
|
msw
2017/05/22 19:26:11
optional nit: ->GetRootWindow() may not be needed.
sky
2017/05/22 19:50:58
You are right. Removed.
|
| + .id()) { |
| // The panel is being dragged to a new display. If the previous container is |
| // the current parent of the panel it will be informed of the end of drag |
| // when the panel is reparented, otherwise let the previous container know |
| // the drag is complete. If we told the panel's parent that the drag was |
| // complete it would begin positioning the panel. |
| - if (GetTarget()->GetParent() != panel_container_) |
| - PanelLayoutManager::Get(panel_container_)->FinishDragging(); |
| - WmWindow* dst_root = |
| + if (GetTarget()->parent() != panel_container_) |
| + GetPanelLayoutManager()->FinishDragging(); |
| + aura::Window* dst_root = |
| Shell::GetRootWindowControllerWithDisplayId(dst_display.id()) |
| - ->GetWindow(); |
| - panel_container_ = |
| - dst_root->GetChildByShellWindowId(kShellWindowId_PanelContainer); |
| + ->GetRootWindow(); |
| + panel_container_ = dst_root->GetChildById(kShellWindowId_PanelContainer); |
| // The panel's parent already knows that the drag is in progress for this |
| // panel. |
| - if (panel_container_ && GetTarget()->GetParent() != panel_container_) |
| - PanelLayoutManager::Get(panel_container_)->StartDragging(GetTarget()); |
| + if (panel_container_ && GetTarget()->parent() != panel_container_) |
| + GetPanelLayoutManager()->StartDragging(WmWindow::Get(GetTarget())); |
| } |
| gfx::Point offset; |
| gfx::Rect bounds(CalculateBoundsForDrag(location)); |
| @@ -105,11 +109,11 @@ PanelWindowResizer::PanelWindowResizer(WindowResizer* next_window_resizer, |
| panel_container_(NULL), |
| initial_panel_container_(NULL), |
| did_move_or_resize_(false), |
| - was_attached_(GetTarget()->aura_window()->GetProperty(kPanelAttachedKey)), |
| + was_attached_(GetTarget()->GetProperty(kPanelAttachedKey)), |
| weak_ptr_factory_(this) { |
| DCHECK(details().is_resizable); |
| - panel_container_ = GetTarget()->GetRootWindow()->GetChildByShellWindowId( |
| - kShellWindowId_PanelContainer); |
| + panel_container_ = |
| + GetTarget()->GetRootWindow()->GetChildById(kShellWindowId_PanelContainer); |
| initial_panel_container_ = panel_container_; |
| } |
| @@ -117,10 +121,10 @@ bool PanelWindowResizer::AttachToLauncher(const gfx::Rect& bounds, |
| gfx::Point* offset) { |
| bool should_attach = false; |
| if (panel_container_) { |
| - PanelLayoutManager* panel_layout_manager = |
| - PanelLayoutManager::Get(panel_container_); |
| - gfx::Rect launcher_bounds = GetTarget()->GetParent()->ConvertRectFromScreen( |
| - panel_layout_manager->shelf()->GetWindow()->GetBoundsInScreen()); |
| + PanelLayoutManager* panel_layout_manager = GetPanelLayoutManager(); |
| + gfx::Rect launcher_bounds = |
| + panel_layout_manager->shelf()->GetWindow()->GetBoundsInScreen(); |
| + ::wm::ConvertRectFromScreen(GetTarget()->parent(), &launcher_bounds); |
| switch (panel_layout_manager->shelf()->GetAlignment()) { |
| case SHELF_ALIGNMENT_BOTTOM: |
| case SHELF_ALIGNMENT_BOTTOM_LOCKED: |
| @@ -153,55 +157,57 @@ void PanelWindowResizer::StartedDragging() { |
| // Tell the panel layout manager that we are dragging this panel before |
| // attaching it so that it does not get repositioned. |
| if (panel_container_) |
| - PanelLayoutManager::Get(panel_container_)->StartDragging(GetTarget()); |
| + GetPanelLayoutManager()->StartDragging(WmWindow::Get(GetTarget())); |
| if (!was_attached_) { |
| // Attach the panel while dragging, placing it in front of other panels. |
| - WmWindow* target = GetTarget(); |
| - target->aura_window()->SetProperty(kPanelAttachedKey, true); |
| + aura::Window* target = GetTarget(); |
| + target->SetProperty(kPanelAttachedKey, true); |
| // We use root window coordinates to ensure that during the drag the panel |
| // is reparented to a container in the root window that has that window. |
| - WmWindow* target_root = target->GetRootWindow(); |
| - aura::Window* old_parent = target->aura_window()->parent(); |
| - target->SetParentUsingContext(target_root, |
| - target_root->GetBoundsInScreen()); |
| - wm::ReparentTransientChildrenOfChild(target->aura_window(), old_parent, |
| - target->aura_window()->parent()); |
| + aura::Window* target_root = target->GetRootWindow(); |
| + aura::Window* old_parent = target->parent(); |
| + aura::client::ParentWindowWithContext(target, target_root, |
| + target_root->GetBoundsInScreen()); |
| + wm::ReparentTransientChildrenOfChild(target, old_parent, target->parent()); |
| } |
| } |
| void PanelWindowResizer::FinishDragging() { |
| if (!did_move_or_resize_) |
| return; |
| - if (GetTarget()->aura_window()->GetProperty(kPanelAttachedKey) != |
| + if (GetTarget()->GetProperty(kPanelAttachedKey) != |
| details().should_attach_to_shelf) { |
| - GetTarget()->aura_window()->SetProperty(kPanelAttachedKey, |
| - details().should_attach_to_shelf); |
| + GetTarget()->SetProperty(kPanelAttachedKey, |
| + details().should_attach_to_shelf); |
| // We use last known location to ensure that after the drag the panel |
| // is reparented to a container in the root window that has that location. |
| - WmWindow* target = GetTarget(); |
| - WmWindow* target_root = target->GetRootWindow(); |
| - aura::Window* old_parent = target->aura_window()->parent(); |
| - target->SetParentUsingContext(target_root, |
| - target_root->GetBoundsInScreen()); |
| - wm::ReparentTransientChildrenOfChild(target->aura_window(), old_parent, |
| - target->aura_window()->parent()); |
| + aura::Window* target = GetTarget(); |
| + aura::Window* target_root = target->GetRootWindow(); |
| + aura::Window* old_parent = target->parent(); |
| + aura::client::ParentWindowWithContext(target, target_root, |
| + target_root->GetBoundsInScreen()); |
| + wm::ReparentTransientChildrenOfChild(target, old_parent, target->parent()); |
| } |
| // If we started the drag in one root window and moved into another root |
| // but then canceled the drag we may need to inform the original layout |
| // manager that the drag is finished. |
| if (initial_panel_container_ != panel_container_) |
|
msw
2017/05/22 19:26:11
optional nit: curlies
sky
2017/05/22 19:50:58
Done.
|
| - PanelLayoutManager::Get(initial_panel_container_)->FinishDragging(); |
| + PanelLayoutManager::Get(WmWindow::Get(initial_panel_container_)) |
| + ->FinishDragging(); |
| if (panel_container_) |
| - PanelLayoutManager::Get(panel_container_)->FinishDragging(); |
| + GetPanelLayoutManager()->FinishDragging(); |
| } |
| void PanelWindowResizer::UpdateLauncherPosition() { |
| if (panel_container_) { |
| - PanelLayoutManager::Get(panel_container_) |
| - ->shelf() |
| - ->UpdateIconPositionForPanel(GetTarget()); |
| + GetPanelLayoutManager()->shelf()->UpdateIconPositionForPanel( |
| + WmWindow::Get(GetTarget())); |
| } |
| } |
| +PanelLayoutManager* PanelWindowResizer::GetPanelLayoutManager() { |
| + return PanelLayoutManager::Get(WmWindow::Get(panel_container_)); |
| +} |
| + |
| } // namespace ash |