diff options
author | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-08 17:11:04 +0000 |
---|---|---|
committer | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-08 17:11:04 +0000 |
commit | c73d1338b77657f56ef3257a06804cc25df9ea1b (patch) | |
tree | c32627d10292ace1537249c864c0be5a52d4ab9d /ash | |
parent | 54f297ebc4172d1a9db1db8f769054a1e2adc756 (diff) | |
download | chromium_src-c73d1338b77657f56ef3257a06804cc25df9ea1b.zip chromium_src-c73d1338b77657f56ef3257a06804cc25df9ea1b.tar.gz chromium_src-c73d1338b77657f56ef3257a06804cc25df9ea1b.tar.bz2 |
Ash: Remove compact window mode.
Remove MultipleWindowIndicatorButton
Clean up OpaqueBrowserFrameView
Remove CompactBrowserFrameView
Remove ash/wm/compact_layout_manager and compact_status_area_layout_manager
Remove window mode switches
Remove window mode from ash::Shell
Remove ShellDelegate::CycleOrder
Remove ShellDelegate::GetOverrideWindowMode
Remove all outside calls to Shell::IsWindowModeCompact
BUG=117284
TEST=existing tests
Review URL: https://chromiumcodereview.appspot.com/9630002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@125625 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/ash.gyp | 5 | ||||
-rw-r--r-- | ash/ash_switches.cc | 18 | ||||
-rw-r--r-- | ash/ash_switches.h | 4 | ||||
-rw-r--r-- | ash/focus_cycler.cc | 2 | ||||
-rw-r--r-- | ash/launcher/launcher_window_cycler.cc | 2 | ||||
-rw-r--r-- | ash/shell.cc | 99 | ||||
-rw-r--r-- | ash/shell.h | 42 | ||||
-rw-r--r-- | ash/shell/shell_main.cc | 8 | ||||
-rw-r--r-- | ash/shell_delegate.h | 13 | ||||
-rw-r--r-- | ash/shell_unittest.cc | 83 | ||||
-rw-r--r-- | ash/test/ash_test_base.cc | 7 | ||||
-rw-r--r-- | ash/test/ash_test_base.h | 5 | ||||
-rw-r--r-- | ash/test/test_shell_delegate.cc | 26 | ||||
-rw-r--r-- | ash/test/test_shell_delegate.h | 9 | ||||
-rw-r--r-- | ash/wm/compact_layout_manager.cc | 256 | ||||
-rw-r--r-- | ash/wm/compact_layout_manager.h | 94 | ||||
-rw-r--r-- | ash/wm/compact_layout_manager_unittest.cc | 232 | ||||
-rw-r--r-- | ash/wm/compact_status_area_layout_manager.cc | 77 | ||||
-rw-r--r-- | ash/wm/compact_status_area_layout_manager.h | 49 | ||||
-rw-r--r-- | ash/wm/window_cycle_controller.cc | 6 | ||||
-rw-r--r-- | ash/wm/window_cycle_controller_unittest.cc | 6 |
21 files changed, 25 insertions, 1018 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp index cb458d1..af8a639 100644 --- a/ash/ash.gyp +++ b/ash/ash.gyp @@ -139,10 +139,6 @@ 'wm/always_on_top_controller.h', 'wm/base_layout_manager.cc', 'wm/base_layout_manager.h', - 'wm/compact_layout_manager.cc', - 'wm/compact_layout_manager.h', - 'wm/compact_status_area_layout_manager.cc', - 'wm/compact_status_area_layout_manager.h', 'wm/custom_frame_view_ash.cc', 'wm/custom_frame_view_ash.h', 'wm/default_window_resizer.cc', @@ -299,7 +295,6 @@ 'tooltips/tooltip_controller_unittest.cc', 'wm/activation_controller_unittest.cc', 'wm/base_layout_manager_unittest.cc', - 'wm/compact_layout_manager_unittest.cc', 'wm/image_grid_unittest.cc', 'wm/panel_layout_manager_unittest.cc', 'wm/power_button_controller_unittest.cc', diff --git a/ash/ash_switches.cc b/ash/ash_switches.cc index b45a9e2..c03525a 100644 --- a/ash/ash_switches.cc +++ b/ash/ash_switches.cc @@ -14,12 +14,6 @@ namespace switches { // Use the in-progress uber system tray. const char kAshUberTray[] = "ash-uber-tray"; -// Force the "compact" window mode regardless of the value of kAuraWindowMode. -// This can be used to override a value set in chrome://flags. -// Also implies fully-opaque windows for performance. -// TODO(derat): Remove this once the normal mode is usable on all platforms. -const char kAuraForceCompactWindowMode[] = "aura-force-compact-window-mode"; - // Use Google-style dialog box frames. const char kAuraGoogleDialogFrames[] = "aura-google-dialog-frames"; @@ -35,18 +29,6 @@ const char kAuraNoShadows[] = "aura-no-shadows"; // If present animations are disabled. const char kAuraWindowAnimationsDisabled[] = "aura-window-animations-disabled"; -// Use a custom window style, e.g. --aura-window-mode=compact. -// When this flag is not passed we default to "overlapping" mode. -const char kAuraWindowMode[] = "aura-window-mode"; - -// Show only a single maximized window, like traditional non-Aura builds. -// Useful for low-resolution screens, such as on laptops. -const char kAuraWindowModeCompact[] = "compact"; - -// Smart window management with workspace manager that automatically lays out -// windows. -const char kAuraWindowModeManaged[] = "managed"; - // Use Aura to manage windows of type WINDOW_TYPE_PANEL. const char kAuraPanelManager[] = "aura-panels"; diff --git a/ash/ash_switches.h b/ash/ash_switches.h index 1b8fa7a..7f85ef9 100644 --- a/ash/ash_switches.h +++ b/ash/ash_switches.h @@ -17,14 +17,10 @@ namespace switches { // Please keep alphabetized. ASH_EXPORT extern const char kAshUberTray[]; -ASH_EXPORT extern const char kAuraForceCompactWindowMode[]; ASH_EXPORT extern const char kAuraGoogleDialogFrames[]; ASH_EXPORT extern const char kAuraLegacyPowerButton[]; ASH_EXPORT extern const char kAuraNoShadows[]; ASH_EXPORT extern const char kAuraWindowAnimationsDisabled[]; -ASH_EXPORT extern const char kAuraWindowMode[]; -ASH_EXPORT extern const char kAuraWindowModeCompact[]; -ASH_EXPORT extern const char kAuraWindowModeManaged[]; ASH_EXPORT extern const char kAuraPanelManager[]; } // namespace switches diff --git a/ash/focus_cycler.cc b/ash/focus_cycler.cc index 6a62757b..29dea55 100644 --- a/ash/focus_cycler.cc +++ b/ash/focus_cycler.cc @@ -64,7 +64,7 @@ void FocusCycler::RotateFocus(Direction direction) { // Activate the browser window. const std::vector<aura::Window*>& windows = Shell::GetInstance()->delegate()->GetCycleWindowList( - ShellDelegate::SOURCE_LAUNCHER, ShellDelegate::ORDER_MRU); + ShellDelegate::SOURCE_LAUNCHER); if (!windows.empty()) { aura::client::GetActivationClient(Shell::GetRootWindow())-> ActivateWindow(windows[0]); diff --git a/ash/launcher/launcher_window_cycler.cc b/ash/launcher/launcher_window_cycler.cc index 75f22ac..02903c9 100644 --- a/ash/launcher/launcher_window_cycler.cc +++ b/ash/launcher/launcher_window_cycler.cc @@ -26,7 +26,7 @@ void LauncherWindowCycler::Cycle() { if (!windows_.get()) { windows_.reset(new WindowCycleList( ash::Shell::GetInstance()->delegate()->GetCycleWindowList( - ShellDelegate::SOURCE_LAUNCHER, ShellDelegate::ORDER_MRU))); + ShellDelegate::SOURCE_LAUNCHER))); } if (windows_->empty()) delegate_->CreateNewWindow(); diff --git a/ash/shell.cc b/ash/shell.cc index ceae6ca..1e8742a6 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -27,8 +27,6 @@ #include "ash/tooltips/tooltip_controller.h" #include "ash/wm/activation_controller.h" #include "ash/wm/base_layout_manager.h" -#include "ash/wm/compact_layout_manager.h" -#include "ash/wm/compact_status_area_layout_manager.h" #include "ash/wm/custom_frame_view_ash.h" #include "ash/wm/dialog_frame_view.h" #include "ash/wm/panel_window_event_filter.h" @@ -287,10 +285,6 @@ bool Shell::initially_hide_cursor_ = false; Shell::TestApi::TestApi(Shell* shell) : shell_(shell) {} -Shell::WindowMode Shell::TestApi::ComputeWindowMode(CommandLine* cmd) const { - return shell_->ComputeWindowMode(cmd); -} - internal::RootWindowLayoutManager* Shell::TestApi::root_window_layout() { return shell_->root_window_layout_; } @@ -308,11 +302,12 @@ internal::WorkspaceController* Shell::TestApi::workspace_controller() { Shell::Shell(ShellDelegate* delegate) : root_window_(new aura::RootWindow), + root_filter_(NULL), delegate_(delegate), audio_controller_(NULL), brightness_controller_(NULL), + power_status_controller_(NULL), shelf_(NULL), - window_mode_(MODE_MANAGED), desktop_background_mode_(BACKGROUND_IMAGE), root_window_layout_(NULL), status_widget_(NULL) { @@ -425,11 +420,6 @@ void Shell::Init() { input_method_filter_.reset(new internal::InputMethodEventFilter); AddRootWindowEventFilter(input_method_filter_.get()); - // Window mode must be set before computing containers or layout managers. - CommandLine* command_line = CommandLine::ForCurrentProcess(); - if (!delegate_.get() || !delegate_->GetOverrideWindowMode(&window_mode_)) - window_mode_ = ComputeWindowMode(command_line); - aura::RootWindow* root_window = GetRootWindow(); root_window->SetCursor(aura::kCursorPointer); if (initially_hide_cursor_) @@ -447,6 +437,7 @@ void Shell::Init() { if (delegate_.get()) status_widget_ = delegate_->CreateStatusArea(); + CommandLine* command_line = CommandLine::ForCurrentProcess(); if (command_line->HasSwitch(switches::kAshUberTray)) { // TODO(sad): This is rather ugly at the moment. This is because we are // supporting both the old and the new status bar at the same time. This @@ -484,10 +475,7 @@ void Shell::Init() { GetContainer(internal::kShellWindowId_DefaultContainer); launcher_.reset(new Launcher(default_container)); - if (window_mode_ == MODE_COMPACT) - SetupCompactWindowMode(); - else - SetupManagedWindowMode(); + InitLayoutManagers(); if (!command_line->HasSwitch(switches::kAuraNoShadows)) shadow_controller_.reset(new internal::ShadowController()); @@ -514,25 +502,6 @@ void Shell::Init() { window_cycle_controller_.reset(new WindowCycleController); } -Shell::WindowMode Shell::ComputeWindowMode(CommandLine* command_line) const { - // Some devices don't perform well with overlapping windows. - if (command_line->HasSwitch(switches::kAuraForceCompactWindowMode)) - return MODE_COMPACT; - - // If user set the flag, use their desired behavior. - if (command_line->HasSwitch(switches::kAuraWindowMode)) { - std::string mode = - command_line->GetSwitchValueASCII(switches::kAuraWindowMode); - if (mode == switches::kAuraWindowModeCompact) - return MODE_COMPACT; - if (mode == switches::kAuraWindowModeManaged) - return MODE_MANAGED; - } - - // Managed is the default. - return Shell::MODE_MANAGED; -} - aura::Window* Shell::GetContainer(int container_id) { return const_cast<aura::Window*>( const_cast<const Shell*>(this)->GetContainer(container_id)); @@ -602,31 +571,16 @@ bool Shell::IsModalWindowOpen() const { return !modal_container->children().empty(); } -void Shell::SetCompactStatusAreaOffset(gfx::Size& offset) { - compact_status_area_offset_ = offset; - - // Trigger a relayout. - if (IsWindowModeCompact()) { - aura::LayoutManager* layout_manager = GetContainer( - internal::kShellWindowId_StatusContainer)->layout_manager(); - if (layout_manager) - layout_manager->OnWindowResized(); - } -} - views::NonClientFrameView* Shell::CreateDefaultNonClientFrameView( views::Widget* widget) { if (CommandLine::ForCurrentProcess()->HasSwitch( switches::kAuraGoogleDialogFrames)) { return new internal::DialogFrameView; } - // Normal non-compact-mode gets translucent-style window frames for dialogs. - if (!IsWindowModeCompact()) { - internal::CustomFrameViewAsh* frame_view = new internal::CustomFrameViewAsh; - frame_view->Init(widget); - return frame_view; - } - return NULL; + // Use translucent-style window frames for dialogs. + internal::CustomFrameViewAsh* frame_view = new internal::CustomFrameViewAsh; + frame_view->Init(widget); + return frame_view; } void Shell::RotateFocus(Direction direction) { @@ -638,38 +592,7 @@ void Shell::RotateFocus(Direction direction) { //////////////////////////////////////////////////////////////////////////////// // Shell, private: -// Compact mode has a simplified layout manager and doesn't use the shelf, -// desktop background, etc. The launcher still exists so we can use its -// data model and list of open windows, but we hide the UI to save space. -void Shell::SetupCompactWindowMode() { - DCHECK(root_window_layout_); - DCHECK(status_widget_); - - // Don't use an event filter for the default container, as we don't support - // window dragging, double-click to maximize, etc. - aura::Window* default_container = - GetContainer(internal::kShellWindowId_DefaultContainer); - default_container->SetEventFilter(NULL); - - // Set up our new layout managers. - internal::CompactLayoutManager* compact_layout_manager = - new internal::CompactLayoutManager(); - compact_layout_manager->set_status_area_widget(status_widget_); - internal::CompactStatusAreaLayoutManager* status_area_layout_manager = - new internal::CompactStatusAreaLayoutManager(status_widget_); - GetContainer(internal::kShellWindowId_StatusContainer)-> - SetLayoutManager(status_area_layout_manager); - default_container->SetLayoutManager(compact_layout_manager); - - // Keep the launcher for its data model, but hide it. Do this before - // maximizing the windows so the work area is the right size. - launcher_->widget()->Hide(); - - // Set a solid black background. - SetDesktopBackgroundMode(BACKGROUND_SOLID_COLOR); -} - -void Shell::SetupManagedWindowMode() { +void Shell::InitLayoutManagers() { DCHECK(root_window_layout_); DCHECK(status_widget_); @@ -698,10 +621,6 @@ void Shell::SetupManagedWindowMode() { SetDesktopBackgroundMode(BACKGROUND_IMAGE); } -void Shell::ResetLayoutManager(int container_id) { - GetContainer(container_id)->SetLayoutManager(NULL); -} - void Shell::DisableWorkspaceGridLayout() { if (workspace_controller_.get()) workspace_controller_->workspace_manager()->set_grid_size(0); diff --git a/ash/shell.h b/ash/shell.h index 0d27747..dc6415d 100644 --- a/ash/shell.h +++ b/ash/shell.h @@ -76,14 +76,6 @@ class WorkspaceController; // takes ownership of the Shell. class ASH_EXPORT Shell { public: - // In compact window mode we fill the screen with a single maximized window, - // similar to ChromeOS R17 and earlier. In managed mode we have overlapping - // windows arranged by the workspace. - enum WindowMode { - MODE_COMPACT, - MODE_MANAGED, - }; - enum BackgroundMode { BACKGROUND_IMAGE, BACKGROUND_SOLID_COLOR @@ -99,7 +91,6 @@ class ASH_EXPORT Shell { public: explicit TestApi(Shell* shell); - WindowMode ComputeWindowMode(CommandLine* cmd) const; internal::RootWindowLayoutManager* root_window_layout(); internal::InputMethodEventFilter* input_method_event_filter(); internal::WorkspaceController* workspace_controller(); @@ -125,10 +116,6 @@ class ASH_EXPORT Shell { // Get the singleton RootWindow used by the Shell. static aura::RootWindow* GetRootWindow(); - const gfx::Size& compact_status_area_offset() const { - return compact_status_area_offset_; - } - BackgroundMode desktop_background_mode() const { return desktop_background_mode_; } @@ -156,19 +143,12 @@ class ASH_EXPORT Shell { // Returns true if a modal dialog window is currently open. bool IsModalWindowOpen() const; - // See enum WindowMode for details. - bool IsWindowModeCompact() const { return window_mode_ == MODE_COMPACT; } - - // Sets the offset between the corner of the status area and the corner of the - // screen when we're using the compact window mode. - void SetCompactStatusAreaOffset(gfx::Size& offset); - // Creates a default views::NonClientFrameView for use by windows in the // Ash environment. views::NonClientFrameView* CreateDefaultNonClientFrameView( views::Widget* widget); - // Rotate focus through containers that can recieve focus. + // Rotate focus through containers that can receive focus. void RotateFocus(Direction direction); #if !defined(OS_MACOSX) @@ -237,17 +217,8 @@ class ASH_EXPORT Shell { void Init(); - // Returns the appropriate window mode to use based on the |command_line|. - WindowMode ComputeWindowMode(CommandLine* command_line) const; - - // Initializes or re-initializes the layout managers and event filters needed - // to support a given window mode and cleans up the unneeded ones. - void SetupCompactWindowMode(); - void SetupManagedWindowMode(); - - // Sets the LayoutManager of the container with the specified id to NULL. This - // has the effect of deleting the current LayoutManager. - void ResetLayoutManager(int container_id); + // Initializes the layout managers and event filters. + void InitLayoutManagers(); // Disables the workspace grid layout. void DisableWorkspaceGridLayout(); @@ -312,9 +283,6 @@ class ASH_EXPORT Shell { // the status area. internal::ShelfLayoutManager* shelf_; - // Does not change after Init(). - WindowMode window_mode_; - // Can change at runtime. BackgroundMode desktop_background_mode_; @@ -328,10 +296,6 @@ class ASH_EXPORT Shell { // |status_widget_|). scoped_ptr<SystemTray> tray_; - // Offset between the corner of the status area and the corner of the screen - // when in the compact window mode. - gfx::Size compact_status_area_offset_; - DISALLOW_COPY_AND_ASSIGN(Shell); }; diff --git a/ash/shell/shell_main.cc b/ash/shell/shell_main.cc index ada5027..c1c6d83 100644 --- a/ash/shell/shell_main.cc +++ b/ash/shell/shell_main.cc @@ -183,8 +183,7 @@ class ShellDelegateImpl : public ash::ShellDelegate { } std::vector<aura::Window*> GetCycleWindowList( - CycleSource source, - CycleOrder order) const OVERRIDE { + CycleSource source) const OVERRIDE { aura::Window* default_container = ash::Shell::GetInstance()->GetContainer( ash::internal::kShellWindowId_DefaultContainer); std::vector<aura::Window*> windows = default_container->children(); @@ -209,11 +208,6 @@ class ShellDelegateImpl : public ash::ShellDelegate { return NULL; } - virtual bool GetOverrideWindowMode( - ash::Shell::WindowMode* window_mode) OVERRIDE { - return false; - } - private: // Used to update Launcher. Owned by main. WindowWatcher* watcher_; diff --git a/ash/shell_delegate.h b/ash/shell_delegate.h index c5ec41b..8e9076e 100644 --- a/ash/shell_delegate.h +++ b/ash/shell_delegate.h @@ -34,11 +34,6 @@ class SystemTrayDelegate; // Delegate of the Shell. class ASH_EXPORT ShellDelegate { public: - enum CycleOrder { - ORDER_MRU, // Most recently used - ORDER_LINEAR - }; - // Source requesting the window list. enum CycleSource { // Windows are going to be used for alt-tab (or F5). @@ -72,8 +67,7 @@ class ASH_EXPORT ShellDelegate { // at the front of the list. Otherwise any order may be returned. The list // does not contain NULL pointers. virtual std::vector<aura::Window*> GetCycleWindowList( - CycleSource source, - CycleOrder order) const = 0; + CycleSource source) const = 0; // Invoked to start taking partial screenshot. virtual void StartPartialScreenshot( @@ -86,11 +80,6 @@ class ASH_EXPORT ShellDelegate { // Creates a system-tray delegate. Shell takes ownership of the delegate. virtual SystemTrayDelegate* CreateSystemTrayDelegate(SystemTray* tray) = 0; - - // Returns true if the delegate wants to override the window mode. Used only - // by testing. Returning false causes the shell to determine the default. - // TODO(beng): This can probably be removed once we only have one window mode. - virtual bool GetOverrideWindowMode(Shell::WindowMode* window_mode) = 0; }; } // namespace ash diff --git a/ash/shell_unittest.cc b/ash/shell_unittest.cc index a6791ce..7777ef0 100644 --- a/ash/shell_unittest.cc +++ b/ash/shell_unittest.cc @@ -287,35 +287,6 @@ TEST_F(ShellTest, IsScreenLocked) { EXPECT_FALSE(Shell::GetInstance()->IsScreenLocked()); } -TEST_F(ShellTest, ComputeWindowMode) { - // By default, we use managed mode. - Shell* shell = Shell::GetInstance(); - Shell::TestApi test_api(shell); - CommandLine command_line_blank(CommandLine::NO_PROGRAM); - EXPECT_EQ(Shell::MODE_MANAGED, - test_api.ComputeWindowMode(&command_line_blank)); - - // Sometimes we force compact mode. - CommandLine command_line_force(CommandLine::NO_PROGRAM); - command_line_force.AppendSwitch(switches::kAuraForceCompactWindowMode); - EXPECT_EQ(Shell::MODE_COMPACT, - test_api.ComputeWindowMode(&command_line_force)); - - // The user can set compact mode. - CommandLine command_line_compact(CommandLine::NO_PROGRAM); - command_line_compact.AppendSwitchASCII(switches::kAuraWindowMode, - switches::kAuraWindowModeCompact); - EXPECT_EQ(Shell::MODE_COMPACT, - test_api.ComputeWindowMode(&command_line_compact)); - - // The user can set managed. - CommandLine command_line_managed(CommandLine::NO_PROGRAM); - command_line_managed.AppendSwitchASCII(switches::kAuraWindowMode, - switches::kAuraWindowModeManaged); - EXPECT_EQ(Shell::MODE_MANAGED, - test_api.ComputeWindowMode(&command_line_managed)); -} - // Fails on Mac, see http://crbug.com/115662 #if defined(OS_MACOSX) #define MAYBE_ManagedWindowModeBasics FAILS_ManagedWindowModeBasics @@ -328,8 +299,6 @@ TEST_F(ShellTest, MAYBE_ManagedWindowModeBasics) { // We start with the usual window containers. ExpectAllContainers(); - // We're not in compact window mode by default. - EXPECT_FALSE(shell->IsWindowModeCompact()); // We have a default container event filter (for window drags). EXPECT_TRUE(GetDefaultContainer()->event_filter()); // Launcher is visible. @@ -381,56 +350,4 @@ TEST_F(ShellTest, FullscreenWindowHidesShelf) { widget->Close(); } -// By implementing GetOverrideWindowMode we make the Shell come up in compact -// window mode. -class ShellCompactWindowModeTest : public test::AshTestBase { - public: - ShellCompactWindowModeTest() {} - virtual ~ShellCompactWindowModeTest() {} - - protected: - virtual bool GetOverrideWindowMode(Shell::WindowMode* window_mode) { - *window_mode = Shell::MODE_COMPACT; - return true; - } - - private: - DISALLOW_COPY_AND_ASSIGN(ShellCompactWindowModeTest); -}; - -TEST_F(ShellCompactWindowModeTest, CompactWindowModeBasics) { - Shell* shell = Shell::GetInstance(); - Shell::TestApi test_api(shell); - - EXPECT_TRUE(shell->IsWindowModeCompact()); - // Compact mode does not use a default container event filter. - EXPECT_FALSE(GetDefaultContainer()->event_filter()); - // We have all the usual containers. - ExpectAllContainers(); - - // Compact mode has no shelf. - EXPECT_TRUE(shell->shelf() == NULL); - - // Create a window. In compact mode, windows are created maximized. - views::Widget::InitParams widget_params( - views::Widget::InitParams::TYPE_WINDOW); - widget_params.bounds.SetRect(11, 22, 300, 400); - widget_params.show_state = ui::SHOW_STATE_MAXIMIZED; - views::Widget* widget = CreateTestWindow(widget_params); - widget->Show(); - - // Window bounds got updated to fill the work area. - EXPECT_EQ(widget->GetWorkAreaBoundsInScreen(), - widget->GetWindowScreenBounds()); - // Launcher is hidden. - views::Widget* launcher_widget = shell->launcher()->widget(); - EXPECT_FALSE(launcher_widget->IsVisible()); - // Desktop background widget is gone but we have a layer. - EXPECT_FALSE(test_api.root_window_layout()->background_widget()); - EXPECT_TRUE(test_api.root_window_layout()->background_layer()); - - // Clean up. - widget->Close(); -} - } // namespace ash diff --git a/ash/test/ash_test_base.cc b/ash/test/ash_test_base.cc index 5fca288..e23ab8a 100644 --- a/ash/test/ash_test_base.cc +++ b/ash/test/ash_test_base.cc @@ -21,9 +21,6 @@ AshTestBase::~AshTestBase() { void AshTestBase::SetUp() { // Creates Shell and hook with Desktop. TestShellDelegate* delegate = new TestShellDelegate; - Shell::WindowMode window_mode = Shell::MODE_MANAGED; - if (GetOverrideWindowMode(&window_mode)) - delegate->SetOverrideWindowMode(window_mode); ash::Shell::CreateInstance(delegate); helper_.SetUp(); @@ -43,10 +40,6 @@ void AshTestBase::TearDown() { Shell::DeleteInstance(); } -bool AshTestBase::GetOverrideWindowMode(Shell::WindowMode* window_mode) { - return false; -} - void AshTestBase::RunAllPendingInMessageLoop() { helper_.RunAllPendingInMessageLoop(Shell::GetRootWindow()); } diff --git a/ash/test/ash_test_base.h b/ash/test/ash_test_base.h index 85a1f35..e7b929f 100644 --- a/ash/test/ash_test_base.h +++ b/ash/test/ash_test_base.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -24,9 +24,6 @@ class AshTestBase : public testing::Test { virtual void TearDown() OVERRIDE; protected: - // Overridden by test cases to specify what window mode to run the shell in. - virtual bool GetOverrideWindowMode(Shell::WindowMode* window_mode); - void RunAllPendingInMessageLoop(); private: diff --git a/ash/test/test_shell_delegate.cc b/ash/test/test_shell_delegate.cc index 6ec4864..16caee5 100644 --- a/ash/test/test_shell_delegate.cc +++ b/ash/test/test_shell_delegate.cc @@ -15,19 +15,12 @@ namespace ash { namespace test { -TestShellDelegate::TestShellDelegate() - : override_window_mode_(false), - window_mode_(Shell::MODE_MANAGED) { +TestShellDelegate::TestShellDelegate() { } TestShellDelegate::~TestShellDelegate() { } -void TestShellDelegate::SetOverrideWindowMode(Shell::WindowMode window_mode) { - override_window_mode_ = true; - window_mode_ = window_mode; -} - views::Widget* TestShellDelegate::CreateStatusArea() { return NULL; } @@ -45,17 +38,14 @@ AppListViewDelegate* TestShellDelegate::CreateAppListViewDelegate() { } std::vector<aura::Window*> TestShellDelegate::GetCycleWindowList( - CycleSource source, - CycleOrder order) const { + CycleSource source) const { // We just use the Shell's default container of windows, so tests can be // written with the usual CreateTestWindowWithId() calls. But window cycling - // expects the topmost window at the front of the list, so reverse the order - // if we are mimicking MRU. + // expects the topmost window at the front of the list, so reverse the order. aura::Window* default_container = Shell::GetInstance()->GetContainer( internal::kShellWindowId_DefaultContainer); std::vector<aura::Window*> windows = default_container->children(); - if (order != ShellDelegate::ORDER_LINEAR) - std::reverse(windows.begin(), windows.end()); + std::reverse(windows.begin(), windows.end()); return windows; } @@ -75,13 +65,5 @@ SystemTrayDelegate* TestShellDelegate::CreateSystemTrayDelegate( return NULL; } -bool TestShellDelegate::GetOverrideWindowMode(Shell::WindowMode* window_mode) { - if (override_window_mode_) { - *window_mode = window_mode_; - return true; - } - return false; -} - } // namespace test } // namespace ash diff --git a/ash/test/test_shell_delegate.h b/ash/test/test_shell_delegate.h index 30f6f44..888b732 100644 --- a/ash/test/test_shell_delegate.h +++ b/ash/test/test_shell_delegate.h @@ -17,8 +17,6 @@ class TestShellDelegate : public ShellDelegate { TestShellDelegate(); virtual ~TestShellDelegate(); - void SetOverrideWindowMode(Shell::WindowMode window_mode); - // Overridden from ShellDelegate: virtual views::Widget* CreateStatusArea() OVERRIDE; #if defined(OS_CHROMEOS) @@ -27,19 +25,14 @@ class TestShellDelegate : public ShellDelegate { virtual void Exit() OVERRIDE; virtual AppListViewDelegate* CreateAppListViewDelegate() OVERRIDE; virtual std::vector<aura::Window*> GetCycleWindowList( - CycleSource source, - CycleOrder order) const OVERRIDE; + CycleSource source) const OVERRIDE; virtual void StartPartialScreenshot( ScreenshotDelegate* screenshot_delegate) OVERRIDE; virtual LauncherDelegate* CreateLauncherDelegate( ash::LauncherModel* model) OVERRIDE; virtual SystemTrayDelegate* CreateSystemTrayDelegate(SystemTray* t) OVERRIDE; - virtual bool GetOverrideWindowMode(Shell::WindowMode* window_mode) OVERRIDE; private: - bool override_window_mode_; - Shell::WindowMode window_mode_; - DISALLOW_COPY_AND_ASSIGN(TestShellDelegate); }; diff --git a/ash/wm/compact_layout_manager.cc b/ash/wm/compact_layout_manager.cc deleted file mode 100644 index 9e65934..0000000 --- a/ash/wm/compact_layout_manager.cc +++ /dev/null @@ -1,256 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ash/wm/compact_layout_manager.h" - -#include <vector> - -#include "ash/shell.h" -#include "ash/shell_delegate.h" -#include "ash/shell_window_ids.h" -#include "ash/wm/window_util.h" -#include "ui/aura/client/aura_constants.h" -#include "ui/aura/window.h" -#include "ui/gfx/compositor/layer.h" -#include "ui/gfx/compositor/layer_animation_sequence.h" -#include "ui/gfx/compositor/scoped_layer_animation_settings.h" -#include "ui/gfx/screen.h" -#include "ui/views/widget/widget.h" - -namespace ash { -namespace internal { - -namespace { - -typedef std::vector<aura::Window*> WindowList; -typedef std::vector<aura::Window*>::const_iterator WindowListConstIter; - -// Convenience method to get the layer of this container. -ui::Layer* GetDefaultContainerLayer() { - return Shell::GetInstance()->GetContainer( - internal::kShellWindowId_DefaultContainer)->layer(); -} - -// Whether it is a window that should be animated on entrance. -bool ShouldAnimateOnEntrance(aura::Window* window) { - return window && - window->type() == aura::client::WINDOW_TYPE_NORMAL && - wm::IsWindowMaximized(window); -} - -// Adjust layer bounds to grow or shrink in |delta_width|. -void AdjustContainerLayerWidth(int delta_width) { - gfx::Rect bounds(GetDefaultContainerLayer()->bounds()); - bounds.set_width(bounds.width() + delta_width); - GetDefaultContainerLayer()->SetBounds(bounds); -} - -} // namespace - -///////////////////////////////////////////////////////////////////////////// -// CompactLayoutManager, public: - -CompactLayoutManager::CompactLayoutManager() - : status_area_widget_(NULL), - current_window_(NULL) { -} - -CompactLayoutManager::~CompactLayoutManager() { -} - -///////////////////////////////////////////////////////////////////////////// -// CompactLayoutManager, LayoutManager overrides: - -void CompactLayoutManager::OnWindowAddedToLayout(aura::Window* child) { - // Windows added to this container does not need extra animation. - if (child->type() == aura::client::WINDOW_TYPE_NORMAL) - child->SetProperty(aura::client::kAnimationsDisabledKey, true); - BaseLayoutManager::OnWindowAddedToLayout(child); - UpdateStatusAreaVisibility(); - if (windows().size() > 1 && - child->type() == aura::client::WINDOW_TYPE_NORMAL) { - // The first window is already contained in the current layer, - // add subsequent windows to layer bounds calculation. - AdjustContainerLayerWidth(child->bounds().width()); - } -} - -void CompactLayoutManager::OnWillRemoveWindowFromLayout(aura::Window* child) { - BaseLayoutManager::OnWillRemoveWindowFromLayout(child); - UpdateStatusAreaVisibility(); - if (windows().size() > 1 && ShouldAnimateOnEntrance(child)) - AdjustContainerLayerWidth(-child->bounds().width()); - - if (child == current_window_) { - LayoutWindows(current_window_); - SwitchToReplacementWindow(); - } - // Allow window to be animated by others. - if (child->type() == aura::client::WINDOW_TYPE_NORMAL) - child->SetProperty(aura::client::kAnimationsDisabledKey, false); -} - -void CompactLayoutManager::OnChildWindowVisibilityChanged(aura::Window* child, - bool visible) { - BaseLayoutManager::OnChildWindowVisibilityChanged(child, visible); - UpdateStatusAreaVisibility(); - if (ShouldAnimateOnEntrance(child)) { - LayoutWindows(visible ? NULL : child); - if (visible) { - current_window_ = child; - AnimateSlideTo(child->bounds().x()); - } else if (child == current_window_) { - SwitchToReplacementWindow(); - } - } -} - -void CompactLayoutManager::SetChildBounds(aura::Window* child, - const gfx::Rect& requested_bounds) { - gfx::Rect child_bounds(requested_bounds); - // Avoid a janky resize on startup by ensuring the initial bounds fill the - // screen. - if (wm::IsWindowMaximized(child)) - child_bounds = gfx::Screen::GetMonitorWorkAreaNearestWindow(child); - else if (wm::IsWindowFullscreen(child)) - child_bounds = gfx::Screen::GetMonitorAreaNearestWindow(child); - else if (current_window_) { - // All other windows should be offset by the current viewport. - int offset_x = current_window_->bounds().x(); - child_bounds.Offset(offset_x, 0); - } - SetChildBoundsDirect(child, child_bounds); -} - -///////////////////////////////////////////////////////////////////////////// -// CompactLayoutManager, aura::WindowObserver overrides: - -void CompactLayoutManager::OnWindowPropertyChanged(aura::Window* window, - const void* key, - intptr_t old) { - BaseLayoutManager::OnWindowPropertyChanged(window, key, old); - if (key == aura::client::kShowStateKey) - UpdateStatusAreaVisibility(); -} - -void CompactLayoutManager::OnWindowStackingChanged(aura::Window* window) { - if (!current_window_ || ShouldAnimateOnEntrance(window)) { - if (current_window_ != window) { - LayoutWindows(current_window_); - current_window_ = window; - } else { - // Same window as |current_window_|, and already animating. - if (GetDefaultContainerLayer()->GetAnimator()->is_animating()) - return; - } - // Animate to |window| when there is a stacking change. - AnimateSlideTo(window->bounds().x()); - } -} - -///////////////////////////////////////////////////////////////////////////// -// CompactLayoutManager, AnimationDelegate overrides: - -void CompactLayoutManager::OnImplicitAnimationsCompleted() { - if (!GetDefaultContainerLayer()->GetAnimator()->is_animating()) - HideWindows(); -} - -////////////////////////////////////////////////////////////////////////////// -// CompactLayoutManager, private: - -void CompactLayoutManager::UpdateStatusAreaVisibility() { - if (!status_area_widget_) - return; - // Full screen windows should hide the status area widget. - bool has_fullscreen = wm::HasFullscreenWindow(windows()); - bool widget_visible = status_area_widget_->IsVisible(); - if (has_fullscreen && widget_visible) - status_area_widget_->Hide(); - else if (!has_fullscreen && !widget_visible) - status_area_widget_->Show(); -} - -void CompactLayoutManager::AnimateSlideTo(int offset_x) { - GetDefaultContainerLayer()->GetAnimator()->RemoveObserver(this); - ui::ScopedLayerAnimationSettings settings( - GetDefaultContainerLayer()->GetAnimator()); - settings.AddObserver(this); - ui::Transform transform; - transform.ConcatTranslate(-offset_x, 0); - GetDefaultContainerLayer()->SetTransform(transform); // Will be animated! -} - -void CompactLayoutManager::LayoutWindows(aura::Window* skip) { - ShellDelegate* shell_delegate = ash::Shell::GetInstance()->delegate(); - const WindowList& windows_list = shell_delegate->GetCycleWindowList( - ShellDelegate::SOURCE_KEYBOARD, - ShellDelegate::ORDER_LINEAR); - int new_x = 0; - for (WindowListConstIter const_it = windows_list.begin(); - const_it != windows_list.end(); - ++const_it) { - if (*const_it != skip) { - gfx::Rect new_bounds((*const_it)->bounds()); - new_bounds.set_x(new_x); - SetChildBoundsDirect(*const_it, new_bounds); - (*const_it)->layer()->SetVisible(true); - new_x += (*const_it)->bounds().width(); - } - } -} - -void CompactLayoutManager::HideWindows() { - // If we do not know which one is the current window, or if the current - // window is not visible, do not attempt to hide the windows. - if (current_window_ == NULL) - return; - // Current window should be visible, if not it is an error and we shouldn't - // proceed. - if (!current_window_->layer()->visible()) - NOTREACHED() << "Current window is invisible"; - - ShellDelegate* shell_delegate = ash::Shell::GetInstance()->delegate(); - const WindowList& windows_list = shell_delegate->GetCycleWindowList( - ShellDelegate::SOURCE_KEYBOARD, - ShellDelegate::ORDER_LINEAR); - for (WindowListConstIter const_it = windows_list.begin(); - const_it != windows_list.end(); - ++const_it) { - if (*const_it != current_window_) - (*const_it)->layer()->SetVisible(false); - } -} - -aura::Window* CompactLayoutManager::FindReplacementWindow( - aura::Window* window) { - ShellDelegate* shell_delegate = ash::Shell::GetInstance()->delegate(); - const WindowList& windows_list = shell_delegate->GetCycleWindowList( - ShellDelegate::SOURCE_KEYBOARD, - ShellDelegate::ORDER_LINEAR); - WindowListConstIter const_it = std::find(windows_list.begin(), - windows_list.end(), - window); - if (windows_list.size() > 1 && const_it != windows_list.end()) { - do { - ++const_it; - if (const_it == windows_list.end()) - const_it = windows_list.begin(); - } while (*const_it != window && !(*const_it)->IsVisible()); - if (*const_it != window) - return *const_it; - } - return NULL; -} - -void CompactLayoutManager::SwitchToReplacementWindow() { - current_window_ = FindReplacementWindow(current_window_); - if (current_window_) { - wm::ActivateWindow(current_window_); - AnimateSlideTo(current_window_->bounds().x()); - } -} - -} // namespace internal -} // namespace ash diff --git a/ash/wm/compact_layout_manager.h b/ash/wm/compact_layout_manager.h deleted file mode 100644 index 4d713b6..0000000 --- a/ash/wm/compact_layout_manager.h +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef ASH_WM_COMPACT_LAYOUT_MANAGER_H_ -#define ASH_WM_COMPACT_LAYOUT_MANAGER_H_ -#pragma once - -#include "ash/ash_export.h" -#include "ash/wm/base_layout_manager.h" -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "base/gtest_prod_util.h" -#include "ui/gfx/compositor/layer_animation_observer.h" - -namespace views { -class Widget; -} - -namespace ash { -namespace internal { - -// CompactLayoutManager is the LayoutManager used in compact window mode, -// which emulates the traditional Chrome OS window manager. Windows are always -// maximized, fill the screen, and only one tabbed browser window is visible at -// a time. The status area appears in the top-right corner of the screen. -class ASH_EXPORT CompactLayoutManager : public BaseLayoutManager, - public ui::ImplicitAnimationObserver { - public: - CompactLayoutManager(); - virtual ~CompactLayoutManager(); - - void set_status_area_widget(views::Widget* widget) { - status_area_widget_ = widget; - } - - // LayoutManager overrides: - virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE; - virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE; - virtual void OnChildWindowVisibilityChanged(aura::Window* child, - bool visibile) OVERRIDE; - virtual void SetChildBounds(aura::Window* child, - const gfx::Rect& requested_bounds) OVERRIDE; - - // aura::WindowObserver overrides: - virtual void OnWindowPropertyChanged(aura::Window* window, - const void* key, - intptr_t old) OVERRIDE; - virtual void OnWindowStackingChanged(aura::Window* window) OVERRIDE; - - // ui::LayerAnimationObserver overrides: - virtual void OnImplicitAnimationsCompleted() OVERRIDE; - - private: - FRIEND_TEST_ALL_PREFIXES(CompactLayoutManagerTest, TransitionTest); - FRIEND_TEST_ALL_PREFIXES(CompactLayoutManagerTest, CloseAllWindows); - - // Hides the status area if we are managing it and full screen windows are - // visible. - void UpdateStatusAreaVisibility(); - - // Start a slide in / out animation sequence for the layer. - // The underlying layer is translated to -|offset_x| position. - void AnimateSlideTo(int offset_x); - - // Layout all browser windows currently in the window cycle list. - // skip |skip_this_window| if we do not want the window to be laid out. - void LayoutWindows(aura::Window* skip_this_window); - - // Hides all but the |current_window_| in the windows list. If we - // cannot determine the |current_window_|, we do not hide any. - void HideWindows(); - - // Returns the next window after |window| in the window cycle list. - // This could return NULL if we cannot find a next window. - aura::Window* FindReplacementWindow(aura::Window* window); - - // Switches to a replacement window of |current_window_|. - void SwitchToReplacementWindow(); - - // Status area with clock, network, battery, etc. icons. May be NULL if the - // shelf is managing the status area. - views::Widget* status_area_widget_; - - // The browser window currently in the viewport. - aura::Window* current_window_; - - DISALLOW_COPY_AND_ASSIGN(CompactLayoutManager); -}; - -} // namespace ash -} // namespace internal - -#endif // ASH_WM_COMPACT_LAYOUT_MANAGER_H_ diff --git a/ash/wm/compact_layout_manager_unittest.cc b/ash/wm/compact_layout_manager_unittest.cc deleted file mode 100644 index 55c8df6..0000000 --- a/ash/wm/compact_layout_manager_unittest.cc +++ /dev/null @@ -1,232 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ash/wm/compact_layout_manager.h" - -#include "ash/shell.h" -#include "ash/shell_window_ids.h" -#include "ash/test/ash_test_base.h" -#include "ash/wm/shelf_layout_manager.h" -#include "ash/wm/window_util.h" -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "ui/aura/client/aura_constants.h" -#include "ui/aura/root_window.h" -#include "ui/aura/screen_aura.h" -#include "ui/aura/test/test_windows.h" -#include "ui/aura/window.h" -#include "ui/base/ui_base_types.h" -#include "ui/views/widget/widget.h" - -namespace ash { - -namespace { - -const int kMaxWidth = 800; -const int kMaxHeight = 600; - -} // namespace - -namespace internal { - -class CompactLayoutManagerTest : public ash::test::AshTestBase { - public: - CompactLayoutManagerTest() : layout_manager_(NULL) { - } - virtual ~CompactLayoutManagerTest() {} - - virtual void SetUp() OVERRIDE { - ash::test::AshTestBase::SetUp(); - Shell::GetRootWindow()->Show(); - Shell::GetRootWindow()->SetHostSize(gfx::Size(kMaxWidth, kMaxHeight)); - default_container()->SetBounds(gfx::Rect(0, 0, kMaxWidth, kMaxHeight)); - layout_manager_ = new internal::CompactLayoutManager(); - default_container()->SetLayoutManager(layout_manager_); - default_container()->Show(); - // Control layer animation stepping. - default_container()->layer()->GetAnimator()-> - set_disable_timer_for_test(true); - RunAllPendingInMessageLoop(); - } - - aura::Window* CreateNormalWindow(int id) { - aura::Window* window = new aura::Window(NULL); - window->set_id(id); - window->SetType(aura::client::WINDOW_TYPE_NORMAL); - window->Init(ui::Layer::LAYER_TEXTURED); - window->SetBounds(gfx::Rect(0, 0, kMaxWidth, kMaxHeight)); - window->SetParent(default_container()); - wm::MaximizeWindow(window); - window->Show(); - RunAllPendingInMessageLoop(); - return window; - } - - aura::Window* CreateTestWindow(const gfx::Rect& bounds) { - return aura::test::CreateTestWindowWithBounds(bounds, default_container()); - } - - // Returns widget owned by its parent, so doesn't need scoped_ptr<>. - views::Widget* CreateTestWidget() { - views::Widget* widget = new views::Widget; - views::Widget::InitParams params( - views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); - params.bounds = gfx::Rect(11, 22, 33, 44); - widget->Init(params); - widget->Show(); - return widget; - } - - internal::CompactLayoutManager* layout_manager() { - return layout_manager_; - } - - aura::Window* default_container() const { - return ash::Shell::GetInstance()->GetContainer( - ash::internal::kShellWindowId_DefaultContainer); - } - - int default_container_layer_width() const { - return default_container()->layer()->bounds().width(); - } - - ui::Transform default_container_layer_transform() const { - return default_container()->layer()->GetTargetTransform(); - } - - ui::AnimationContainerElement* animation_element() { - return default_container()->layer()->GetAnimator(); - } - - protected: - internal::CompactLayoutManager* layout_manager_; - - private: - DISALLOW_COPY_AND_ASSIGN(CompactLayoutManagerTest); -}; - -// Tests status area visibility during window maximize and fullscreen. -TEST_F(CompactLayoutManagerTest, StatusAreaVisibility) { - gfx::Rect bounds(100, 100, 200, 200); - scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); - views::Widget* widget = CreateTestWidget(); - layout_manager()->set_status_area_widget(widget); - EXPECT_TRUE(widget->IsVisible()); - window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); - EXPECT_TRUE(widget->IsVisible()); - window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); - EXPECT_TRUE(widget->IsVisible()); - window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); - EXPECT_FALSE(widget->IsVisible()); - window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); - EXPECT_TRUE(widget->IsVisible()); -} - -#if defined(OS_MACOSX) -#define MAYBE_TransitionTest FAILS_TransitionTest -#else -#define MAYBE_TransitionTest TransitionTest -#endif -TEST_F(CompactLayoutManagerTest, MAYBE_TransitionTest) { - // Assert on viewport size to be the host size. - ASSERT_EQ(kMaxWidth, default_container_layer_width()); - // Create 3 windows, check that the layer grow as each one is added - // to the layout. - aura::Window* window1 = CreateNormalWindow(0); - EXPECT_EQ(kMaxWidth, default_container_layer_width()); - aura::Window* window2 = CreateNormalWindow(1); - EXPECT_EQ(kMaxWidth * 2, default_container_layer_width()); - aura::Window* window3 = CreateNormalWindow(2); - EXPECT_EQ(kMaxWidth * 3, default_container_layer_width()); - animation_element()->Step(base::TimeTicks::Now() + - base::TimeDelta::FromSeconds(1)); - RunAllPendingInMessageLoop(); - - // Check laid out position of the windows. - EXPECT_EQ(0, window1->bounds().x()); - EXPECT_EQ(kMaxWidth, window2->bounds().x()); - EXPECT_EQ(kMaxWidth * 2, window3->bounds().x()); - - // Check layer transformation. - ui::Transform target_transform; - target_transform.ConcatTranslate(-window3->bounds().x(), 0); - EXPECT_EQ(target_transform, default_container_layer_transform()); - RunAllPendingInMessageLoop(); - - // Check that only one window is visible. - EXPECT_EQ(window3, layout_manager_->current_window_); - EXPECT_FALSE(window1->IsVisible()); - EXPECT_FALSE(window2->IsVisible()); - EXPECT_TRUE(window3->IsVisible()); - - // That window disappear, check that we transform the layer, and - // again only have one window visible. - window3->Hide(); - animation_element()->Step(base::TimeTicks::Now() + - base::TimeDelta::FromSeconds(1)); - ui::Transform target_transform1; - target_transform1.ConcatTranslate(-window1->bounds().x(), 0); - EXPECT_EQ(target_transform1, default_container_layer_transform()); - EXPECT_TRUE(window1->IsVisible()); - EXPECT_FALSE(window2->IsVisible()); - EXPECT_FALSE(window3->IsVisible()); - EXPECT_EQ(window1, layout_manager_->current_window_); -} - -TEST_F(CompactLayoutManagerTest, SwitchToNextVisibleWindow) { - // Create 3 windows - aura::Window* window1 = CreateNormalWindow(0); - window1->Hide(); // Hide window1 before its layer marked invisible. - aura::Window* window2 = CreateNormalWindow(1); - aura::Window* window3 = CreateNormalWindow(2); - - // Check that only window3 is visible. - EXPECT_FALSE(window1->IsVisible()); - EXPECT_FALSE(window2->IsVisible()); - EXPECT_TRUE(window3->IsVisible()); - - // Hide the current active window. - window3->Hide(); - - // And window2 becomes the current window because window1 is hidden. - EXPECT_FALSE(window1->IsVisible()); - EXPECT_TRUE(window2->IsVisible()); - EXPECT_FALSE(window3->IsVisible()); - - // Show window3 and it becomes the current window. - window3->Show(); - EXPECT_FALSE(window1->IsVisible()); - EXPECT_FALSE(window2->IsVisible()); - EXPECT_TRUE(window3->IsVisible()); - - // Close the current active window. - delete window3; - - // And window2 becomes active again. - EXPECT_FALSE(window1->IsVisible()); - EXPECT_TRUE(window2->IsVisible()); -} - -TEST_F(CompactLayoutManagerTest, CloseAllWindows) { - // Create 3 windows - aura::Window* window1 = CreateNormalWindow(0); - aura::Window* window2 = CreateNormalWindow(1); - aura::Window* window3 = CreateNormalWindow(2); - - // Check that only window3 is visible. - EXPECT_FALSE(window1->IsVisible()); - EXPECT_FALSE(window2->IsVisible()); - EXPECT_TRUE(window3->IsVisible()); - - // Close all windows. Note they should not be accessed after here. - delete window1; - delete window2; - delete window3; - - // No current window now. - EXPECT_EQ(NULL, layout_manager_->current_window_); -} - -} // namespace internal -} // namespace ash diff --git a/ash/wm/compact_status_area_layout_manager.cc b/ash/wm/compact_status_area_layout_manager.cc deleted file mode 100644 index 5e2fcc8..0000000 --- a/ash/wm/compact_status_area_layout_manager.cc +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ash/wm/compact_status_area_layout_manager.h" - -#include "ash/shell.h" -#include "base/auto_reset.h" -#include "base/i18n/rtl.h" -#include "ui/gfx/rect.h" -#include "ui/gfx/screen.h" -#include "ui/views/widget/widget.h" - -namespace ash { -namespace internal { - -//////////////////////////////////////////////////////////////////////////////// -// CompactStatusAreaLayoutManager, public: - -CompactStatusAreaLayoutManager::CompactStatusAreaLayoutManager( - views::Widget* status_widget) - : in_layout_(false), - status_widget_(status_widget) { -} - -CompactStatusAreaLayoutManager::~CompactStatusAreaLayoutManager() { -} - -//////////////////////////////////////////////////////////////////////////////// -// CompactStatusAreaLayoutManager, aura::LayoutManager implementation: - -void CompactStatusAreaLayoutManager::OnWindowResized() { - LayoutStatusArea(); -} - -void CompactStatusAreaLayoutManager::OnWindowAddedToLayout( - aura::Window* child) { - LayoutStatusArea(); -} - -void CompactStatusAreaLayoutManager::OnWillRemoveWindowFromLayout( - aura::Window* child) { -} - -void CompactStatusAreaLayoutManager::OnChildWindowVisibilityChanged( - aura::Window* child, bool visible) { -} - -void CompactStatusAreaLayoutManager::SetChildBounds( - aura::Window* child, const gfx::Rect& requested_bounds) { - SetChildBoundsDirect(child, requested_bounds); - if (!in_layout_) - LayoutStatusArea(); -} - -//////////////////////////////////////////////////////////////////////////////// -// CompactStatusAreaLayoutManager, private: - -void CompactStatusAreaLayoutManager::LayoutStatusArea() { - AutoReset<bool> auto_reset_in_layout(&in_layout_, true); - gfx::Rect monitor_bounds = gfx::Screen::GetPrimaryMonitorBounds(); - gfx::Rect widget_bounds = status_widget_->GetRestoredBounds(); - gfx::Size offset = ash::Shell::GetInstance()->compact_status_area_offset(); - if (base::i18n::IsRTL()) { - // Place the widget in the top-left corner of the screen. - widget_bounds.set_x(monitor_bounds.x() + offset.width()); - } else { - // Place the widget in the top-right corner of the screen. - widget_bounds.set_x( - monitor_bounds.right() - widget_bounds.width() - offset.width()); - } - widget_bounds.set_y(offset.height()); - status_widget_->SetBounds(widget_bounds); -} - -} // namespace internal -} // namespace ash diff --git a/ash/wm/compact_status_area_layout_manager.h b/ash/wm/compact_status_area_layout_manager.h deleted file mode 100644 index cd676d8..0000000 --- a/ash/wm/compact_status_area_layout_manager.h +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef ASH_WM_COMPACT_STATUS_AREA_LAYOUT_MANAGER_H_ -#define ASH_WM_COMPACT_STATUS_AREA_LAYOUT_MANAGER_H_ -#pragma once - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "ui/aura/layout_manager.h" - -namespace views { -class Widget; -} - -namespace ash { -namespace internal { - -// CompactStatusAreaLayoutManager places the status area in the top-right -// corner of the screen. -class CompactStatusAreaLayoutManager : public aura::LayoutManager { - public: - explicit CompactStatusAreaLayoutManager(views::Widget* status_widget); - virtual ~CompactStatusAreaLayoutManager(); - - // Overridden from aura::LayoutManager: - virtual void OnWindowResized() OVERRIDE; - virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE; - virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE; - virtual void OnChildWindowVisibilityChanged(aura::Window* child, - bool visible) OVERRIDE; - virtual void SetChildBounds(aura::Window* child, - const gfx::Rect& requested_bounds) OVERRIDE; - - private: - // Place the status area widget in the corner of the screen. - void LayoutStatusArea(); - - bool in_layout_; - views::Widget* status_widget_; - - DISALLOW_COPY_AND_ASSIGN(CompactStatusAreaLayoutManager); -}; - -} // namespace internal -} // namespace ash - -#endif // ASH_WM_COMPACT_STATUS_AREA_LAYOUT_MANAGER_H_ diff --git a/ash/wm/window_cycle_controller.cc b/ash/wm/window_cycle_controller.cc index 2a81b6f..0df8bed 100644 --- a/ash/wm/window_cycle_controller.cc +++ b/ash/wm/window_cycle_controller.cc @@ -126,13 +126,9 @@ void WindowCycleController::AltKeyReleased() { // WindowCycleController, private: void WindowCycleController::StartCycling() { - // Most-recently-used cycling is confusing in compact window mode because - // you can't see all the windows. windows_.reset(new WindowCycleList( ash::Shell::GetInstance()->delegate()->GetCycleWindowList( - ShellDelegate::SOURCE_KEYBOARD, - Shell::GetInstance()->IsWindowModeCompact() ? - ShellDelegate::ORDER_LINEAR : ShellDelegate::ORDER_MRU))); + ShellDelegate::SOURCE_KEYBOARD))); } void WindowCycleController::Step(Direction direction) { diff --git a/ash/wm/window_cycle_controller_unittest.cc b/ash/wm/window_cycle_controller_unittest.cc index 3757bcc..499acdc 100644 --- a/ash/wm/window_cycle_controller_unittest.cc +++ b/ash/wm/window_cycle_controller_unittest.cc @@ -39,8 +39,7 @@ TEST_F(WindowCycleControllerTest, HandleCycleWindowBaseCases) { // Cycling doesn't crash if there are no windows. std::vector<Window*> windows = Shell::GetInstance()->delegate()-> - GetCycleWindowList(ShellDelegate::SOURCE_KEYBOARD, - ShellDelegate::ORDER_MRU); + GetCycleWindowList(ShellDelegate::SOURCE_KEYBOARD); EXPECT_TRUE(windows.empty()); controller->HandleCycleWindow(WindowCycleController::FORWARD, false); @@ -73,8 +72,7 @@ TEST_F(WindowCycleControllerTest, HandleCycleWindow) { // Window lists should return the topmost window in front. std::vector<Window*> windows = Shell::GetInstance()->delegate()-> - GetCycleWindowList(ShellDelegate::SOURCE_KEYBOARD, - ShellDelegate::ORDER_MRU); + GetCycleWindowList(ShellDelegate::SOURCE_KEYBOARD); ASSERT_EQ(3u, windows.size()); ASSERT_EQ(window0.get(), windows[0]); ASSERT_EQ(window1.get(), windows[1]); |