| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/wm/dock/docked_window_resizer.h" | 5 #include "ash/wm/dock/docked_window_resizer.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/display/window_tree_host_manager.h" | 8 #include "ash/display/window_tree_host_manager.h" |
| 9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
| 10 #include "ash/screen_util.h" | 10 #include "ash/screen_util.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 aura::Window* window = new aura::Window(&delegate_); | 93 aura::Window* window = new aura::Window(&delegate_); |
| 94 window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); | 94 window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); |
| 95 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 95 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
| 96 window->Init(ui::LAYER_TEXTURED); | 96 window->Init(ui::LAYER_TEXTURED); |
| 97 window->Show(); | 97 window->Show(); |
| 98 | 98 |
| 99 if (bounds.IsEmpty()) { | 99 if (bounds.IsEmpty()) { |
| 100 ParentWindowInPrimaryRootWindow(window); | 100 ParentWindowInPrimaryRootWindow(window); |
| 101 } else { | 101 } else { |
| 102 gfx::Display display = | 102 gfx::Display display = |
| 103 Shell::GetScreen()->GetDisplayMatching(bounds); | 103 gfx::Screen::GetScreen()->GetDisplayMatching(bounds); |
| 104 aura::Window* root = ash::Shell::GetInstance() | 104 aura::Window* root = ash::Shell::GetInstance() |
| 105 ->window_tree_host_manager() | 105 ->window_tree_host_manager() |
| 106 ->GetRootWindowForDisplayId(display.id()); | 106 ->GetRootWindowForDisplayId(display.id()); |
| 107 gfx::Point origin = bounds.origin(); | 107 gfx::Point origin = bounds.origin(); |
| 108 ::wm::ConvertPointFromScreen(root, &origin); | 108 ::wm::ConvertPointFromScreen(root, &origin); |
| 109 window->SetBounds(gfx::Rect(origin, bounds.size())); | 109 window->SetBounds(gfx::Rect(origin, bounds.size())); |
| 110 aura::client::ParentWindowWithContext(window, root, bounds); | 110 aura::client::ParentWindowWithContext(window, root, bounds); |
| 111 } | 111 } |
| 112 return window; | 112 return window; |
| 113 } | 113 } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 void DragVerticallyAndRelativeToEdge(DockedEdge edge, | 207 void DragVerticallyAndRelativeToEdge(DockedEdge edge, |
| 208 aura::Window* window, | 208 aura::Window* window, |
| 209 int dx, int dy, | 209 int dx, int dy, |
| 210 int grab_x, int grab_y) { | 210 int grab_x, int grab_y) { |
| 211 gfx::Rect initial_bounds = window->GetBoundsInScreen(); | 211 gfx::Rect initial_bounds = window->GetBoundsInScreen(); |
| 212 // avoid snap by clicking away from the border | 212 // avoid snap by clicking away from the border |
| 213 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(window, | 213 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(window, |
| 214 grab_x, grab_y)); | 214 grab_x, grab_y)); |
| 215 | 215 |
| 216 gfx::Rect work_area = | 216 gfx::Rect work_area = |
| 217 Shell::GetScreen()->GetDisplayNearestWindow(window).work_area(); | 217 gfx::Screen::GetScreen()->GetDisplayNearestWindow(window).work_area(); |
| 218 gfx::Point initial_location_in_screen = initial_location_in_parent_; | 218 gfx::Point initial_location_in_screen = initial_location_in_parent_; |
| 219 ::wm::ConvertPointToScreen(window->parent(), &initial_location_in_screen); | 219 ::wm::ConvertPointToScreen(window->parent(), &initial_location_in_screen); |
| 220 // Drag the window left or right to the edge (or almost to it). | 220 // Drag the window left or right to the edge (or almost to it). |
| 221 if (edge == DOCKED_EDGE_LEFT) | 221 if (edge == DOCKED_EDGE_LEFT) |
| 222 dx += work_area.x() - initial_location_in_screen.x(); | 222 dx += work_area.x() - initial_location_in_screen.x(); |
| 223 else if (edge == DOCKED_EDGE_RIGHT) | 223 else if (edge == DOCKED_EDGE_RIGHT) |
| 224 dx += work_area.right() - 1 - initial_location_in_screen.x(); | 224 dx += work_area.right() - 1 - initial_location_in_screen.x(); |
| 225 DragMove(dx, dy); | 225 DragMove(dx, dy); |
| 226 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); | 226 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); |
| 227 // Release the mouse and the panel should be attached to the dock. | 227 // Release the mouse and the panel should be attached to the dock. |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 w1->GetBoundsInScreen().right()); | 590 w1->GetBoundsInScreen().right()); |
| 591 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 591 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
| 592 | 592 |
| 593 scoped_ptr<aura::Window> w2(CreateTestWindowInShellWithDelegateAndType( | 593 scoped_ptr<aura::Window> w2(CreateTestWindowInShellWithDelegateAndType( |
| 594 NULL, ui::wm::WINDOW_TYPE_NORMAL, 0, gfx::Rect(20, 20, 150, 20))); | 594 NULL, ui::wm::WINDOW_TYPE_NORMAL, 0, gfx::Rect(20, 20, 150, 20))); |
| 595 wm::GetWindowState(w2.get())->Maximize(); | 595 wm::GetWindowState(w2.get())->Maximize(); |
| 596 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id()); | 596 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id()); |
| 597 EXPECT_TRUE(wm::GetWindowState(w2.get())->IsMaximized()); | 597 EXPECT_TRUE(wm::GetWindowState(w2.get())->IsMaximized()); |
| 598 | 598 |
| 599 gfx::Rect work_area = | 599 gfx::Rect work_area = |
| 600 Shell::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); | 600 gfx::Screen::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); |
| 601 DockedWindowLayoutManager* manager = | 601 DockedWindowLayoutManager* manager = |
| 602 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); | 602 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); |
| 603 | 603 |
| 604 // Docked window should be centered vertically in the work area. | 604 // Docked window should be centered vertically in the work area. |
| 605 EXPECT_EQ(work_area.CenterPoint().y(), w1->bounds().CenterPoint().y()); | 605 EXPECT_EQ(work_area.CenterPoint().y(), w1->bounds().CenterPoint().y()); |
| 606 // Docked background should extend to the bottom of work area. | 606 // Docked background should extend to the bottom of work area. |
| 607 EXPECT_EQ(work_area.bottom(), manager->docked_bounds().bottom()); | 607 EXPECT_EQ(work_area.bottom(), manager->docked_bounds().bottom()); |
| 608 | 608 |
| 609 // set launcher shelf to be aligned on the right | 609 // set launcher shelf to be aligned on the right |
| 610 ash::Shell* shell = ash::Shell::GetInstance(); | 610 ash::Shell* shell = ash::Shell::GetInstance(); |
| 611 shell->SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, | 611 shell->SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, |
| 612 shell->GetPrimaryRootWindow()); | 612 shell->GetPrimaryRootWindow()); |
| 613 work_area = | 613 work_area = |
| 614 Shell::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); | 614 gfx::Screen::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); |
| 615 // Docked window should be centered vertically in the work area. | 615 // Docked window should be centered vertically in the work area. |
| 616 EXPECT_EQ(work_area.CenterPoint().y(), w1->bounds().CenterPoint().y()); | 616 EXPECT_EQ(work_area.CenterPoint().y(), w1->bounds().CenterPoint().y()); |
| 617 // Docked background should extend to the bottom of work area. | 617 // Docked background should extend to the bottom of work area. |
| 618 EXPECT_EQ(work_area.bottom(), manager->docked_bounds().bottom()); | 618 EXPECT_EQ(work_area.bottom(), manager->docked_bounds().bottom()); |
| 619 } | 619 } |
| 620 | 620 |
| 621 // Dock one window, try to dock another window on the opposite side (should not | 621 // Dock one window, try to dock another window on the opposite side (should not |
| 622 // dock). | 622 // dock). |
| 623 TEST_P(DockedWindowResizerTest, AttachOnTwoSides) { | 623 TEST_P(DockedWindowResizerTest, AttachOnTwoSides) { |
| 624 if (!SupportsHostWindowResize()) | 624 if (!SupportsHostWindowResize()) |
| (...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1603 EXPECT_TRUE(window_state->IsMaximized()); | 1603 EXPECT_TRUE(window_state->IsMaximized()); |
| 1604 } | 1604 } |
| 1605 | 1605 |
| 1606 // Tests run twice - on both panels and normal windows | 1606 // Tests run twice - on both panels and normal windows |
| 1607 INSTANTIATE_TEST_CASE_P(NormalOrPanel, | 1607 INSTANTIATE_TEST_CASE_P(NormalOrPanel, |
| 1608 DockedWindowResizerTest, | 1608 DockedWindowResizerTest, |
| 1609 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, | 1609 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, |
| 1610 ui::wm::WINDOW_TYPE_PANEL)); | 1610 ui::wm::WINDOW_TYPE_PANEL)); |
| 1611 | 1611 |
| 1612 } // namespace ash | 1612 } // namespace ash |
| OLD | NEW |