summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-10 07:23:24 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-10 07:23:24 +0000
commit43d9663e465af59f73efed267228a909d1832fc4 (patch)
tree13eb247a9e68b617de8d6ff3862dfffb85b0adf5
parent51fc9987101b3012c879f78efc9f21c2e17f56de (diff)
downloadchromium_src-43d9663e465af59f73efed267228a909d1832fc4.zip
chromium_src-43d9663e465af59f73efed267228a909d1832fc4.tar.gz
chromium_src-43d9663e465af59f73efed267228a909d1832fc4.tar.bz2
Breaks ShelfLayoutManagerTest.ShelfBackgroundColor on Win8 Aura
Revert 210763 "Sets the background color of shelf is opaque blac..." > Sets the background color of shelf is opaque black when maximized. > > Previously the black color was achieved by hiding the desktop background. > Now shelf's background color is opaque black instead. > > Note that right now BaseLayoutManagerTest fails, but it'll be fixed by > crrev.com/18326024 > > BUG=252422 > R=jamescook@chromium.org > TEST=covered by the new tests > > Review URL: https://chromiumcodereview.appspot.com/18339008 TBR=mukai@chromium.org Review URL: https://codereview.chromium.org/18980003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@210772 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/root_window_controller.cc2
-rw-r--r--ash/shelf/shelf_layout_manager.cc58
-rw-r--r--ash/shelf/shelf_layout_manager.h11
-rw-r--r--ash/shelf/shelf_layout_manager_unittest.cc44
-rw-r--r--ash/shelf/shelf_types.h11
-rw-r--r--ash/shelf/shelf_widget.cc57
-rw-r--r--ash/shelf/shelf_widget.h9
-rw-r--r--ash/wm/workspace/workspace_layout_manager.cc56
-rw-r--r--ash/wm/workspace/workspace_manager.cc43
-rw-r--r--ash/wm/workspace/workspace_manager.h1
-rw-r--r--ash/wm/workspace/workspace_manager_unittest.cc51
11 files changed, 141 insertions, 202 deletions
diff --git a/ash/root_window_controller.cc b/ash/root_window_controller.cc
index 06e35fc..82ff30d 100644
--- a/ash/root_window_controller.cc
+++ b/ash/root_window_controller.cc
@@ -358,7 +358,7 @@ void RootWindowController::CloseChildWindows() {
shelf_->ShutdownStatusAreaWidget();
if (shelf_->shelf_layout_manager())
- shelf_->shelf_layout_manager()->PrepareForShutdown();
+ shelf_->shelf_layout_manager()->set_workspace_controller(NULL);
// Close background widget first as it depends on tooltip.
wallpaper_controller_.reset();
diff --git a/ash/shelf/shelf_layout_manager.cc b/ash/shelf/shelf_layout_manager.cc
index b0dab2f..c53da27 100644
--- a/ash/shelf/shelf_layout_manager.cc
+++ b/ash/shelf/shelf_layout_manager.cc
@@ -216,18 +216,8 @@ void ShelfLayoutManager::SetAutoHideBehavior(ShelfAutoHideBehavior behavior) {
OnAutoHideBehaviorChanged(auto_hide_behavior_));
}
-void ShelfLayoutManager::PrepareForShutdown() {
- // Clear all event filters, otherwise sometimes those filters may catch
- // synthesized mouse event and cause crashes during the shutdown.
- set_workspace_controller(NULL);
- auto_hide_event_filter_.reset();
- bezel_event_filter_.reset();
-}
-
bool ShelfLayoutManager::IsVisible() const {
- // status_area_widget() may be NULL during the shutdown.
- return shelf_->status_area_widget() &&
- shelf_->status_area_widget()->IsVisible() &&
+ return shelf_->status_area_widget()->IsVisible() &&
(state_.visibility_state == SHELF_VISIBLE ||
(state_.visibility_state == SHELF_AUTO_HIDE &&
state_.auto_hide_state == SHELF_AUTO_HIDE_SHOWN));
@@ -557,14 +547,15 @@ void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) {
state.auto_hide_state = CalculateAutoHideState(visibility_state);
state.is_screen_locked =
Shell::GetInstance()->session_state_delegate()->IsScreenLocked();
- state.window_state = workspace_controller_ ?
- workspace_controller_->GetWindowState() : WORKSPACE_WINDOW_STATE_DEFAULT;
// It's possible for SetState() when a window becomes maximized but the state
// won't have changed value. Do the dimming check before the early exit.
- shelf_->SetDimsShelf(
- (state.visibility_state == SHELF_VISIBLE) &&
- state.window_state == WORKSPACE_WINDOW_STATE_MAXIMIZED);
+ if (workspace_controller_) {
+ shelf_->SetDimsShelf(
+ (state.visibility_state == SHELF_VISIBLE) &&
+ workspace_controller_->GetWindowState() ==
+ WORKSPACE_WINDOW_STATE_MAXIMIZED);
+ }
if (state_.Equals(state))
return; // Nothing changed.
@@ -583,18 +574,12 @@ void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) {
auto_hide_timer_.Stop();
- // The transition of background from auto-hide to visible is janky if the
- // transition also cause the shelf's slide animation from the bottom edge.
- // This happens if:
- // - shelf is hidden
- // - or, shelf is visible but workspace state is maximized
- bool keep_maximized = state_.window_state == state.window_state &&
- state_.window_state == WORKSPACE_WINDOW_STATE_MAXIMIZED;
+ // Animating the background when transitioning from auto-hide & hidden to
+ // visible is janky. Update the background immediately in this case.
BackgroundAnimator::ChangeType change_type =
(state_.visibility_state == SHELF_AUTO_HIDE &&
- state.visibility_state == SHELF_VISIBLE &&
- (state_.auto_hide_state == SHELF_AUTO_HIDE_HIDDEN ||
- keep_maximized)) ?
+ state_.auto_hide_state == SHELF_AUTO_HIDE_HIDDEN &&
+ state.visibility_state == SHELF_VISIBLE) ?
BackgroundAnimator::CHANGE_IMMEDIATE : BackgroundAnimator::CHANGE_ANIMATE;
State old_state = state_;
@@ -625,13 +610,12 @@ void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) {
// animation you see the background change.
// Also delay the animation when the shelf was hidden, and has just been made
// visible (e.g. using a gesture-drag).
- // But do not delay if the transition happens when a window is maximized.
bool delay_shelf_update =
state.visibility_state == SHELF_AUTO_HIDE &&
state.auto_hide_state == SHELF_AUTO_HIDE_HIDDEN &&
old_state.visibility_state == SHELF_AUTO_HIDE;
- if (!keep_maximized && state.visibility_state == SHELF_VISIBLE &&
+ if (state.visibility_state == SHELF_VISIBLE &&
old_state.visibility_state == SHELF_AUTO_HIDE &&
old_state.auto_hide_state == SHELF_AUTO_HIDE_HIDDEN)
delay_shelf_update = true;
@@ -856,22 +840,14 @@ void ShelfLayoutManager::UpdateTargetBoundsForGesture(
void ShelfLayoutManager::UpdateShelfBackground(
BackgroundAnimator::ChangeType type) {
- shelf_->SetPaintsBackground(GetShelfBackgroundType(), type);
+ bool launcher_paints = GetLauncherPaintsBackground();
+ shelf_->SetPaintsBackground(launcher_paints, type);
}
-ShelfBackgroundType ShelfLayoutManager::GetShelfBackgroundType() const {
- if (state_.visibility_state != SHELF_AUTO_HIDE &&
- state_.window_state == WORKSPACE_WINDOW_STATE_MAXIMIZED) {
- return SHELF_BACKGROUND_MAXIMIZED;
- }
-
- if (gesture_drag_status_ == GESTURE_DRAG_IN_PROGRESS ||
+bool ShelfLayoutManager::GetLauncherPaintsBackground() const {
+ return gesture_drag_status_ == GESTURE_DRAG_IN_PROGRESS ||
(!state_.is_screen_locked && window_overlaps_shelf_) ||
- (state_.visibility_state == SHELF_AUTO_HIDE)) {
- return SHELF_BACKGROUND_OVERLAP;
- }
-
- return SHELF_BACKGROUND_DEFAULT;
+ (state_.visibility_state == SHELF_AUTO_HIDE);
}
void ShelfLayoutManager::UpdateAutoHideStateNow() {
diff --git a/ash/shelf/shelf_layout_manager.h b/ash/shelf/shelf_layout_manager.h
index 939a057..d49f42a 100644
--- a/ash/shelf/shelf_layout_manager.h
+++ b/ash/shelf/shelf_layout_manager.h
@@ -13,7 +13,6 @@
#include "ash/shelf/shelf_types.h"
#include "ash/shell_observer.h"
#include "ash/system/status_area_widget.h"
-#include "ash/wm/workspace/workspace_types.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/logging.h"
@@ -94,9 +93,6 @@ class ASH_EXPORT ShelfLayoutManager :
bool in_layout() const { return in_layout_; }
- // Clears internal data for shutdown process.
- void PrepareForShutdown();
-
// Returns whether the shelf and its contents (launcher, status) are visible
// on the screen.
bool IsVisible() const;
@@ -221,7 +217,6 @@ class ASH_EXPORT ShelfLayoutManager :
struct State {
State() : visibility_state(SHELF_VISIBLE),
auto_hide_state(SHELF_AUTO_HIDE_HIDDEN),
- window_state(WORKSPACE_WINDOW_STATE_DEFAULT),
is_screen_locked(false) {}
// Returns true if the two states are considered equal. As
@@ -232,13 +227,11 @@ class ASH_EXPORT ShelfLayoutManager :
return other.visibility_state == visibility_state &&
(visibility_state != SHELF_AUTO_HIDE ||
other.auto_hide_state == auto_hide_state) &&
- other.window_state == window_state &&
other.is_screen_locked == is_screen_locked;
}
ShelfVisibilityState visibility_state;
ShelfAutoHideState auto_hide_state;
- WorkspaceWindowState window_state;
bool is_screen_locked;
};
@@ -265,8 +258,8 @@ class ASH_EXPORT ShelfLayoutManager :
// Updates the background of the shelf.
void UpdateShelfBackground(BackgroundAnimator::ChangeType type);
- // Returns how the shelf background is painted.
- ShelfBackgroundType GetShelfBackgroundType() const;
+ // Returns whether the launcher should draw a background.
+ bool GetLauncherPaintsBackground() const;
// Updates the auto hide state immediately.
void UpdateAutoHideStateNow();
diff --git a/ash/shelf/shelf_layout_manager_unittest.cc b/ash/shelf/shelf_layout_manager_unittest.cc
index 7242161..20b5be0 100644
--- a/ash/shelf/shelf_layout_manager_unittest.cc
+++ b/ash/shelf/shelf_layout_manager_unittest.cc
@@ -1533,49 +1533,5 @@ TEST_F(ShelfLayoutManagerTest, BubbleEnlargesShelfMouseHitArea) {
}
}
-TEST_F(ShelfLayoutManagerTest, ShelfBackgroundColor) {
- EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, GetShelfWidget()->GetBackgroundType());
-
- scoped_ptr<aura::Window> w1(CreateTestWindow());
- w1->Show();
- wm::ActivateWindow(w1.get());
- EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, GetShelfWidget()->GetBackgroundType());
- w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
- EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, GetShelfWidget()->GetBackgroundType());
-
- scoped_ptr<aura::Window> w2(CreateTestWindow());
- w2->Show();
- wm::ActivateWindow(w2.get());
- // Overlaps with shelf.
- w2->SetBounds(GetShelfWidget()->GetWindowBoundsInScreen());
-
- // Still background is 'maximized'.
- EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, GetShelfWidget()->GetBackgroundType());
-
- w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
- EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, GetShelfWidget()->GetBackgroundType());
- w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
- EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, GetShelfWidget()->GetBackgroundType());
-
- w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
- EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, GetShelfWidget()->GetBackgroundType());
- w1.reset();
- EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, GetShelfWidget()->GetBackgroundType());
-}
-
-// Verify that the shelf doesn't have the opaque background if it's auto-hide
-// status.
-TEST_F(ShelfLayoutManagerTest, ShelfBackgroundColorAutoHide) {
- EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, GetShelfWidget ()->GetBackgroundType());
-
- GetShelfLayoutManager()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
- scoped_ptr<aura::Window> w1(CreateTestWindow());
- w1->Show();
- wm::ActivateWindow(w1.get());
- EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, GetShelfWidget()->GetBackgroundType());
- w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
- EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, GetShelfWidget()->GetBackgroundType());
-}
-
} // namespace internal
} // namespace ash
diff --git a/ash/shelf/shelf_types.h b/ash/shelf/shelf_types.h
index 4ee3b94..82cf630 100644
--- a/ash/shelf/shelf_types.h
+++ b/ash/shelf/shelf_types.h
@@ -41,17 +41,6 @@ enum ShelfAutoHideState {
SHELF_AUTO_HIDE_HIDDEN,
};
-enum ShelfBackgroundType {
- // The default transparent background.
- SHELF_BACKGROUND_DEFAULT,
-
- // The background when a window is overlapping.
- SHELF_BACKGROUND_OVERLAP,
-
- // The background when a window is maximized.
- SHELF_BACKGROUND_MAXIMIZED,
-};
-
} // namespace ash
#endif // ASH_SHELF_SHELF_TYPES_H_
diff --git a/ash/shelf/shelf_widget.cc b/ash/shelf/shelf_widget.cc
index 1f83de4..ad11e7d 100644
--- a/ash/shelf/shelf_widget.cc
+++ b/ash/shelf/shelf_widget.cc
@@ -27,7 +27,6 @@
#include "ui/base/events/event_constants.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/compositor/layer.h"
-#include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_skia_operations.h"
@@ -45,7 +44,6 @@ const int kDimAlpha = 128;
// The time to dim and un-dim.
const int kTimeToDimMs = 3000; // Slow in dimming.
const int kTimeToUnDimMs = 200; // Fast in activating.
-const int kTimeToSwitchBackgroundMs = 1000;
// Class used to slightly dim shelf items when maximized and visible.
class DimmerView : public views::View,
@@ -248,8 +246,6 @@ class ShelfWidget::DelegateView : public views::WidgetDelegate,
return focus_cycler_;
}
- ui::Layer* opaque_background() { return &opaque_background_; }
-
// Set if the shelf area is dimmed (eg when a window is maximized).
void SetDimmed(bool dimmed);
bool GetDimmed() const;
@@ -257,8 +253,6 @@ class ShelfWidget::DelegateView : public views::WidgetDelegate,
// Set the bounds of the widget.
void SetWidgetBounds(const gfx::Rect bounds);
- void SetParentLayer(ui::Layer* layer);
-
// views::View overrides:
virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE;
@@ -272,8 +266,6 @@ class ShelfWidget::DelegateView : public views::WidgetDelegate,
virtual bool CanActivate() const OVERRIDE;
virtual void Layout() OVERRIDE;
- virtual void ReorderChildLayers(ui::Layer* parent_layer) OVERRIDE;
- virtual void OnBoundsChanged(const gfx::Rect& old_bounds) OVERRIDE;
// BackgroundAnimatorDelegate overrides:
virtual void UpdateBackground(int alpha) OVERRIDE;
@@ -300,7 +292,6 @@ class ShelfWidget::DelegateView : public views::WidgetDelegate,
scoped_ptr<views::Widget> dimmer_;
internal::FocusCycler* focus_cycler_;
int alpha_;
- ui::Layer opaque_background_;
// The view which does the dimming.
DimmerView* dimmer_view_;
@@ -315,13 +306,9 @@ ShelfWidget::DelegateView::DelegateView(ShelfWidget* shelf)
: shelf_(shelf),
focus_cycler_(NULL),
alpha_(0),
- opaque_background_(ui::LAYER_SOLID_COLOR),
dimmer_view_(NULL),
disable_dimming_animations_for_test_(false) {
set_allow_deactivate_on_esc(true);
- opaque_background_.SetColor(SK_ColorBLACK);
- opaque_background_.SetBounds(GetLocalBounds());
- opaque_background_.SetOpacity(0.0f);
}
ShelfWidget::DelegateView::~DelegateView() {
@@ -364,11 +351,6 @@ void ShelfWidget::DelegateView::SetWidgetBounds(const gfx::Rect bounds) {
dimmer_->SetBounds(bounds);
}
-void ShelfWidget::DelegateView::SetParentLayer(ui::Layer* layer) {
- layer->Add(&opaque_background_);
- ReorderLayers();
-}
-
void ShelfWidget::DelegateView::OnPaintBackground(gfx::Canvas* canvas) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
gfx::ImageSkia launcher_background =
@@ -423,15 +405,6 @@ void ShelfWidget::DelegateView::Layout() {
}
}
-void ShelfWidget::DelegateView::ReorderChildLayers(ui::Layer* parent_layer) {
- views::View::ReorderChildLayers(parent_layer);
- parent_layer->StackAtBottom(&opaque_background_);
-}
-
-void ShelfWidget::DelegateView::OnBoundsChanged(const gfx::Rect& old_bounds) {
- opaque_background_.SetBounds(GetLocalBounds());
-}
-
void ShelfWidget::DelegateView::ForceUndimming(bool force) {
if (GetDimmed())
dimmer_view_->ForceUndimming(force);
@@ -472,7 +445,6 @@ ShelfWidget::ShelfWidget(aura::Window* shelf_container,
// The shelf should not take focus when initially shown.
set_focus_on_creation(false);
SetContentsView(delegate_view_);
- delegate_view_->SetParentLayer(GetLayer());
status_area_widget_ = new internal::StatusAreaWidget(status_container);
status_area_widget_->CreateTrayViews();
@@ -499,34 +471,9 @@ ShelfWidget::~ShelfWidget() {
}
void ShelfWidget::SetPaintsBackground(
- ShelfBackgroundType background_type,
+ bool value,
internal::BackgroundAnimator::ChangeType change_type) {
- ui::Layer* opaque_background = delegate_view_->opaque_background();
- float target_opacity =
- (background_type == SHELF_BACKGROUND_MAXIMIZED) ? 1.0f : 0.0f;
- scoped_ptr<ui::ScopedLayerAnimationSettings> opaque_background_animation;
- if (change_type != internal::BackgroundAnimator::CHANGE_IMMEDIATE) {
- opaque_background_animation.reset(new ui::ScopedLayerAnimationSettings(
- opaque_background->GetAnimator()));
- opaque_background_animation->SetTransitionDuration(
- base::TimeDelta::FromMilliseconds(kTimeToSwitchBackgroundMs));
- }
- opaque_background->SetOpacity(target_opacity);
-
- // TODO(mukai): use ui::Layer on both opaque_background and normal background
- // retire background_animator_ at all. It would be simpler.
- background_animator_.SetPaintsBackground(
- background_type != SHELF_BACKGROUND_DEFAULT,
- change_type);
-}
-
-ShelfBackgroundType ShelfWidget::GetBackgroundType() const {
- if (delegate_view_->opaque_background()->GetTargetOpacity() == 1.0f)
- return SHELF_BACKGROUND_MAXIMIZED;
- if (background_animator_.paints_background())
- return SHELF_BACKGROUND_OVERLAP;
-
- return SHELF_BACKGROUND_DEFAULT;
+ background_animator_.SetPaintsBackground(value, change_type);
}
ShelfAlignment ShelfWidget::GetAlignment() const {
diff --git a/ash/shelf/shelf_widget.h b/ash/shelf/shelf_widget.h
index 392264a..e7cbcf1 100644
--- a/ash/shelf/shelf_widget.h
+++ b/ash/shelf/shelf_widget.h
@@ -37,11 +37,14 @@ class ASH_EXPORT ShelfWidget : public views::Widget,
void SetAlignment(ShelfAlignment alignmnet);
ShelfAlignment GetAlignment() const;
- // Sets the shelf's background type.
+ // Sets whether the shelf paints a background. Default is false, but is set
+ // to true if a window overlaps the shelf.
void SetPaintsBackground(
- ShelfBackgroundType background_type,
+ bool value,
internal::BackgroundAnimator::ChangeType change_type);
- ShelfBackgroundType GetBackgroundType() const;
+ bool paints_background() const {
+ return background_animator_.paints_background();
+ }
// Causes shelf items to be slightly dimmed (eg when a window is maximized).
void SetDimsShelf(bool dimming);
diff --git a/ash/wm/workspace/workspace_layout_manager.cc b/ash/wm/workspace/workspace_layout_manager.cc
index 834a332..550f470 100644
--- a/ash/wm/workspace/workspace_layout_manager.cc
+++ b/ash/wm/workspace/workspace_layout_manager.cc
@@ -316,41 +316,29 @@ void WorkspaceLayoutManager::AdjustWindowSizesForScreenChange(
void WorkspaceLayoutManager::AdjustWindowSizeForScreenChange(
Window* window,
AdjustWindowReason reason) {
- if (!GetTrackedByWorkspace(window))
- return;
-
- // Use cross fade transition for the maximized window if the adjustment
- // happens due to the shelf's visibility change. Otherwise the background
- // can be seen slightly between the bottom edge of resized-window and
- // the animating shelf.
- // TODO(mukai): this cause slight blur at the window frame because of the
- // cross fade. I think this is better, but should reconsider if someone
- // raises voice for this.
- if (wm::IsWindowMaximized(window) &&
- reason == ADJUST_WINDOW_DISPLAY_INSETS_CHANGED) {
- CrossFadeToBounds(window, ScreenAsh::GetMaximizedWindowBoundsInParent(
- window->parent()->parent()));
- return;
- }
-
- if (SetMaximizedOrFullscreenBounds(window))
- return;
-
- gfx::Rect bounds = window->bounds();
- if (reason == ADJUST_WINDOW_SCREEN_SIZE_CHANGED) {
- // The work area may be smaller than the full screen. Put as much of the
- // window as possible within the display area.
- bounds.AdjustToFit(work_area_);
- } else if (reason == ADJUST_WINDOW_DISPLAY_INSETS_CHANGED) {
- ash::wm::AdjustBoundsToEnsureMinimumWindowVisibility(work_area_, &bounds);
- } else if (reason == ADJUST_WINDOW_WINDOW_ADDED) {
- int min_width = bounds.width() * kMinimumPercentOnScreenArea;
- int min_height = bounds.height() * kMinimumPercentOnScreenArea;
- ash::wm::AdjustBoundsToEnsureWindowVisibility(
- work_area_, min_width, min_height, &bounds);
+ if (GetTrackedByWorkspace(window) &&
+ !SetMaximizedOrFullscreenBounds(window)) {
+ if (reason == ADJUST_WINDOW_SCREEN_SIZE_CHANGED) {
+ // The work area may be smaller than the full screen. Put as much of the
+ // window as possible within the display area.
+ gfx::Rect bounds = window->bounds();
+ bounds.AdjustToFit(work_area_);
+ window->SetBounds(bounds);
+ } else if (reason == ADJUST_WINDOW_DISPLAY_INSETS_CHANGED) {
+ gfx::Rect bounds = window->bounds();
+ ash::wm::AdjustBoundsToEnsureMinimumWindowVisibility(work_area_, &bounds);
+ if (window->bounds() != bounds)
+ window->SetBounds(bounds);
+ } else if (reason == ADJUST_WINDOW_WINDOW_ADDED) {
+ gfx::Rect bounds = window->bounds();
+ int min_width = bounds.width() * kMinimumPercentOnScreenArea;
+ int min_height = bounds.height() * kMinimumPercentOnScreenArea;
+ ash::wm::AdjustBoundsToEnsureWindowVisibility(
+ work_area_, min_width, min_height, &bounds);
+ if (window->bounds() != bounds)
+ window->SetBounds(bounds);
+ }
}
- if (window->bounds() != bounds)
- window->SetBounds(bounds);
}
void WorkspaceLayoutManager::UpdateBoundsFromShowState(Window* window) {
diff --git a/ash/wm/workspace/workspace_manager.cc b/ash/wm/workspace/workspace_manager.cc
index f2b5278..a060df2 100644
--- a/ash/wm/workspace/workspace_manager.cc
+++ b/ash/wm/workspace/workspace_manager.cc
@@ -225,7 +225,6 @@ void WorkspaceManager::SetActiveWorkspaceByWindow(Window* window) {
base::TimeDelta());
}
}
-
if (workspace->is_fullscreen() && wm::IsWindowFullscreen(window)) {
// Clicking on the fullscreen window in a fullscreen workspace. Force all
// other windows to drop to the desktop.
@@ -539,6 +538,9 @@ void WorkspaceManager::ShowOrHideDesktopBackground(
case SWITCH_WORKSPACE_CYCLER:
// The workspace cycler has already animated the desktop background's
// opacity. Do not do any further animation.
+ case SWITCH_BACKGROUND_ONLY_WITHIN_DESKTOP:
+ // The show/hide of background may happen within the desktop workspace
+ // for maximized windows. In that case no animation is needed.
break;
case SWITCH_FULLSCREEN_FROM_FULLSCREEN_WORKSPACE:
case SWITCH_MAXIMIZED_OR_RESTORED:
@@ -679,6 +681,20 @@ void WorkspaceManager::OnWillRemoveWindowFromWorkspace(Workspace* workspace,
void WorkspaceManager::OnWindowRemovedFromWorkspace(Workspace* workspace,
Window* child) {
+ // Reappear the background which was hidden when a window is maximized.
+ if (wm::IsWindowMaximized(child) && workspace == active_workspace_ &&
+ GetWindowState() != WORKSPACE_WINDOW_STATE_MAXIMIZED) {
+ RootWindowController* root_controller = GetRootWindowController(
+ workspace->window()->GetRootWindow());
+ aura::Window* background = root_controller->GetContainer(
+ kShellWindowId_DesktopBackgroundContainer);;
+ ShowOrHideDesktopBackground(
+ background,
+ SWITCH_BACKGROUND_ONLY_WITHIN_DESKTOP,
+ base::TimeDelta(),
+ true);
+ }
+
if (workspace->ShouldMoveToPending())
MoveWorkspaceToPendingOrDelete(workspace, NULL, SWITCH_WINDOW_REMOVED);
UpdateShelfVisibility();
@@ -716,6 +732,31 @@ void WorkspaceManager::OnWorkspaceWindowShowStateChanged(
// |child| better still be in |workspace| else things have gone wrong.
DCHECK_EQ(workspace, child->GetProperty(kWorkspaceKey));
+ if (active_workspace_ == workspace) {
+ // Show/hide state of the background has to be set here since maximized
+ // window doesn't create its own workspace anymore.
+ RootWindowController* root_controller = GetRootWindowController(
+ contents_window_->GetRootWindow());
+ aura::Window* background = root_controller->GetContainer(
+ kShellWindowId_DesktopBackgroundContainer);
+ if (wm::IsWindowMaximized(child)) {
+ ShowOrHideDesktopBackground(
+ background,
+ last_show_state == ui::SHOW_STATE_MINIMIZED ?
+ SWITCH_MAXIMIZED_OR_RESTORED :
+ SWITCH_BACKGROUND_ONLY_WITHIN_DESKTOP,
+ base::TimeDelta(),
+ false);
+ } else if (last_show_state == ui::SHOW_STATE_MAXIMIZED &&
+ GetWindowState() != WORKSPACE_WINDOW_STATE_MAXIMIZED) {
+ ShowOrHideDesktopBackground(
+ background,
+ SWITCH_BACKGROUND_ONLY_WITHIN_DESKTOP,
+ base::TimeDelta(),
+ true);
+ }
+ }
+
if (wm::IsWindowMinimized(child)) {
if (workspace->ShouldMoveToPending())
MoveWorkspaceToPendingOrDelete(workspace, NULL, SWITCH_MINIMIZED);
diff --git a/ash/wm/workspace/workspace_manager.h b/ash/wm/workspace/workspace_manager.h
index 0ae88df..b7ef571 100644
--- a/ash/wm/workspace/workspace_manager.h
+++ b/ash/wm/workspace/workspace_manager.h
@@ -111,6 +111,7 @@ class ASH_EXPORT WorkspaceManager : public ash::ShellObserver {
SWITCH_WINDOW_MADE_ACTIVE,
SWITCH_WINDOW_REMOVED,
SWITCH_VISIBILITY_CHANGED,
+ SWITCH_BACKGROUND_ONLY_WITHIN_DESKTOP,
SWITCH_MINIMIZED,
SWITCH_MAXIMIZED_OR_RESTORED,
// Switch a normal window in a fullscreen workspace to get fullscreen.
diff --git a/ash/wm/workspace/workspace_manager_unittest.cc b/ash/wm/workspace/workspace_manager_unittest.cc
index 9b1a6fa..60e3fdf 100644
--- a/ash/wm/workspace/workspace_manager_unittest.cc
+++ b/ash/wm/workspace/workspace_manager_unittest.cc
@@ -144,6 +144,13 @@ class WorkspaceManagerTest : public test::AshTestBase {
return shelf_layout_manager()->window_overlaps_shelf();
}
+ bool IsBackgroundVisible(aura::Window* window) {
+ RootWindowController* controller = RootWindowController::ForWindow(window);
+ aura::Window* background =
+ controller->GetContainer(kShellWindowId_DesktopBackgroundContainer);
+ return background->IsVisible();
+ }
+
Workspace* FindBy(aura::Window* window) const {
return manager_->FindBy(window);
}
@@ -299,6 +306,46 @@ TEST_F(WorkspaceManagerTest, CloseLastWindowInWorkspace) {
EXPECT_TRUE(w1->IsVisible());
}
+TEST_F(WorkspaceManagerTest, BackgroundWithMaximizedWindow) {
+ scoped_ptr<Window> w1(CreateTestWindow());
+ scoped_ptr<Window> w2(CreateTestWindow());
+ scoped_ptr<Window> w3(CreateTestWindow());
+ w1->SetBounds(gfx::Rect(0, 0, 250, 251));
+ w1->Show();
+ w2->SetBounds(gfx::Rect(0, 0, 250, 251));
+ w2->Show();
+ w3->SetBounds(gfx::Rect(0, 0, 250, 251));
+ w3->Show();
+ wm::ActivateWindow(w1.get());
+ wm::ActivateWindow(w2.get());
+ wm::ActivateWindow(w3.get());
+ EXPECT_TRUE(IsBackgroundVisible(w1.get()));
+
+ w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
+ EXPECT_FALSE(IsBackgroundVisible(w1.get()));
+
+ w3->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
+ EXPECT_FALSE(IsBackgroundVisible(w1.get()));
+
+ w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
+ EXPECT_FALSE(IsBackgroundVisible(w1.get()));
+
+ w3->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
+ EXPECT_TRUE(IsBackgroundVisible(w1.get()));
+
+ w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
+ EXPECT_FALSE(IsBackgroundVisible(w1.get()));
+
+ w3->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
+ EXPECT_FALSE(IsBackgroundVisible(w1.get()));
+
+ w2.reset();
+ EXPECT_FALSE(IsBackgroundVisible(w1.get()));
+
+ w3.reset();
+ EXPECT_TRUE(IsBackgroundVisible(w1.get()));
+}
+
// Assertions around adding a fullscreen window when empty.
TEST_F(WorkspaceManagerTest, AddFullscreenWindowWhenEmpty) {
scoped_ptr<Window> w1(CreateTestWindow());
@@ -996,12 +1043,10 @@ TEST_F(WorkspaceManagerTest, MinimizeResetsVisibility) {
w1->Show();
wm::ActivateWindow(w1.get());
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
- EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, shelf_widget()->GetBackgroundType());
-
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
EXPECT_EQ(SHELF_VISIBLE,
shelf_layout_manager()->visibility_state());
- EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, shelf_widget()->GetBackgroundType());
+ EXPECT_FALSE(shelf_widget()->paints_background());
}
// Verifies transients are moved when fullscreen.