Commit bbcefe48 authored by Avery Musbach's avatar Avery Musbach Committed by Commit Bot

overview: Avoid ending overview because of window activation change while an...

overview: Avoid ending overview because of window activation change while an overview item is being dragged

The present CL aims to address a problem similar to [1]. [2] addresses
[1] by modifying OverviewSession:OnWindowActivating() to avoid ending
overview while there exists a window in a dragged state. That solution
is fine for workflows where a window is dragged from the top in tablet
mode, but there is a similar problem (possibly introduced by [3], which
I have reverted but would like to reland) involving overview item
dragging, which is handled by OverviewWindowDragController and does not
put any window in a dragged state.

[1] https://crbug.com/955814
[2] https://chromium-review.googlesource.com/c/chromium/src/+/1626542
[3] https://chromium-review.googlesource.com/c/chromium/src/+/1627562

Bug: 961170, 967196
Change-Id: I059127b88b343ea56a995bd7b815d5f434877064
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1633109Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Commit-Queue: Avery Musbach <amusbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664370}
parent 143f0359
...@@ -143,19 +143,6 @@ gfx::Rect GetGridBoundsInScreen(aura::Window* root_window, ...@@ -143,19 +143,6 @@ gfx::Rect GetGridBoundsInScreen(aura::Window* root_window,
return bounds; return bounds;
} }
bool IsWindowDragInProgress() {
auto windows = Shell::Get()->mru_window_tracker()->BuildMruWindowList();
for (auto* window : windows) {
wm::WindowState* window_state = wm::GetWindowState(window);
if (window_state && window_state->is_dragged() &&
(window_state->drag_details()->window_component == HTCLIENT ||
window_state->drag_details()->window_component == HTCAPTION)) {
return true;
}
}
return false;
}
} // namespace } // namespace
OverviewSession::OverviewSession(OverviewDelegate* delegate) OverviewSession::OverviewSession(OverviewDelegate* delegate)
...@@ -716,9 +703,13 @@ void OverviewSession::OnWindowActivating( ...@@ -716,9 +703,13 @@ void OverviewSession::OnWindowActivating(
// Don't restore focus on exit if a window was just activated. // Don't restore focus on exit if a window was just activated.
ResetFocusRestoreWindow(false); ResetFocusRestoreWindow(false);
// Do not cancel overview mode if a window drag in progress. // Do not cancel overview mode while a window or overview item is being
if (IsWindowDragInProgress()) // dragged as evidenced by the presence of a drop target. (Dragging to close
return; // does not count; canceling overview mode is okay then.)
for (std::unique_ptr<OverviewGrid>& overview_grid : grid_list_) {
if (overview_grid->GetDropTarget())
return;
}
const auto& windows = grid->window_list(); const auto& windows = grid->window_list();
auto iter = std::find_if( auto iter = std::find_if(
...@@ -1018,12 +1009,8 @@ void OverviewSession::OnDisplayBoundsChanged() { ...@@ -1018,12 +1009,8 @@ void OverviewSession::OnDisplayBoundsChanged() {
} }
void OverviewSession::MaybeCreateAndPositionNoWindowsWidget() { void OverviewSession::MaybeCreateAndPositionNoWindowsWidget() {
// Hide the widget if there is an item in overview or there are none but there // Hide the widget if there is an item in overview.
// is a window drag in progress. It is possible for a window drag to be in if (!IsEmpty()) {
// progress when we notify that split view has started so check for that case.
if (!IsEmpty() ||
(IsWindowDragInProgress() &&
!Shell::Get()->split_view_controller()->InSplitViewMode())) {
no_windows_widget_.reset(); no_windows_widget_.reset();
return; return;
} }
......
...@@ -1063,6 +1063,60 @@ TEST_F(OverviewSessionTest, ActivateAnotherWindowDuringDragNotCancelOverview) { ...@@ -1063,6 +1063,60 @@ TEST_F(OverviewSessionTest, ActivateAnotherWindowDuringDragNotCancelOverview) {
EXPECT_TRUE(InOverviewSession()); EXPECT_TRUE(InOverviewSession());
} }
// Tests that if an overview item is dragged, the activation of the
// corresponding window does not cancel overview.
TEST_F(OverviewSessionTest, ActivateDraggedOverviewWindowNotCancelOverview) {
UpdateDisplay("800x600");
EnterTabletMode();
std::unique_ptr<aura::Window> window(CreateTestWindow());
ToggleOverview();
OverviewItem* item = GetWindowItemForWindow(0, window.get());
gfx::PointF drag_point = item->target_bounds().CenterPoint();
overview_session()->InitiateDrag(item, drag_point);
drag_point.Offset(5.f, 0.f);
overview_session()->Drag(item, drag_point);
::wm::ActivateWindow(window.get());
EXPECT_TRUE(InOverviewSession());
}
// Tests that if an overview item is dragged, the activation of the window
// corresponding to another overview item does not cancel overview.
TEST_F(OverviewSessionTest,
ActivateAnotherOverviewWindowDuringOverviewDragNotCancelOverview) {
UpdateDisplay("800x600");
EnterTabletMode();
std::unique_ptr<aura::Window> window1(CreateTestWindow());
std::unique_ptr<aura::Window> window2(CreateTestWindow());
ToggleOverview();
OverviewItem* item1 = GetWindowItemForWindow(0, window1.get());
gfx::PointF drag_point = item1->target_bounds().CenterPoint();
overview_session()->InitiateDrag(item1, drag_point);
drag_point.Offset(5.f, 0.f);
overview_session()->Drag(item1, drag_point);
::wm::ActivateWindow(window2.get());
EXPECT_TRUE(InOverviewSession());
}
// Tests that if an overview item is dragged, the activation of a window
// excluded from overview does not cancel overview.
TEST_F(OverviewSessionTest,
ActivateWindowExcludedFromOverviewDuringOverviewDragNotCancelOverview) {
UpdateDisplay("800x600");
EnterTabletMode();
std::unique_ptr<aura::Window> window1(CreateTestWindow());
std::unique_ptr<aura::Window> window2(
CreateTestWindow(gfx::Rect(), aura::client::WINDOW_TYPE_POPUP));
EXPECT_TRUE(wm::ShouldExcludeForOverview(window2.get()));
ToggleOverview();
OverviewItem* item1 = GetWindowItemForWindow(0, window1.get());
gfx::PointF drag_point = item1->target_bounds().CenterPoint();
overview_session()->InitiateDrag(item1, drag_point);
drag_point.Offset(5.f, 0.f);
overview_session()->Drag(item1, drag_point);
::wm::ActivateWindow(window2.get());
EXPECT_TRUE(InOverviewSession());
}
// Tests that exiting overview mode without selecting a window restores focus // Tests that exiting overview mode without selecting a window restores focus
// to the previously focused window. // to the previously focused window.
TEST_F(OverviewSessionTest, CancelRestoresFocus) { TEST_F(OverviewSessionTest, CancelRestoresFocus) {
......
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