diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-13 22:39:40 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-13 22:39:40 +0000 |
commit | 4e437633645a53d94a0e6faa4f0137d41f34bad8 (patch) | |
tree | 529e99594ab7d8039348d0b8dbad594e905fbde9 /ash | |
parent | a6381cb574d7e48fd577aab1270d5298a16af6bc (diff) | |
download | chromium_src-4e437633645a53d94a0e6faa4f0137d41f34bad8.zip chromium_src-4e437633645a53d94a0e6faa4f0137d41f34bad8.tar.gz chromium_src-4e437633645a53d94a0e6faa4f0137d41f34bad8.tar.bz2 |
ash: Hide the shelf/launcher in managed mode when a window goes fullscreen.
BUG=112914
TEST=aura_shell_unittests:ShellTest.FullscreenWindowHidesShelf
Review URL: https://chromiumcodereview.appspot.com/9374008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121745 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/shell.cc | 6 | ||||
-rw-r--r-- | ash/shell.h | 8 | ||||
-rw-r--r-- | ash/shell_unittest.cc | 41 | ||||
-rw-r--r-- | ash/wm/workspace/workspace_manager.cc | 18 | ||||
-rw-r--r-- | ash/wm/workspace/workspace_manager.h | 8 |
5 files changed, 79 insertions, 2 deletions
diff --git a/ash/shell.cc b/ash/shell.cc index f5f2246..2916c7d 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -40,6 +40,7 @@ #include "ash/wm/workspace_controller.h" #include "ash/wm/workspace/workspace_event_filter.h" #include "ash/wm/workspace/workspace_layout_manager.h" +#include "ash/wm/workspace/workspace_manager.h" #include "base/bind.h" #include "base/command_line.h" #include "ui/aura/client/aura_constants.h" @@ -205,6 +206,7 @@ Shell::Shell(ShellDelegate* delegate) accelerator_controller_(new AcceleratorController), #endif delegate_(delegate), + shelf_(NULL), window_mode_(MODE_OVERLAPPING), root_window_layout_(NULL), status_widget_(NULL) { @@ -488,6 +490,8 @@ void Shell::SetupCompactWindowMode() { DCHECK(root_window_layout_); DCHECK(status_widget_); + shelf_ = NULL; + // Clean out the old layout managers before we start. ResetLayoutManager(internal::kShellWindowId_DefaultContainer); ResetLayoutManager(internal::kShellWindowId_LauncherContainer); @@ -541,6 +545,7 @@ void Shell::SetupNonCompactWindowMode() { new internal::ShelfLayoutManager(launcher_->widget(), status_widget_); GetContainer(internal::kShellWindowId_LauncherContainer)-> SetLayoutManager(shelf_layout_manager); + shelf_ = shelf_layout_manager; internal::StatusAreaLayoutManager* status_area_layout_manager = new internal::StatusAreaLayoutManager(shelf_layout_manager); @@ -553,6 +558,7 @@ void Shell::SetupNonCompactWindowMode() { // Workspace manager has its own layout managers. workspace_controller_.reset( new internal::WorkspaceController(default_container)); + workspace_controller_->workspace_manager()->set_shelf(shelf_layout_manager); } else { // Default layout manager. internal::ToplevelLayoutManager* toplevel_layout_manager = diff --git a/ash/shell.h b/ash/shell.h index 833cfee..dcc7552 100644 --- a/ash/shell.h +++ b/ash/shell.h @@ -52,6 +52,7 @@ class FocusCycler; class InputMethodEventFilter; class RootWindowLayoutManager; class ShadowController; +class ShelfLayoutManager; class StackingController; class TooltipController; class VisibilityController; @@ -159,6 +160,8 @@ class ASH_EXPORT Shell { Launcher* launcher() { return launcher_.get(); } + internal::ShelfLayoutManager* shelf() const { return shelf_; } + // Made available for tests. internal::ShadowController* shadow_controller() { return shadow_controller_.get(); @@ -233,6 +236,11 @@ class ASH_EXPORT Shell { scoped_ptr<internal::AcceleratorFilter> accelerator_filter_; #endif + // The shelf for managing the launcher and the status widget in non-compact + // mode. Shell does not own the shelf. Instead, it is owned by container of + // the status area. + internal::ShelfLayoutManager* shelf_; + // Can change at runtime. WindowMode window_mode_; diff --git a/ash/shell_unittest.cc b/ash/shell_unittest.cc index a852188..87a3edf 100644 --- a/ash/shell_unittest.cc +++ b/ash/shell_unittest.cc @@ -8,8 +8,10 @@ #include "ash/shell_window_ids.h" #include "ash/test/aura_shell_test_base.h" #include "ash/wm/root_window_layout_manager.h" +#include "ash/wm/shelf_layout_manager.h" #include "base/command_line.h" #include "base/utf_string_conversions.h" +#include "ui/aura/client/aura_constants.h" #include "ui/aura/test/aura_test_base.h" #include "ui/aura/root_window.h" #include "ui/aura/window.h" @@ -416,4 +418,43 @@ TEST_F(ShellTest, ResizeRootWindow) { } #endif // defined(OS_CHROMEOS) +TEST_F(ShellTest, FullscreenWindowHidesShelf) { + ExpectAllContainers(); + Shell* shell = Shell::GetInstance(); + + // Create a normal window. It is not maximized. + views::Widget::InitParams widget_params( + views::Widget::InitParams::TYPE_WINDOW); + widget_params.bounds.SetRect(11, 22, 300, 400); + views::Widget* widget = CreateTestWindow(widget_params); + widget->Show(); + EXPECT_FALSE(widget->IsMaximized()); + + // Test in the compact mode. There should be no shelf. + shell->ChangeWindowMode(Shell::MODE_COMPACT); + EXPECT_FALSE(Shell::GetInstance()->shelf()); + + // Test in the managed mode. + shell->ChangeWindowMode(Shell::MODE_MANAGED); + EXPECT_TRUE(Shell::GetInstance()->shelf()->visible()); + + widget->SetFullscreen(true); + EXPECT_FALSE(Shell::GetInstance()->shelf()->visible()); + + widget->Restore(); + EXPECT_TRUE(Shell::GetInstance()->shelf()->visible()); + + // Test in the overlap mode. + shell->ChangeWindowMode(Shell::MODE_OVERLAPPING); + EXPECT_TRUE(Shell::GetInstance()->shelf()->visible()); + + widget->SetFullscreen(true); + EXPECT_FALSE(Shell::GetInstance()->shelf()->visible()); + + widget->Restore(); + EXPECT_TRUE(Shell::GetInstance()->shelf()->visible()); + + widget->Close(); +} + } // namespace ash diff --git a/ash/wm/workspace/workspace_manager.cc b/ash/wm/workspace/workspace_manager.cc index 6e225f6..2331df9 100644 --- a/ash/wm/workspace/workspace_manager.cc +++ b/ash/wm/workspace/workspace_manager.cc @@ -7,6 +7,7 @@ #include <algorithm> #include "ash/wm/property_util.h" +#include "ash/wm/shelf_layout_manager.h" #include "ash/wm/window_util.h" #include "ash/wm/workspace/managed_workspace.h" #include "ash/wm/workspace/maximized_workspace.h" @@ -84,7 +85,8 @@ WorkspaceManager::WorkspaceManager(aura::Window* contents_view) is_overview_(false), ignored_window_(NULL), grid_size_(0), - open_new_windows_maximized_(true) { + open_new_windows_maximized_(true), + shelf_(NULL) { DCHECK(contents_view); } @@ -221,6 +223,7 @@ void WorkspaceManager::OnWindowPropertyChanged(aura::Window* window, // maximized to fullscreen. Adjust the bounds appropriately. SetFullScreenOrMaximizedBounds(window); } + UpdateShelfVisibility(); } //////////////////////////////////////////////////////////////////////////////// @@ -257,6 +260,15 @@ void WorkspaceManager::RemoveWorkspace(Workspace* workspace) { } } +void WorkspaceManager::UpdateShelfVisibility() { + if (!shelf_ || !active_workspace_) + return; + std::set<aura::Window*> windows; + windows.insert(active_workspace_->windows().begin(), + active_workspace_->windows().end()); + shelf_->SetVisible(!window_util::HasFullscreenWindow(windows)); +} + Workspace* WorkspaceManager::GetActiveWorkspace() const { return active_workspace_; } @@ -274,8 +286,10 @@ void WorkspaceManager::SetActiveWorkspace(Workspace* workspace) { if (active_workspace_) SetWindowLayerVisibility(active_workspace_->windows(), false); active_workspace_ = workspace; - if (active_workspace_) + if (active_workspace_) { SetWindowLayerVisibility(active_workspace_->windows(), true); + UpdateShelfVisibility(); + } is_overview_ = false; } diff --git a/ash/wm/workspace/workspace_manager.h b/ash/wm/workspace/workspace_manager.h index 5c25fff..2960287 100644 --- a/ash/wm/workspace/workspace_manager.h +++ b/ash/wm/workspace/workspace_manager.h @@ -27,6 +27,7 @@ class Rect; namespace ash { namespace internal { +class ShelfLayoutManager; class WorkspaceManagerTest; // WorkspaceManager manages multiple workspaces in the desktop. @@ -92,6 +93,8 @@ class ASH_EXPORT WorkspaceManager : public aura::WindowObserver{ // Returns a bounds aligned to the grid. Returns |bounds| if grid_size is 0. gfx::Rect AlignBoundsToGrid(const gfx::Rect& bounds); + void set_shelf(ShelfLayoutManager* shelf) { shelf_ = shelf; } + // Overriden from aura::WindowObserver: virtual void OnWindowPropertyChanged(aura::Window* window, const void* key, @@ -109,6 +112,8 @@ class ASH_EXPORT WorkspaceManager : public aura::WindowObserver{ void AddWorkspace(Workspace* workspace); void RemoveWorkspace(Workspace* workspace); + void UpdateShelfVisibility(); + // Returns the active workspace. Workspace* GetActiveWorkspace() const; @@ -167,6 +172,9 @@ class ASH_EXPORT WorkspaceManager : public aura::WindowObserver{ // See description above setter. bool open_new_windows_maximized_; + // Owned by the Shell container window LauncherContainer. May be NULL. + ShelfLayoutManager* shelf_; + DISALLOW_COPY_AND_ASSIGN(WorkspaceManager); }; |