summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
Diffstat (limited to 'ash')
-rw-r--r--ash/ash.gyp1
-rw-r--r--ash/shell.cc8
-rw-r--r--ash/shell.h7
-rw-r--r--ash/wm/shelf_auto_hide_behavior.h24
-rw-r--r--ash/wm/shelf_layout_manager.cc23
-rw-r--r--ash/wm/shelf_layout_manager.h11
-rw-r--r--ash/wm/shelf_layout_manager_unittest.cc24
7 files changed, 75 insertions, 23 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index 3bccd1a..615ddd2 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -202,6 +202,7 @@
'wm/partial_screenshot_event_filter.h',
'wm/partial_screenshot_view.cc',
'wm/partial_screenshot_view.h',
+ 'wm/shelf_auto_hide_behavior.h',
'wm/system_modal_container_layout_manager.cc',
'wm/system_modal_container_layout_manager.h',
'wm/system_modal_container_event_filter.cc',
diff --git a/ash/shell.cc b/ash/shell.cc
index 4c3282b..87021be 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -854,12 +854,12 @@ void Shell::UpdateShelfVisibility() {
shelf_->UpdateVisibilityState();
}
-void Shell::SetShelfAlwaysAutoHide(bool value) {
- shelf_->SetAlwaysAutoHide(value);
+void Shell::SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior) {
+ shelf_->SetAutoHideBehavior(behavior);
}
-bool Shell::GetShelfAlwaysAutoHide() const {
- return shelf_->always_auto_hide();
+ShelfAutoHideBehavior Shell::GetShelfAutoHideBehavior() const {
+ return shelf_->auto_hide_behavior();
}
int Shell::GetGridSize() const {
diff --git a/ash/shell.h b/ash/shell.h
index 5aac16a..10f972a 100644
--- a/ash/shell.h
+++ b/ash/shell.h
@@ -10,6 +10,7 @@
#include <vector>
#include "ash/ash_export.h"
+#include "ash/wm/shelf_auto_hide_behavior.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/gtest_prod_util.h"
@@ -209,9 +210,9 @@ class ASH_EXPORT Shell {
// Force the shelf to query for it's current visibility state.
void UpdateShelfVisibility();
- // Sets/gets whether the shelf always auto-hides.
- void SetShelfAlwaysAutoHide(bool value);
- bool GetShelfAlwaysAutoHide() const;
+ // Sets/gets the shelf auto-hide behavior.
+ void SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior);
+ ShelfAutoHideBehavior GetShelfAutoHideBehavior() const;
// TODO(sky): don't expose this!
internal::ShelfLayoutManager* shelf() const { return shelf_; }
diff --git a/ash/wm/shelf_auto_hide_behavior.h b/ash/wm/shelf_auto_hide_behavior.h
new file mode 100644
index 0000000..29c35da
--- /dev/null
+++ b/ash/wm/shelf_auto_hide_behavior.h
@@ -0,0 +1,24 @@
+// 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_SHELF_AUTO_HIDE_BEHAVIOR_H_
+#define ASH_WM_SHELF_AUTO_HIDE_BEHAVIOR_H_
+#pragma once
+
+namespace ash {
+
+enum ShelfAutoHideBehavior {
+ // The default; maximized windows trigger an auto-hide.
+ SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT,
+
+ // Always auto-hide.
+ SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
+
+ // Never auto-hide.
+ SHELF_AUTO_HIDE_BEHAVIOR_NEVER,
+};
+
+} // namespace ash
+
+#endif // ASH_WM_SHELF_AUTO_HIDE_BEHAVIOR_H_
diff --git a/ash/wm/shelf_layout_manager.cc b/ash/wm/shelf_layout_manager.cc
index 951fa73..6fd6e1b 100644
--- a/ash/wm/shelf_layout_manager.cc
+++ b/ash/wm/shelf_layout_manager.cc
@@ -106,7 +106,7 @@ ShelfLayoutManager::AutoHideEventFilter::PreHandleGestureEvent(
ShelfLayoutManager::ShelfLayoutManager(views::Widget* status)
: in_layout_(false),
- always_auto_hide_(false),
+ auto_hide_behavior_(SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT),
shelf_height_(status->GetWindowScreenBounds().height()),
launcher_(NULL),
status_(status),
@@ -117,10 +117,10 @@ ShelfLayoutManager::ShelfLayoutManager(views::Widget* status)
ShelfLayoutManager::~ShelfLayoutManager() {
}
-void ShelfLayoutManager::SetAlwaysAutoHide(bool value) {
- if (always_auto_hide_ == value)
+void ShelfLayoutManager::SetAutoHideBehavior(ShelfAutoHideBehavior behavior) {
+ if (auto_hide_behavior_ == behavior)
return;
- always_auto_hide_ = value;
+ auto_hide_behavior_ = behavior;
UpdateVisibilityState();
}
@@ -128,8 +128,13 @@ gfx::Rect ShelfLayoutManager::GetMaximizedWindowBounds(
aura::Window* window) const {
// TODO: needs to be multi-mon aware.
gfx::Rect bounds(gfx::Screen::GetMonitorAreaNearestWindow(window));
- bounds.set_height(bounds.height() - kAutoHideHeight);
- return bounds;
+ if (auto_hide_behavior_ == SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT ||
+ auto_hide_behavior_ == SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS) {
+ bounds.set_height(bounds.height() - kAutoHideHeight);
+ return bounds;
+ }
+ // SHELF_AUTO_HIDE_BEHAVIOR_NEVER maximized windows don't get any taller.
+ return GetUnmaximizedWorkAreaBounds(window);
}
gfx::Rect ShelfLayoutManager::GetUnmaximizedWorkAreaBounds(
@@ -183,12 +188,14 @@ void ShelfLayoutManager::UpdateVisibilityState() {
break;
case WorkspaceManager::WINDOW_STATE_MAXIMIZED:
- SetState(AUTO_HIDE);
+ SetState(auto_hide_behavior_ != SHELF_AUTO_HIDE_BEHAVIOR_NEVER ?
+ AUTO_HIDE : VISIBLE);
break;
case WorkspaceManager::WINDOW_STATE_WINDOW_OVERLAPS_SHELF:
case WorkspaceManager::WINDOW_STATE_DEFAULT:
- SetState(always_auto_hide_ ? AUTO_HIDE : VISIBLE);
+ SetState(auto_hide_behavior_ == SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS ?
+ AUTO_HIDE : VISIBLE);
SetWindowOverlapsShelf(window_state ==
WorkspaceManager::WINDOW_STATE_WINDOW_OVERLAPS_SHELF);
}
diff --git a/ash/wm/shelf_layout_manager.h b/ash/wm/shelf_layout_manager.h
index 05e3e7a..850aa80 100644
--- a/ash/wm/shelf_layout_manager.h
+++ b/ash/wm/shelf_layout_manager.h
@@ -8,6 +8,7 @@
#include "ash/ash_export.h"
#include "ash/launcher/launcher.h"
+#include "ash/wm/shelf_auto_hide_behavior.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/timer.h"
@@ -63,9 +64,11 @@ class ASH_EXPORT ShelfLayoutManager : public aura::LayoutManager {
explicit ShelfLayoutManager(views::Widget* status);
virtual ~ShelfLayoutManager();
- // Sets whether the shelf always auto-hides. Default is false.
- void SetAlwaysAutoHide(bool value);
- bool always_auto_hide() const { return always_auto_hide_; }
+ // Sets the ShelfAutoHideBehavior. See enum description for details.
+ void SetAutoHideBehavior(ShelfAutoHideBehavior behavior);
+ ShelfAutoHideBehavior auto_hide_behavior() const {
+ return auto_hide_behavior_;
+ }
void set_workspace_manager(WorkspaceManager* manager) {
workspace_manager_ = manager;
@@ -174,7 +177,7 @@ class ASH_EXPORT ShelfLayoutManager : public aura::LayoutManager {
bool in_layout_;
// See description above setter.
- bool always_auto_hide_;
+ ShelfAutoHideBehavior auto_hide_behavior_;
// Current state.
State state_;
diff --git a/ash/wm/shelf_layout_manager_unittest.cc b/ash/wm/shelf_layout_manager_unittest.cc
index f33605e..cd30b3d 100644
--- a/ash/wm/shelf_layout_manager_unittest.cc
+++ b/ash/wm/shelf_layout_manager_unittest.cc
@@ -263,8 +263,8 @@ TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) {
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
}
-// Assertions around SetAlwaysAutoHide.
-TEST_F(ShelfLayoutManagerTest, SetAlwaysAutoHide) {
+// Assertions around SetAutoHideBehavior.
+TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) {
ShelfLayoutManager* shelf = GetShelfLayoutManager();
views::Widget* widget = new views::Widget;
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
@@ -272,12 +272,28 @@ TEST_F(ShelfLayoutManagerTest, SetAlwaysAutoHide) {
// Widget is now owned by the parent window.
widget->Init(params);
widget->Show();
+ aura::Window* window = widget->GetNativeWindow();
+ gfx::Rect monitor_bounds(gfx::Screen::GetMonitorAreaNearestWindow(window));
+ EXPECT_EQ(monitor_bounds.bottom() - ShelfLayoutManager::kAutoHideHeight,
+ shelf->GetMaximizedWindowBounds(window).bottom());
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
- shelf->SetAlwaysAutoHide(true);
+ shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
+ EXPECT_EQ(monitor_bounds.bottom() - ShelfLayoutManager::kAutoHideHeight,
+ shelf->GetMaximizedWindowBounds(window).bottom());
- shelf->SetAlwaysAutoHide(FALSE);
+ shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT);
+ EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
+ EXPECT_EQ(monitor_bounds.bottom() - ShelfLayoutManager::kAutoHideHeight,
+ shelf->GetMaximizedWindowBounds(window).bottom());
+
+ shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
+ EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
+ EXPECT_GT(monitor_bounds.bottom() - ShelfLayoutManager::kAutoHideHeight,
+ shelf->GetMaximizedWindowBounds(window).bottom());
+
+ widget->Maximize();
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
}