summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ash/shelf/shelf_layout_manager.h2
-rw-r--r--ash/wm/panels/panel_layout_manager.cc50
-rw-r--r--ash/wm/panels/panel_layout_manager.h13
-rw-r--r--ash/wm/panels/panel_layout_manager_unittest.cc46
4 files changed, 109 insertions, 2 deletions
diff --git a/ash/shelf/shelf_layout_manager.h b/ash/shelf/shelf_layout_manager.h
index fa16158..30ed3e5 100644
--- a/ash/shelf/shelf_layout_manager.h
+++ b/ash/shelf/shelf_layout_manager.h
@@ -34,6 +34,7 @@ class ScreenAsh;
class ShelfWidget;
namespace internal {
+class PanelLayoutManagerTest;
class ShelfLayoutManagerTest;
class StatusAreaWidget;
class WorkspaceController;
@@ -201,6 +202,7 @@ class ASH_EXPORT ShelfLayoutManager :
class AutoHideEventFilter;
class UpdateShelfObserver;
friend class ash::ScreenAsh;
+ friend class PanelLayoutManagerTest;
friend class ShelfLayoutManagerTest;
struct TargetBounds {
diff --git a/ash/wm/panels/panel_layout_manager.cc b/ash/wm/panels/panel_layout_manager.cc
index cacce2d..39350ac 100644
--- a/ash/wm/panels/panel_layout_manager.cc
+++ b/ash/wm/panels/panel_layout_manager.cc
@@ -252,6 +252,8 @@ PanelLayoutManager::PanelLayoutManager(aura::Window* panel_container)
in_layout_(false),
dragged_panel_(NULL),
launcher_(NULL),
+ shelf_layout_manager_(NULL),
+ shelf_hidden_(false),
last_active_panel_(NULL),
weak_factory_(this) {
DCHECK(panel_container);
@@ -261,6 +263,10 @@ PanelLayoutManager::PanelLayoutManager(aura::Window* panel_container)
}
PanelLayoutManager::~PanelLayoutManager() {
+ if (launcher_)
+ launcher_->RemoveIconObserver(this);
+ if (shelf_layout_manager_)
+ shelf_layout_manager_->RemoveObserver(this);
Shutdown();
aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())->
RemoveObserver(this);
@@ -290,8 +296,16 @@ void PanelLayoutManager::FinishDragging() {
}
void PanelLayoutManager::SetLauncher(ash::Launcher* launcher) {
+ DCHECK(!launcher_);
+ DCHECK(!shelf_layout_manager_);
launcher_ = launcher;
launcher_->AddIconObserver(this);
+ if (launcher_->shelf_widget()) {
+ shelf_layout_manager_ = ash::internal::ShelfLayoutManager::ForLauncher(
+ launcher_->shelf_widget()->GetNativeWindow());
+ WillChangeVisibilityState(shelf_layout_manager_->visibility_state());
+ shelf_layout_manager_->AddObserver(this);
+ }
}
void PanelLayoutManager::ToggleMinimize(aura::Window* panel) {
@@ -416,6 +430,10 @@ void PanelLayoutManager::OnWindowPropertyChanged(aura::Window* window,
intptr_t old) {
if (key != aura::client::kShowStateKey)
return;
+ // The window property will still be set, but no actual change will occur
+ // until WillChangeVisibilityState is called when the shelf is visible again.
+ if (shelf_hidden_)
+ return;
ui::WindowShowState new_state =
window->GetProperty(aura::client::kShowStateKey);
if (new_state == ui::SHOW_STATE_MINIMIZED)
@@ -445,6 +463,29 @@ void PanelLayoutManager::OnWindowActivated(aura::Window* gained_active,
}
////////////////////////////////////////////////////////////////////////////////
+// PanelLayoutManager, ShelfLayoutManager::Observer implementation:
+
+void PanelLayoutManager::WillChangeVisibilityState(
+ ShelfVisibilityState new_state) {
+ // On entering / leaving full screen mode the shelf visibility state is
+ // changed to / from SHELF_HIDDEN. In this state, panel windows should hide
+ // to allow the full-screen application to use the full screen.
+ shelf_hidden_ = new_state == ash::SHELF_HIDDEN;
+ for (PanelList::iterator iter = panel_windows_.begin();
+ iter != panel_windows_.end(); ++iter) {
+ if (shelf_hidden_) {
+ if (iter->window->IsVisible())
+ MinimizePanel(iter->window);
+ } else {
+ if (iter->window->GetProperty(aura::client::kShowStateKey) !=
+ ui::SHOW_STATE_MINIMIZED) {
+ RestorePanel(iter->window);
+ }
+ }
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
// PanelLayoutManager private implementation:
void PanelLayoutManager::MinimizePanel(aura::Window* panel) {
@@ -510,6 +551,15 @@ void PanelLayoutManager::Relayout() {
continue;
}
+ // If the shelf is currently hidden (full-screen mode), hide panel until
+ // full-screen mode is exited.
+ if (shelf_hidden_) {
+ // The call to Hide does not set the minimize property, so the window will
+ // be restored when the shelf becomes visible again.
+ panel->Hide();
+ continue;
+ }
+
gfx::Rect icon_bounds =
launcher_->GetScreenBoundsOfItemIconForWindow(panel);
diff --git a/ash/wm/panels/panel_layout_manager.h b/ash/wm/panels/panel_layout_manager.h
index e12d1ce..3d4371d 100644
--- a/ash/wm/panels/panel_layout_manager.h
+++ b/ash/wm/panels/panel_layout_manager.h
@@ -9,6 +9,7 @@
#include "ash/ash_export.h"
#include "ash/launcher/launcher_icon_observer.h"
+#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shell_observer.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
@@ -50,7 +51,8 @@ class ASH_EXPORT PanelLayoutManager
public ash::LauncherIconObserver,
public ash::ShellObserver,
public aura::WindowObserver,
- public aura::client::ActivationChangeObserver {
+ public aura::client::ActivationChangeObserver,
+ public ShelfLayoutManager::Observer {
public:
explicit PanelLayoutManager(aura::Window* panel_container);
virtual ~PanelLayoutManager();
@@ -93,6 +95,10 @@ class ASH_EXPORT PanelLayoutManager
virtual void OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) OVERRIDE;
+ // Overridden from ShelfLayoutManager::Observer
+ virtual void WillChangeVisibilityState(
+ ShelfVisibilityState new_state) OVERRIDE;
+
private:
friend class PanelLayoutManagerTest;
friend class PanelWindowResizerTest;
@@ -144,6 +150,11 @@ class ASH_EXPORT PanelLayoutManager
aura::Window* dragged_panel_;
// The launcher we are observing for launcher icon changes.
Launcher* launcher_;
+ // The shelf layout manager being observed for visibility changes.
+ ShelfLayoutManager* shelf_layout_manager_;
+ // Tracks the visibility of the shelf. Defaults to false when there is no
+ // shelf.
+ bool shelf_hidden_;
// The last active panel. Used to maintain stacking even if no panels are
// currently focused.
aura::Window* last_active_panel_;
diff --git a/ash/wm/panels/panel_layout_manager_unittest.cc b/ash/wm/panels/panel_layout_manager_unittest.cc
index 23318f1..f05e093 100644
--- a/ash/wm/panels/panel_layout_manager_unittest.cc
+++ b/ash/wm/panels/panel_layout_manager_unittest.cc
@@ -249,6 +249,14 @@ class PanelLayoutManagerTest : public test::AshTestBase {
shelf->UpdateAutoHideState();
}
+ void SetShelfVisibilityState(aura::Window* window,
+ ShelfVisibilityState visibility_state) {
+ internal::ShelfLayoutManager* shelf =
+ RootWindowController::ForWindow(window)->shelf()->
+ shelf_layout_manager();
+ shelf->SetState(visibility_state);
+ }
+
private:
scoped_ptr<test::LauncherViewTestAPI> launcher_view_test_;
@@ -274,7 +282,8 @@ TEST_F(PanelLayoutManagerTest, AddOnePanel) {
TEST_F(PanelLayoutManagerTest, PanelAlignsToHiddenLauncherIcon) {
gfx::Rect bounds(0, 0, 201, 201);
SetShelfAutoHideBehavior(Shell::GetPrimaryRootWindow(),
- SHELF_AUTO_HIDE_ALWAYS_HIDDEN);
+ SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+ RunAllPendingInMessageLoop();
scoped_ptr<aura::Window> window(CreatePanelWindow(bounds));
EXPECT_EQ(GetPanelContainer(window.get()), window->parent());
EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(window.get()));
@@ -638,5 +647,40 @@ TEST_F(PanelLayoutManagerTest, AlignmentTop) {
IsCalloutAboveLauncherIcon(w.get());
}
+// Tests that panels will hide and restore their state with the shelf visibility
+// state. This ensures that entering full-screen mode will hide your panels
+// until you leave it.
+TEST_F(PanelLayoutManagerTest, PanelsHideAndRestoreWithShelf) {
+ gfx::Rect bounds(0, 0, 201, 201);
+
+ scoped_ptr<aura::Window> w1(CreatePanelWindow(bounds));
+ scoped_ptr<aura::Window> w2(CreatePanelWindow(bounds));
+ scoped_ptr<aura::Window> w3;
+ // Minimize w2.
+ w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
+ RunAllPendingInMessageLoop();
+ EXPECT_TRUE(w1->IsVisible());
+ EXPECT_FALSE(w2->IsVisible());
+
+ SetShelfVisibilityState(Shell::GetPrimaryRootWindow(), SHELF_HIDDEN);
+ RunAllPendingInMessageLoop();
+
+ // w3 is created while in full-screen mode, should only become visible when
+ // we exit fullscreen mode.
+ w3.reset(CreatePanelWindow(bounds));
+
+ EXPECT_FALSE(w1->IsVisible());
+ EXPECT_FALSE(w2->IsVisible());
+ EXPECT_FALSE(w3->IsVisible());
+
+ SetShelfVisibilityState(Shell::GetPrimaryRootWindow(), SHELF_VISIBLE);
+ RunAllPendingInMessageLoop();
+
+ // Windows should be restored to their prior state.
+ EXPECT_TRUE(w1->IsVisible());
+ EXPECT_FALSE(w2->IsVisible());
+ EXPECT_TRUE(w3->IsVisible());
+}
+
} // namespace internal
} // namespace ash