Commit aa8081c8 authored by Xiaoqian Dai's avatar Xiaoqian Dai Committed by Commit Bot

Start/End resize for attached windows during multi window resizing.

Bug: 945951
Change-Id: Ic7f983f95cff0b54ebffebea87024e524906d92d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1625827
Commit-Queue: Xiaoqian Dai <xdai@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#665596}
parent e7c68b73
...@@ -320,14 +320,38 @@ TEST_F(MultiWindowResizeControllerTest, Three) { ...@@ -320,14 +320,38 @@ TEST_F(MultiWindowResizeControllerTest, Three) {
gfx::Rect bounds(resize_widget()->GetWindowBoundsInScreen()); gfx::Rect bounds(resize_widget()->GetWindowBoundsInScreen());
generator->MoveMouseTo(bounds.x() + 1, bounds.y() + 1); generator->MoveMouseTo(bounds.x() + 1, bounds.y() + 1);
generator->PressLeftButton(); generator->PressLeftButton();
// Test that when drag starts, drag details are created for each window.
EXPECT_TRUE(wm::GetWindowState(w1.get())->is_dragged());
EXPECT_TRUE(wm::GetWindowState(w2.get())->is_dragged());
EXPECT_TRUE(wm::GetWindowState(w3.get())->is_dragged());
// Test the window components for each window.
EXPECT_EQ(wm::GetWindowState(w1.get())->drag_details()->window_component,
HTRIGHT);
EXPECT_EQ(wm::GetWindowState(w2.get())->drag_details()->window_component,
HTLEFT);
EXPECT_EQ(wm::GetWindowState(w3.get())->drag_details()->window_component,
HTLEFT);
generator->MoveMouseTo(bounds.x() + 11, bounds.y() + 10); generator->MoveMouseTo(bounds.x() + 11, bounds.y() + 10);
// Drag details should exist during dragging.
EXPECT_TRUE(wm::GetWindowState(w1.get())->is_dragged());
EXPECT_TRUE(wm::GetWindowState(w2.get())->is_dragged());
EXPECT_TRUE(wm::GetWindowState(w3.get())->is_dragged());
EXPECT_TRUE(HasTarget(w3.get())); EXPECT_TRUE(HasTarget(w3.get()));
// Release the mouse. The resizer should still be visible and a subsequent // Release the mouse. The resizer should still be visible and a subsequent
// press should not trigger a DCHECK. // press should not trigger a DCHECK.
generator->ReleaseLeftButton(); generator->ReleaseLeftButton();
EXPECT_TRUE(IsShowing()); EXPECT_TRUE(IsShowing());
// Test that drag details are correctly deleted after dragging.
EXPECT_FALSE(wm::GetWindowState(w1.get())->is_dragged());
EXPECT_FALSE(wm::GetWindowState(w2.get())->is_dragged());
EXPECT_FALSE(wm::GetWindowState(w3.get())->is_dragged());
generator->PressLeftButton(); generator->PressLeftButton();
} }
......
...@@ -487,6 +487,7 @@ void WorkspaceWindowResizer::CompleteDrag() { ...@@ -487,6 +487,7 @@ void WorkspaceWindowResizer::CompleteDrag() {
::wm::ConvertPointToScreen(GetTarget()->parent(), ::wm::ConvertPointToScreen(GetTarget()->parent(),
&last_mouse_location_in_screen); &last_mouse_location_in_screen);
window_state()->OnCompleteDrag(last_mouse_location_in_screen); window_state()->OnCompleteDrag(last_mouse_location_in_screen);
EndDragForAttachedWindows(/*revert_drag=*/false);
if (!did_move_or_resize_) if (!did_move_or_resize_)
return; return;
...@@ -550,6 +551,7 @@ void WorkspaceWindowResizer::RevertDrag() { ...@@ -550,6 +551,7 @@ void WorkspaceWindowResizer::RevertDrag() {
::wm::ConvertPointToScreen(GetTarget()->parent(), ::wm::ConvertPointToScreen(GetTarget()->parent(),
&last_mouse_location_in_screen); &last_mouse_location_in_screen);
window_state()->OnRevertDrag(last_mouse_location_in_screen); window_state()->OnRevertDrag(last_mouse_location_in_screen);
EndDragForAttachedWindows(/*revert_drag=*/true);
window_state()->set_bounds_changed_by_user(initial_bounds_changed_by_user_); window_state()->set_bounds_changed_by_user(initial_bounds_changed_by_user_);
snap_phantom_window_controller_.reset(); snap_phantom_window_controller_.reset();
...@@ -687,6 +689,7 @@ WorkspaceWindowResizer::WorkspaceWindowResizer( ...@@ -687,6 +689,7 @@ WorkspaceWindowResizer::WorkspaceWindowResizer(
pre_drag_window_bounds_ = window_state->window()->bounds(); pre_drag_window_bounds_ = window_state->window()->bounds();
window_state->OnDragStarted(details().window_component); window_state->OnDragStarted(details().window_component);
StartDragForAttachedWindows();
} }
void WorkspaceWindowResizer::LayoutAttachedWindows(gfx::Rect* bounds) { void WorkspaceWindowResizer::LayoutAttachedWindows(gfx::Rect* bounds) {
...@@ -1195,4 +1198,43 @@ void WorkspaceWindowResizer::SetWindowStateTypeFromGesture( ...@@ -1195,4 +1198,43 @@ void WorkspaceWindowResizer::SetWindowStateTypeFromGesture(
} }
} }
void WorkspaceWindowResizer::StartDragForAttachedWindows() {
if (attached_windows_.empty())
return;
// The component of the attached windows is always the opposite component of
// the main window.
const int main_window_component = details().window_component;
DCHECK(main_window_component == HTRIGHT || main_window_component == HTBOTTOM);
int window_component = HTNOWHERE;
if (main_window_component == HTRIGHT)
window_component = HTLEFT;
else if (main_window_component == HTBOTTOM)
window_component = HTTOP;
DCHECK(window_component == HTLEFT || window_component == HTTOP);
for (auto* window : attached_windows_) {
wm::WindowState* window_state = wm::GetWindowState(window);
window_state->CreateDragDetails(details().initial_location_in_parent,
window_component,
::wm::WINDOW_MOVE_SOURCE_MOUSE);
window_state->OnDragStarted(window_component);
}
}
void WorkspaceWindowResizer::EndDragForAttachedWindows(bool revert_drag) {
if (attached_windows_.empty())
return;
for (auto* window : attached_windows_) {
wm::WindowState* window_state = wm::GetWindowState(window);
if (revert_drag)
window_state->OnRevertDrag(last_mouse_location_);
else
window_state->OnCompleteDrag(last_mouse_location_);
window_state->DeleteDragDetails();
}
}
} // namespace ash } // namespace ash
...@@ -166,6 +166,10 @@ class ASH_EXPORT WorkspaceWindowResizer : public WindowResizer { ...@@ -166,6 +166,10 @@ class ASH_EXPORT WorkspaceWindowResizer : public WindowResizer {
void SetWindowStateTypeFromGesture(aura::Window* window, void SetWindowStateTypeFromGesture(aura::Window* window,
WindowStateType new_state_type); WindowStateType new_state_type);
// Start/End drag for attached windows if there is any.
void StartDragForAttachedWindows();
void EndDragForAttachedWindows(bool revert_drag);
wm::WindowState* window_state() { return window_state_; } wm::WindowState* window_state() { return window_state_; }
const std::vector<aura::Window*> attached_windows_; const std::vector<aura::Window*> attached_windows_;
......
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