Commit 3b7fe2e0 authored by Avery Musbach's avatar Avery Musbach Committed by Commit Bot

split view: Ignore overview windows in clamshell/tablet carry over logic

In transition between clamshell mode and tablet mode, overview windows
shall be ignored when checking the topmost two windows to see if they
should carry over to split view. In other words, the topmost two non-
overview windows shall be considered for carrying over to split view.

Test: ash_unittests SplitViewTabDraggingTestWithClamshellSupport.DragTabFromSnappedWindowToOverviewAndThenExitTablet
Bug: 1004195, 1004426
Change-Id: I0a19891042678be4d80f74e3124b30bf54b0dc55
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1808790Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Commit-Queue: Avery Musbach <amusbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#697302}
parent d5854a4d
......@@ -15,6 +15,7 @@
#include "ash/display/screen_orientation_controller_test_api.h"
#include "ash/magnifier/docked_magnifier_controller_impl.h"
#include "ash/public/cpp/app_types.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/fps_counter.h"
#include "ash/public/cpp/presentation_time_recorder.h"
#include "ash/public/cpp/window_properties.h"
......@@ -49,6 +50,7 @@
#include "ash/wm/wm_event.h"
#include "base/stl_util.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/test/test_window_delegate.h"
#include "ui/aura/test/test_windows.h"
......@@ -4141,6 +4143,57 @@ TEST_F(SplitViewTabDraggingTest, IgnoreActivatedTabDraggingWindow) {
EXPECT_FALSE(Shell::Get()->overview_controller()->InOverviewSession());
}
class SplitViewTabDraggingTestWithClamshellSupport
: public SplitViewTabDraggingTest {
public:
SplitViewTabDraggingTestWithClamshellSupport() = default;
~SplitViewTabDraggingTestWithClamshellSupport() override = default;
void SetUp() override {
scoped_feature_list_.InitAndEnableFeature(
ash::features::kDragToSnapInClamshellMode);
SplitViewTabDraggingTest::SetUp();
}
private:
base::test::ScopedFeatureList scoped_feature_list_;
DISALLOW_COPY_AND_ASSIGN(SplitViewTabDraggingTestWithClamshellSupport);
};
TEST_F(SplitViewTabDraggingTestWithClamshellSupport,
DragTabFromSnappedWindowToOverviewAndThenExitTablet) {
// Snap a browser window in split view.
std::unique_ptr<aura::Window> snapped_window(
CreateWindowWithType(gfx::Rect(), AppType::BROWSER));
ToggleOverview();
split_view_controller()->SnapWindow(snapped_window.get(),
SplitViewController::LEFT);
// Drag a tab out of the browser window and into overview.
std::unique_ptr<aura::Window> dragged_tab(
CreateWindowWithType(gfx::Rect(), AppType::BROWSER));
std::unique_ptr<WindowResizer> resizer =
StartDrag(dragged_tab.get(), snapped_window.get());
DragWindowTo(resizer.get(),
gfx::ToEnclosingRect(
Shell::Get()
->overview_controller()
->overview_session()
->GetGridWithRootWindow(snapped_window->GetRootWindow())
->GetDropTarget()
->target_bounds())
.CenterPoint());
CompleteDrag(std::move(resizer));
EXPECT_TRUE(dragged_tab->GetProperty(kIsShowingInOverviewKey));
// Switch to clamshell mode and check that |snapped_window| keeps its snapped
// window state.
Shell::Get()->tablet_mode_controller()->SetEnabledForTest(false);
EXPECT_EQ(WindowStateType::kLeftSnapped,
WindowState::Get(snapped_window.get())->GetStateType());
}
class TestWindowDelegateWithWidget : public views::WidgetDelegate {
public:
TestWindowDelegateWithWidget(bool can_activate)
......
......@@ -42,7 +42,7 @@ namespace {
// This function is called to check if window[i] is eligible to be carried over
// to split view mode during clamshell <-> tablet mode transition or multi-user
// switch transition. Returns true if windows[i] exists, can snap in split view,
// is not showing in overview, and is not ARC window.
// and is not an ARC window.
// TODO(xdai): Make it work for ARC windows. (see
// https://crbug.com/922282 and
// https://buganizer.corp.google.com/issues/123432223).
......@@ -50,7 +50,6 @@ bool IsCarryOverCandidateForSplitView(
const MruWindowTracker::WindowList& windows,
size_t i) {
return windows.size() > i && CanSnapInSplitview(windows[i]) &&
!windows[i]->GetProperty(kIsShowingInOverviewKey) &&
static_cast<ash::AppType>(windows[i]->GetProperty(
aura::client::kAppType)) != AppType::ARC_APP;
}
......@@ -61,11 +60,17 @@ bool IsCarryOverCandidateForSplitView(
base::flat_map<aura::Window*, WindowStateType>
GetCarryOverWindowsInSplitView() {
base::flat_map<aura::Window*, WindowStateType> windows;
// Check the topmost window and the second topmost's window state to see if
// they are eligible to be carried over to splitscreen. A window must meet
// Check the states of the topmost two non-overview windows to see if they are
// eligible to be carried over to splitscreen. A window must meet
// IsCarryOverCandidateForSplitView() to be carried over to splitscreen.
MruWindowTracker::WindowList mru_windows =
Shell::Get()->mru_window_tracker()->BuildWindowForCycleList(kActiveDesk);
mru_windows.erase(
std::remove_if(mru_windows.begin(), mru_windows.end(),
[](aura::Window* window) {
return window->GetProperty(kIsShowingInOverviewKey);
}),
mru_windows.end());
if (IsCarryOverCandidateForSplitView(mru_windows, 0u)) {
if (WindowState::Get(mru_windows[0])->GetStateType() ==
WindowStateType::kLeftSnapped) {
......
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