Commit 851d6248 authored by Xiaoqian Dai's avatar Xiaoqian Dai Committed by Commit Bot

Allow drag on caption area of chrome app window.

Bug: 881642
Change-Id: I3c1f72a6a2c39c86de60ab7132b2384ddcfa1ca4
Reviewed-on: https://chromium-review.googlesource.com/1211371
Commit-Queue: Xiaoqian Dai <xdai@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589587}
parent 07cf285f
...@@ -1623,13 +1623,14 @@ class SplitViewTabDraggingTest : public SplitViewControllerTest { ...@@ -1623,13 +1623,14 @@ class SplitViewTabDraggingTest : public SplitViewControllerTest {
~SplitViewTabDraggingTest() override = default; ~SplitViewTabDraggingTest() override = default;
protected: protected:
aura::Window* CreateBrowserTypeWindow( aura::Window* CreateWindowWithType(
const gfx::Rect& bounds, const gfx::Rect& bounds,
aura::client::WindowType type = aura::client::WINDOW_TYPE_NORMAL) { AppType app_type,
aura::client::WindowType window_type = aura::client::WINDOW_TYPE_NORMAL) {
aura::Window* window = CreateTestWindowInShellWithDelegateAndType( aura::Window* window = CreateTestWindowInShellWithDelegateAndType(
new SplitViewTestWindowDelegate, type, -1, bounds); new SplitViewTestWindowDelegate, window_type, -1, bounds);
window->SetProperty(aura::client::kAppType, window->SetProperty(aura::client::kAppType, static_cast<int>(app_type));
static_cast<int>(AppType::BROWSER)); wm::GetWindowState(window)->Maximize();
return window; return window;
} }
...@@ -1734,12 +1735,17 @@ class SplitViewTabDraggingTest : public SplitViewControllerTest { ...@@ -1734,12 +1735,17 @@ class SplitViewTabDraggingTest : public SplitViewControllerTest {
DISALLOW_COPY_AND_ASSIGN(SplitViewTabDraggingTest); DISALLOW_COPY_AND_ASSIGN(SplitViewTabDraggingTest);
}; };
// Test that in tablet mode, we only allow dragging on browser window's caption // Test that in tablet mode, we only allow dragging on browser or chrome app
// area. // window's caption area.
TEST_F(SplitViewTabDraggingTest, OnlyAllowDraggingOnBrowserWindow) { TEST_F(SplitViewTabDraggingTest, OnlyAllowDraggingOnBrowserOrChromeAppWindow) {
const gfx::Rect bounds(0, 0, 400, 400); const gfx::Rect bounds(0, 0, 400, 400);
std::unique_ptr<aura::Window> window1(CreateBrowserTypeWindow(bounds)); std::unique_ptr<aura::Window> window1(
std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); CreateWindowWithType(bounds, AppType::BROWSER));
std::unique_ptr<aura::Window> window2(
CreateWindowWithType(bounds, AppType::CHROME_APP));
std::unique_ptr<aura::Window> window3(CreateWindow(bounds));
std::unique_ptr<aura::Window> window4(
CreateWindowWithType(bounds, AppType::ARC_APP));
std::unique_ptr<WindowResizer> resizer = std::unique_ptr<WindowResizer> resizer =
CreateResizerForTest(window1.get(), gfx::Point(), HTCAPTION); CreateResizerForTest(window1.get(), gfx::Point(), HTCAPTION);
...@@ -1748,6 +1754,14 @@ TEST_F(SplitViewTabDraggingTest, OnlyAllowDraggingOnBrowserWindow) { ...@@ -1748,6 +1754,14 @@ TEST_F(SplitViewTabDraggingTest, OnlyAllowDraggingOnBrowserWindow) {
resizer.reset(); resizer.reset();
resizer = CreateResizerForTest(window2.get(), gfx::Point(), HTCAPTION); resizer = CreateResizerForTest(window2.get(), gfx::Point(), HTCAPTION);
EXPECT_TRUE(resizer.get());
resizer->CompleteDrag();
resizer.reset();
resizer = CreateResizerForTest(window3.get(), gfx::Point(), HTCAPTION);
EXPECT_FALSE(resizer.get());
resizer = CreateResizerForTest(window4.get(), gfx::Point(), HTCAPTION);
EXPECT_FALSE(resizer.get()); EXPECT_FALSE(resizer.get());
} }
...@@ -1755,7 +1769,8 @@ TEST_F(SplitViewTabDraggingTest, OnlyAllowDraggingOnBrowserWindow) { ...@@ -1755,7 +1769,8 @@ TEST_F(SplitViewTabDraggingTest, OnlyAllowDraggingOnBrowserWindow) {
// caption or top area. // caption or top area.
TEST_F(SplitViewTabDraggingTest, OnlyAllowDraggingOnCaptionOrTopArea) { TEST_F(SplitViewTabDraggingTest, OnlyAllowDraggingOnCaptionOrTopArea) {
const gfx::Rect bounds(0, 0, 400, 400); const gfx::Rect bounds(0, 0, 400, 400);
std::unique_ptr<aura::Window> window(CreateBrowserTypeWindow(bounds)); std::unique_ptr<aura::Window> window(
CreateWindowWithType(bounds, AppType::BROWSER));
// Only dragging on HTCAPTION or HTTOP area is allowed. // Only dragging on HTCAPTION or HTTOP area is allowed.
std::unique_ptr<WindowResizer> resizer = std::unique_ptr<WindowResizer> resizer =
...@@ -1791,7 +1806,8 @@ TEST_F(SplitViewTabDraggingTest, OnlyAllowDraggingOnCaptionOrTopArea) { ...@@ -1791,7 +1806,8 @@ TEST_F(SplitViewTabDraggingTest, OnlyAllowDraggingOnCaptionOrTopArea) {
// cursor should be properly locked. // cursor should be properly locked.
TEST_F(SplitViewTabDraggingTest, LockCursor) { TEST_F(SplitViewTabDraggingTest, LockCursor) {
const gfx::Rect bounds(0, 0, 400, 400); const gfx::Rect bounds(0, 0, 400, 400);
std::unique_ptr<aura::Window> window(CreateBrowserTypeWindow(bounds)); std::unique_ptr<aura::Window> window(
CreateWindowWithType(bounds, AppType::BROWSER));
SetIsInTabDragging(window.get(), /*is_dragging=*/true); SetIsInTabDragging(window.get(), /*is_dragging=*/true);
EXPECT_FALSE(Shell::Get()->cursor_manager()->IsCursorLocked()); EXPECT_FALSE(Shell::Get()->cursor_manager()->IsCursorLocked());
...@@ -1809,7 +1825,8 @@ TEST_F(SplitViewTabDraggingTest, LockCursor) { ...@@ -1809,7 +1825,8 @@ TEST_F(SplitViewTabDraggingTest, LockCursor) {
// backdrop is disabled during dragging process. // backdrop is disabled during dragging process.
TEST_F(SplitViewTabDraggingTest, NoBackDropDuringDragging) { TEST_F(SplitViewTabDraggingTest, NoBackDropDuringDragging) {
const gfx::Rect bounds(0, 0, 400, 400); const gfx::Rect bounds(0, 0, 400, 400);
std::unique_ptr<aura::Window> window(CreateBrowserTypeWindow(bounds)); std::unique_ptr<aura::Window> window(
CreateWindowWithType(bounds, AppType::BROWSER));
EXPECT_EQ(window->GetProperty(kBackdropWindowMode), EXPECT_EQ(window->GetProperty(kBackdropWindowMode),
BackdropWindowMode::kAuto); BackdropWindowMode::kAuto);
...@@ -1832,8 +1849,10 @@ TEST_F(SplitViewTabDraggingTest, NoBackDropDuringDragging) { ...@@ -1832,8 +1849,10 @@ TEST_F(SplitViewTabDraggingTest, NoBackDropDuringDragging) {
// not be shown in overview mode. // not be shown in overview mode.
TEST_F(SplitViewTabDraggingTest, DoNotShowDraggedWindowInOverview) { TEST_F(SplitViewTabDraggingTest, DoNotShowDraggedWindowInOverview) {
const gfx::Rect bounds(0, 0, 400, 400); const gfx::Rect bounds(0, 0, 400, 400);
std::unique_ptr<aura::Window> window1(CreateBrowserTypeWindow(bounds)); std::unique_ptr<aura::Window> window1(
std::unique_ptr<aura::Window> window2(CreateBrowserTypeWindow(bounds)); CreateWindowWithType(bounds, AppType::BROWSER));
std::unique_ptr<aura::Window> window2(
CreateWindowWithType(bounds, AppType::BROWSER));
Shell::Get()->window_selector_controller()->ToggleOverview(); Shell::Get()->window_selector_controller()->ToggleOverview();
EXPECT_TRUE(Shell::Get()->window_selector_controller()->IsSelecting()); EXPECT_TRUE(Shell::Get()->window_selector_controller()->IsSelecting());
...@@ -1862,8 +1881,10 @@ TEST_F(SplitViewTabDraggingTest, DoNotShowDraggedWindowInOverview) { ...@@ -1862,8 +1881,10 @@ TEST_F(SplitViewTabDraggingTest, DoNotShowDraggedWindowInOverview) {
// below the current dragged window. // below the current dragged window.
TEST_F(SplitViewTabDraggingTest, DividerIsBelowDraggedWindow) { TEST_F(SplitViewTabDraggingTest, DividerIsBelowDraggedWindow) {
const gfx::Rect bounds(0, 0, 400, 400); const gfx::Rect bounds(0, 0, 400, 400);
std::unique_ptr<aura::Window> window1(CreateBrowserTypeWindow(bounds)); std::unique_ptr<aura::Window> window1(
std::unique_ptr<aura::Window> window2(CreateBrowserTypeWindow(bounds)); CreateWindowWithType(bounds, AppType::BROWSER));
std::unique_ptr<aura::Window> window2(
CreateWindowWithType(bounds, AppType::BROWSER));
split_view_controller()->SnapWindow(window1.get(), SplitViewController::LEFT); split_view_controller()->SnapWindow(window1.get(), SplitViewController::LEFT);
split_view_controller()->SnapWindow(window2.get(), split_view_controller()->SnapWindow(window2.get(),
...@@ -1889,8 +1910,10 @@ TEST_F(SplitViewTabDraggingTest, DividerIsBelowDraggedWindow) { ...@@ -1889,8 +1910,10 @@ TEST_F(SplitViewTabDraggingTest, DividerIsBelowDraggedWindow) {
TEST_F(SplitViewTabDraggingTest, DragMaximizedWindow) { TEST_F(SplitViewTabDraggingTest, DragMaximizedWindow) {
UpdateDisplay("600x600"); UpdateDisplay("600x600");
const gfx::Rect bounds(0, 0, 400, 400); const gfx::Rect bounds(0, 0, 400, 400);
std::unique_ptr<aura::Window> window1(CreateBrowserTypeWindow(bounds)); std::unique_ptr<aura::Window> window1(
std::unique_ptr<aura::Window> window2(CreateBrowserTypeWindow(bounds)); CreateWindowWithType(bounds, AppType::BROWSER));
std::unique_ptr<aura::Window> window2(
CreateWindowWithType(bounds, AppType::BROWSER));
wm::GetWindowState(window1.get())->Maximize(); wm::GetWindowState(window1.get())->Maximize();
wm::GetWindowState(window2.get())->Maximize(); wm::GetWindowState(window2.get())->Maximize();
EXPECT_TRUE(wm::GetWindowState(window1.get())->IsMaximized()); EXPECT_TRUE(wm::GetWindowState(window1.get())->IsMaximized());
...@@ -2014,9 +2037,12 @@ TEST_F(SplitViewTabDraggingTest, DragMaximizedWindow) { ...@@ -2014,9 +2037,12 @@ TEST_F(SplitViewTabDraggingTest, DragMaximizedWindow) {
TEST_F(SplitViewTabDraggingTest, DragSnappedWindow) { TEST_F(SplitViewTabDraggingTest, DragSnappedWindow) {
UpdateDisplay("600x600"); UpdateDisplay("600x600");
const gfx::Rect bounds(0, 0, 400, 400); const gfx::Rect bounds(0, 0, 400, 400);
std::unique_ptr<aura::Window> window1(CreateBrowserTypeWindow(bounds)); std::unique_ptr<aura::Window> window1(
std::unique_ptr<aura::Window> window2(CreateBrowserTypeWindow(bounds)); CreateWindowWithType(bounds, AppType::BROWSER));
std::unique_ptr<aura::Window> window3(CreateBrowserTypeWindow(bounds)); std::unique_ptr<aura::Window> window2(
CreateWindowWithType(bounds, AppType::BROWSER));
std::unique_ptr<aura::Window> window3(
CreateWindowWithType(bounds, AppType::BROWSER));
split_view_controller()->SnapWindow(window1.get(), SplitViewController::LEFT); split_view_controller()->SnapWindow(window1.get(), SplitViewController::LEFT);
split_view_controller()->SnapWindow(window2.get(), split_view_controller()->SnapWindow(window2.get(),
...@@ -2090,7 +2116,7 @@ TEST_F(SplitViewTabDraggingTest, DragSnappedWindow) { ...@@ -2090,7 +2116,7 @@ TEST_F(SplitViewTabDraggingTest, DragSnappedWindow) {
EXPECT_TRUE(Shell::Get()->window_selector_controller()->IsSelecting()); EXPECT_TRUE(Shell::Get()->window_selector_controller()->IsSelecting());
// Recreate |window1| and snap it to test the following senarioes. // Recreate |window1| and snap it to test the following senarioes.
window1.reset(CreateBrowserTypeWindow(bounds)); window1.reset(CreateWindowWithType(bounds, AppType::BROWSER));
split_view_controller()->SnapWindow(window1.get(), split_view_controller()->SnapWindow(window1.get(),
SplitViewController::RIGHT); SplitViewController::RIGHT);
EXPECT_EQ(split_view_controller()->state(), EXPECT_EQ(split_view_controller()->state(),
...@@ -2159,9 +2185,12 @@ TEST_F(SplitViewTabDraggingTest, DragSnappedWindow) { ...@@ -2159,9 +2185,12 @@ TEST_F(SplitViewTabDraggingTest, DragSnappedWindow) {
TEST_F(SplitViewTabDraggingTest, DragSnappedWindowWhileOverviewOpen) { TEST_F(SplitViewTabDraggingTest, DragSnappedWindowWhileOverviewOpen) {
UpdateDisplay("600x600"); UpdateDisplay("600x600");
const gfx::Rect bounds(0, 0, 400, 400); const gfx::Rect bounds(0, 0, 400, 400);
std::unique_ptr<aura::Window> window1(CreateBrowserTypeWindow(bounds)); std::unique_ptr<aura::Window> window1(
std::unique_ptr<aura::Window> window2(CreateBrowserTypeWindow(bounds)); CreateWindowWithType(bounds, AppType::BROWSER));
std::unique_ptr<aura::Window> window3(CreateBrowserTypeWindow(bounds)); std::unique_ptr<aura::Window> window2(
CreateWindowWithType(bounds, AppType::BROWSER));
std::unique_ptr<aura::Window> window3(
CreateWindowWithType(bounds, AppType::BROWSER));
// Prepare the testing senario: // Prepare the testing senario:
split_view_controller()->SnapWindow(window1.get(), SplitViewController::LEFT); split_view_controller()->SnapWindow(window1.get(), SplitViewController::LEFT);
...@@ -2280,9 +2309,12 @@ TEST_F(SplitViewTabDraggingTest, DragSnappedWindowWhileOverviewOpen) { ...@@ -2280,9 +2309,12 @@ TEST_F(SplitViewTabDraggingTest, DragSnappedWindowWhileOverviewOpen) {
// the drag ends. // the drag ends.
TEST_F(SplitViewTabDraggingTest, ShowNewWindowItemWhenDragStarts) { TEST_F(SplitViewTabDraggingTest, ShowNewWindowItemWhenDragStarts) {
const gfx::Rect bounds(0, 0, 400, 400); const gfx::Rect bounds(0, 0, 400, 400);
std::unique_ptr<aura::Window> window1(CreateBrowserTypeWindow(bounds)); std::unique_ptr<aura::Window> window1(
std::unique_ptr<aura::Window> window2(CreateBrowserTypeWindow(bounds)); CreateWindowWithType(bounds, AppType::BROWSER));
std::unique_ptr<aura::Window> window3(CreateBrowserTypeWindow(bounds)); std::unique_ptr<aura::Window> window2(
CreateWindowWithType(bounds, AppType::BROWSER));
std::unique_ptr<aura::Window> window3(
CreateWindowWithType(bounds, AppType::BROWSER));
split_view_controller()->SnapWindow(window1.get(), SplitViewController::LEFT); split_view_controller()->SnapWindow(window1.get(), SplitViewController::LEFT);
split_view_controller()->SnapWindow(window2.get(), split_view_controller()->SnapWindow(window2.get(),
...@@ -2338,9 +2370,12 @@ TEST_F(SplitViewTabDraggingTest, ShowNewWindowItemWhenDragStarts) { ...@@ -2338,9 +2370,12 @@ TEST_F(SplitViewTabDraggingTest, ShowNewWindowItemWhenDragStarts) {
// should not do animation when exiting overview. // should not do animation when exiting overview.
TEST_F(SplitViewTabDraggingTest, OverviewExitAnimationTest) { TEST_F(SplitViewTabDraggingTest, OverviewExitAnimationTest) {
const gfx::Rect bounds(0, 0, 400, 400); const gfx::Rect bounds(0, 0, 400, 400);
std::unique_ptr<aura::Window> window1(CreateBrowserTypeWindow(bounds)); std::unique_ptr<aura::Window> window1(
std::unique_ptr<aura::Window> window2(CreateBrowserTypeWindow(bounds)); CreateWindowWithType(bounds, AppType::BROWSER));
std::unique_ptr<aura::Window> window3(CreateBrowserTypeWindow(bounds)); std::unique_ptr<aura::Window> window2(
CreateWindowWithType(bounds, AppType::BROWSER));
std::unique_ptr<aura::Window> window3(
CreateWindowWithType(bounds, AppType::BROWSER));
std::unique_ptr<OverviewStatesObserver> overview_observer = std::unique_ptr<OverviewStatesObserver> overview_observer =
std::make_unique<OverviewStatesObserver>(window1->GetRootWindow()); std::make_unique<OverviewStatesObserver>(window1->GetRootWindow());
...@@ -2396,7 +2431,8 @@ TEST_F(SplitViewTabDraggingTest, DragIndicatorsInPortraitOrientationTest) { ...@@ -2396,7 +2431,8 @@ TEST_F(SplitViewTabDraggingTest, DragIndicatorsInPortraitOrientationTest) {
OrientationLockType::kLandscapePrimary); OrientationLockType::kLandscapePrimary);
const gfx::Rect bounds(0, 0, 400, 400); const gfx::Rect bounds(0, 0, 400, 400);
std::unique_ptr<aura::Window> window(CreateBrowserTypeWindow(bounds)); std::unique_ptr<aura::Window> window(
CreateWindowWithType(bounds, AppType::BROWSER));
wm::GetWindowState(window.get())->Maximize(); wm::GetWindowState(window.get())->Maximize();
EXPECT_TRUE(wm::GetWindowState(window.get())->IsMaximized()); EXPECT_TRUE(wm::GetWindowState(window.get())->IsMaximized());
std::unique_ptr<WindowResizer> resizer = std::unique_ptr<WindowResizer> resizer =
...@@ -2429,9 +2465,12 @@ TEST_F(SplitViewTabDraggingTest, DragIndicatorsInPortraitOrientationTest) { ...@@ -2429,9 +2465,12 @@ TEST_F(SplitViewTabDraggingTest, DragIndicatorsInPortraitOrientationTest) {
// should be adjusted accordingly. // should be adjusted accordingly.
TEST_F(SplitViewTabDraggingTest, AdjustOverviewBoundsDuringDragging) { TEST_F(SplitViewTabDraggingTest, AdjustOverviewBoundsDuringDragging) {
const gfx::Rect bounds(0, 0, 400, 400); const gfx::Rect bounds(0, 0, 400, 400);
std::unique_ptr<aura::Window> window1(CreateBrowserTypeWindow(bounds)); std::unique_ptr<aura::Window> window1(
std::unique_ptr<aura::Window> window2(CreateBrowserTypeWindow(bounds)); CreateWindowWithType(bounds, AppType::BROWSER));
std::unique_ptr<aura::Window> window3(CreateBrowserTypeWindow(bounds)); std::unique_ptr<aura::Window> window2(
CreateWindowWithType(bounds, AppType::BROWSER));
std::unique_ptr<aura::Window> window3(
CreateWindowWithType(bounds, AppType::BROWSER));
WindowSelectorController* selector_controller = WindowSelectorController* selector_controller =
Shell::Get()->window_selector_controller(); Shell::Get()->window_selector_controller();
...@@ -2565,7 +2604,8 @@ TEST_F(SplitViewTabDraggingTest, AdjustOverviewBoundsDuringDragging) { ...@@ -2565,7 +2604,8 @@ TEST_F(SplitViewTabDraggingTest, AdjustOverviewBoundsDuringDragging) {
// the new selector item to add into overview. // the new selector item to add into overview.
TEST_F(SplitViewTabDraggingTest, WindowBoundsUpdatedBeforeAddingToOverview) { TEST_F(SplitViewTabDraggingTest, WindowBoundsUpdatedBeforeAddingToOverview) {
const gfx::Rect bounds(0, 0, 400, 400); const gfx::Rect bounds(0, 0, 400, 400);
std::unique_ptr<aura::Window> window1(CreateBrowserTypeWindow(bounds)); std::unique_ptr<aura::Window> window1(
CreateWindowWithType(bounds, AppType::BROWSER));
gfx::Rect tablet_mode_bounds = window1->bounds(); gfx::Rect tablet_mode_bounds = window1->bounds();
EXPECT_NE(bounds, tablet_mode_bounds); EXPECT_NE(bounds, tablet_mode_bounds);
...@@ -2632,7 +2672,8 @@ TEST_F(SplitViewTabDraggingTest, WindowBoundsUpdatedBeforeAddingToOverview) { ...@@ -2632,7 +2672,8 @@ TEST_F(SplitViewTabDraggingTest, WindowBoundsUpdatedBeforeAddingToOverview) {
// in overview. // in overview.
TEST_F(SplitViewTabDraggingTest, DropWindowIntoOverviewOnDragPositionTest) { TEST_F(SplitViewTabDraggingTest, DropWindowIntoOverviewOnDragPositionTest) {
const gfx::Rect bounds(0, 0, 400, 400); const gfx::Rect bounds(0, 0, 400, 400);
std::unique_ptr<aura::Window> window1(CreateBrowserTypeWindow(bounds)); std::unique_ptr<aura::Window> window1(
CreateWindowWithType(bounds, AppType::BROWSER));
wm::GetWindowState(window1.get())->Maximize(); wm::GetWindowState(window1.get())->Maximize();
std::unique_ptr<WindowResizer> resizer = std::unique_ptr<WindowResizer> resizer =
StartDrag(window1.get(), window1.get()); StartDrag(window1.get(), window1.get());
...@@ -2679,7 +2720,8 @@ TEST_F(SplitViewTabDraggingTest, DropWindowIntoOverviewOnDragPositionTest) { ...@@ -2679,7 +2720,8 @@ TEST_F(SplitViewTabDraggingTest, DropWindowIntoOverviewOnDragPositionTest) {
// Should not consider the drag position if splitview is active. Window should // Should not consider the drag position if splitview is active. Window should
// still back to be snapped. // still back to be snapped.
std::unique_ptr<aura::Window> window2(CreateBrowserTypeWindow(bounds)); std::unique_ptr<aura::Window> window2(
CreateWindowWithType(bounds, AppType::BROWSER));
split_view_controller()->SnapWindow(window2.get(), split_view_controller()->SnapWindow(window2.get(),
SplitViewController::RIGHT); SplitViewController::RIGHT);
EXPECT_EQ(SplitViewController::BOTH_SNAPPED, EXPECT_EQ(SplitViewController::BOTH_SNAPPED,
...@@ -2698,8 +2740,10 @@ TEST_F(SplitViewTabDraggingTest, DropWindowIntoOverviewOnDragPositionTest) { ...@@ -2698,8 +2740,10 @@ TEST_F(SplitViewTabDraggingTest, DropWindowIntoOverviewOnDragPositionTest) {
// dragging. // dragging.
TEST_F(SplitViewTabDraggingTest, DraggedWindowShouldHaveActiveWindowShadow) { TEST_F(SplitViewTabDraggingTest, DraggedWindowShouldHaveActiveWindowShadow) {
const gfx::Rect bounds(0, 0, 400, 400); const gfx::Rect bounds(0, 0, 400, 400);
std::unique_ptr<aura::Window> window1(CreateBrowserTypeWindow(bounds)); std::unique_ptr<aura::Window> window1(
std::unique_ptr<aura::Window> window2(CreateBrowserTypeWindow(bounds)); CreateWindowWithType(bounds, AppType::BROWSER));
std::unique_ptr<aura::Window> window2(
CreateWindowWithType(bounds, AppType::BROWSER));
wm::ActivateWindow(window1.get()); wm::ActivateWindow(window1.get());
wm::ActivateWindow(window2.get()); wm::ActivateWindow(window2.get());
window1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); window1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
...@@ -2740,10 +2784,14 @@ TEST_F(SplitViewTabDraggingTest, DraggedWindowShouldHaveActiveWindowShadow) { ...@@ -2740,10 +2784,14 @@ TEST_F(SplitViewTabDraggingTest, DraggedWindowShouldHaveActiveWindowShadow) {
// visibility should change accordingly. // visibility should change accordingly.
TEST_F(SplitViewTabDraggingTest, SourceWindowBackgroundTest) { TEST_F(SplitViewTabDraggingTest, SourceWindowBackgroundTest) {
const gfx::Rect bounds(0, 0, 400, 400); const gfx::Rect bounds(0, 0, 400, 400);
std::unique_ptr<aura::Window> window1(CreateBrowserTypeWindow(bounds)); std::unique_ptr<aura::Window> window1(
std::unique_ptr<aura::Window> window2(CreateBrowserTypeWindow(bounds)); CreateWindowWithType(bounds, AppType::BROWSER));
std::unique_ptr<aura::Window> window3(CreateBrowserTypeWindow(bounds)); std::unique_ptr<aura::Window> window2(
std::unique_ptr<aura::Window> window4(CreateBrowserTypeWindow(bounds)); CreateWindowWithType(bounds, AppType::BROWSER));
std::unique_ptr<aura::Window> window3(
CreateWindowWithType(bounds, AppType::BROWSER));
std::unique_ptr<aura::Window> window4(
CreateWindowWithType(bounds, AppType::BROWSER));
EXPECT_TRUE(window1->IsVisible()); EXPECT_TRUE(window1->IsVisible());
EXPECT_TRUE(window2->IsVisible()); EXPECT_TRUE(window2->IsVisible());
EXPECT_TRUE(window3->IsVisible()); EXPECT_TRUE(window3->IsVisible());
......
...@@ -39,6 +39,53 @@ ...@@ -39,6 +39,53 @@
#include "ui/wm/core/coordinate_conversion.h" #include "ui/wm/core/coordinate_conversion.h"
#include "ui/wm/core/cursor_manager.h" #include "ui/wm/core/cursor_manager.h"
namespace {
// Returns true if |window| can be dragged from the top of the screen in tablet
// mode.
bool CanDragInTabletMode(aura::Window* window, int window_component) {
ash::wm::WindowState* window_state = ash::wm::GetWindowState(window);
// Pip window can't be dragged.
if (window_state->IsPip())
return false;
// Only maximized/fullscreen/snapped window can be dragged from the top of
// the screen.
if (!window_state->IsMaximized() && !window_state->IsFullscreen() &&
!window_state->IsSnapped()) {
return false;
}
// Only allow drag that happens on caption or top area. Note: for a maxmized
// or fullscreen window, the window component here is always HTCAPTION, but
// for a snapped window, the window component here can either be HTCAPTION or
// HTTOP.
if (window_component != HTCAPTION && window_component != HTTOP)
return false;
// Note: only browser windows and chrome app windows are included here.
// For browser windows, this piece of codes will be called no matter the
// drag happens on the tab(s) or on the non-tabstrip caption or top area.
// But for app window, this piece of codes will only be called if the chrome
// app window has its customized caption area and can't be hidden in tablet
// mode (and thus the drag for this type of chrome app window always happens
// on caption or top area). If the caption area of the chrome app window can
// be hidden, ImmersiveGestureHandlerClassic will handle the window drag
// through TabletModeAppWindowDragController.
// TODO(xdai, minch): Merge the logic in ImmersiveGestureHandlerClassic into
// CreateWindowResizer() in future.
ash::AppType app_type =
static_cast<ash::AppType>(window->GetProperty(aura::client::kAppType));
if (app_type != ash::AppType::BROWSER &&
app_type != ash::AppType::CHROME_APP) {
return false;
}
return true;
}
} // namespace
namespace ash { namespace ash {
std::unique_ptr<WindowResizer> CreateWindowResizer( std::unique_ptr<WindowResizer> CreateWindowResizer(
...@@ -70,15 +117,8 @@ std::unique_ptr<WindowResizer> CreateWindowResizer( ...@@ -70,15 +117,8 @@ std::unique_ptr<WindowResizer> CreateWindowResizer(
->tablet_mode_controller() ->tablet_mode_controller()
->IsTabletModeWindowManagerEnabled() && ->IsTabletModeWindowManagerEnabled() &&
!window_state->IsPip()) { !window_state->IsPip()) {
// We still don't allow any dragging or resizing happening on the area other if (!CanDragInTabletMode(window, window_component))
// then caption or top area. Note: for a maxmized or fullscreen window, the
// window component here is always HTCAPTION, but for a snapped window, the
// window component here can either be HTCAPTION or HTTOP.
if ((window_component != HTCAPTION && window_component != HTTOP) ||
window->GetProperty(aura::client::kAppType) !=
static_cast<int>(AppType::BROWSER)) {
return nullptr; return nullptr;
}
window_state->CreateDragDetails(point_in_parent, window_component, source); window_state->CreateDragDetails(point_in_parent, window_component, source);
window_resizer = window_resizer =
......
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