Commit 3553465e authored by Xiaoqian Dai's avatar Xiaoqian Dai Committed by Commit Bot

Fix the window transform during dragging.

If a window has transient children, the transform that's applied during
dragging should be adjusted for the transient children.

See before https://drive.google.com/open?id=1BK_AlNAFGJR9eDZdgvf5MY_rsWaB0YXe
and after https://drive.google.com/open?id=12Mg8VHaEhpTEC40VLHImZC9NroWMayDA

Bug: 823769
Change-Id: Ic04739d8327b5febffcc9ff4430ce1db52ba3194
Reviewed-on: https://chromium-review.googlesource.com/1152505
Commit-Queue: Xiaoqian Dai <xdai@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580009}
parent f88cc10f
...@@ -14,6 +14,9 @@ ...@@ -14,6 +14,9 @@
#include "ash/wm/root_window_finder.h" #include "ash/wm/root_window_finder.h"
#include "ash/wm/splitview/split_view_constants.h" #include "ash/wm/splitview/split_view_constants.h"
#include "ash/wm/splitview/split_view_drag_indicators.h" #include "ash/wm/splitview/split_view_drag_indicators.h"
#include "ash/wm/window_transient_descendant_iterator.h"
#include "ui/gfx/transform_util.h"
#include "ui/wm/core/coordinate_conversion.h"
namespace ash { namespace ash {
...@@ -54,6 +57,23 @@ gfx::Rect GetNewSelectorItemBounds(aura::Window* dragged_window) { ...@@ -54,6 +57,23 @@ gfx::Rect GetNewSelectorItemBounds(aura::Window* dragged_window) {
return last_item->target_bounds(); return last_item->target_bounds();
} }
// Set |transform| to |window| and its transient child windows. |transform| is
// the transform that applies to |window| and needes to be adjusted for the
// transient child windows.
void SetTransform(aura::Window* window, const gfx::Transform& transform) {
gfx::Point target_origin(window->GetTargetBounds().origin());
for (auto* window_iter : wm::GetTransientTreeIterator(window)) {
aura::Window* parent_window = window_iter->parent();
gfx::Rect original_bounds(window_iter->GetTargetBounds());
::wm::ConvertRectToScreen(parent_window, &original_bounds);
gfx::Transform new_transform =
TransformAboutPivot(gfx::Point(target_origin.x() - original_bounds.x(),
target_origin.y() - original_bounds.y()),
transform);
window_iter->SetTransform(new_transform);
}
}
} // namespace } // namespace
TabletModeWindowDragDelegate::TabletModeWindowDragDelegate() TabletModeWindowDragDelegate::TabletModeWindowDragDelegate()
...@@ -163,7 +183,7 @@ void TabletModeWindowDragDelegate::EndWindowDrag( ...@@ -163,7 +183,7 @@ void TabletModeWindowDragDelegate::EndWindowDrag(
if (!dragged_window_->layer()->GetTargetTransform().IsIdentity() && if (!dragged_window_->layer()->GetTargetTransform().IsIdentity() &&
(!GetWindowSelector() || (!GetWindowSelector() ||
!GetWindowSelector()->IsWindowInOverview(dragged_window_))) { !GetWindowSelector()->IsWindowInOverview(dragged_window_))) {
dragged_window_->SetTransform(gfx::Transform()); SetTransform(dragged_window_, gfx::Transform());
} }
dragged_window_ = nullptr; dragged_window_ = nullptr;
...@@ -309,7 +329,7 @@ void TabletModeWindowDragDelegate::UpdateDraggedWindowTransform( ...@@ -309,7 +329,7 @@ void TabletModeWindowDragDelegate::UpdateDraggedWindowTransform(
(location_in_screen.y() - window_bounds.y()) - (location_in_screen.y() - window_bounds.y()) -
(initial_location_in_screen_.y() - window_bounds.y()) * scale); (initial_location_in_screen_.y() - window_bounds.y()) * scale);
transform.Scale(scale, scale); transform.Scale(scale, scale);
dragged_window_->SetTransform(transform); SetTransform(dragged_window_, transform);
} }
} // namespace ash } // namespace ash
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment