summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-09 23:12:58 +0000
committerderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-09 23:12:58 +0000
commit1ebf155ac702fa6cea00525550427db5b665e1f5 (patch)
tree56d8b4936b6ec7f68be0e7511458818a7c3fbf6a /ash
parent04fd69f01aad1dc4a8349006a0bb6d1b02084f09 (diff)
downloadchromium_src-1ebf155ac702fa6cea00525550427db5b665e1f5.zip
chromium_src-1ebf155ac702fa6cea00525550427db5b665e1f5.tar.gz
chromium_src-1ebf155ac702fa6cea00525550427db5b665e1f5.tar.bz2
aura: Display black background in compact window mode.
This adds an always-visible black background when ash is using the compact window mode, to prevent the compositor's blue clear color from being visible when logging in, in the middle of animations, etc. BUG=chromium:10801 TEST=manual: logged in, switched windows, locked the screen, logged out, and shut down without seeing the blue background Review URL: http://codereview.chromium.org/9371004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121328 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/shell.cc11
-rw-r--r--ash/shell_unittest.cc7
-rw-r--r--ash/wm/compact_layout_manager.cc6
-rw-r--r--ash/wm/compact_layout_manager.h4
-rw-r--r--ash/wm/power_button_controller.h3
-rw-r--r--ash/wm/root_window_layout_manager.cc6
-rw-r--r--ash/wm/root_window_layout_manager.h11
7 files changed, 40 insertions, 8 deletions
diff --git a/ash/shell.cc b/ash/shell.cc
index a1ab080..89ee3c4 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -522,7 +522,15 @@ void Shell::SetupCompactWindowMode() {
// Maximize all the windows, using the new layout manager.
MaximizeWindows(default_container);
- // Eliminate the background widget.
+ // Set a solid black background.
+ // TODO(derat): Remove this in favor of having the compositor only clear the
+ // viewport when there are regions not covered by a layer:
+ // http://crbug.com/113445
+ ui::Layer* background_layer = new ui::Layer(ui::Layer::LAYER_SOLID_COLOR);
+ background_layer->SetColor(SK_ColorBLACK);
+ GetContainer(internal::kShellWindowId_DesktopBackgroundContainer)->
+ layer()->Add(background_layer);
+ root_window_layout_->SetBackgroundLayer(background_layer);
root_window_layout_->SetBackgroundWidget(NULL);
}
@@ -570,6 +578,7 @@ void Shell::SetupNonCompactWindowMode() {
// Create the desktop background image.
root_window_layout_->SetBackgroundWidget(internal::CreateDesktopBackground());
+ root_window_layout_->SetBackgroundLayer(NULL);
}
void Shell::ResetLayoutManager(int container_id) {
diff --git a/ash/shell_unittest.cc b/ash/shell_unittest.cc
index 69c09cf..9961491 100644
--- a/ash/shell_unittest.cc
+++ b/ash/shell_unittest.cc
@@ -355,8 +355,9 @@ TEST_F(ShellTest, MAYBE_ChangeWindowMode) {
EXPECT_EQ(0, launcher_widget->GetWindowScreenBounds().x());
EXPECT_EQ(RootWindow::GetInstance()->GetHostSize().height(),
launcher_widget->GetWindowScreenBounds().bottom());
- // We have a desktop background.
+ // We have a desktop background but not a bare layer.
EXPECT_TRUE(shell->root_window_layout_->background_widget());
+ EXPECT_FALSE(shell->root_window_layout_->background_layer());
// Create a normal window. It is not maximized.
views::Widget::InitParams widget_params(
@@ -381,8 +382,9 @@ TEST_F(ShellTest, MAYBE_ChangeWindowMode) {
widget->GetWindowScreenBounds());
// Launcher is hidden.
EXPECT_FALSE(launcher_widget->IsVisible());
- // Desktop background is gone.
+ // Desktop background widget is gone but we have a layer.
EXPECT_FALSE(shell->root_window_layout_->background_widget());
+ EXPECT_TRUE(shell->root_window_layout_->background_layer());
// Switch back to overlapping mode.
shell->ChangeWindowMode(Shell::MODE_OVERLAPPING);
@@ -397,6 +399,7 @@ TEST_F(ShellTest, MAYBE_ChangeWindowMode) {
launcher_widget->GetWindowScreenBounds().bottom());
// Desktop background is back.
EXPECT_TRUE(shell->root_window_layout_->background_widget());
+ EXPECT_FALSE(shell->root_window_layout_->background_layer());
// Clean up.
widget->Close();
diff --git a/ash/wm/compact_layout_manager.cc b/ash/wm/compact_layout_manager.cc
index f9e3c87..eacfbcd 100644
--- a/ash/wm/compact_layout_manager.cc
+++ b/ash/wm/compact_layout_manager.cc
@@ -13,6 +13,7 @@
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/window.h"
#include "ui/gfx/compositor/scoped_layer_animation_settings.h"
+#include "ui/gfx/compositor/layer.h"
#include "ui/gfx/compositor/layer_animation_sequence.h"
#include "ui/gfx/screen.h"
#include "ui/views/widget/widget.h"
@@ -76,9 +77,8 @@ void CompactLayoutManager::OnWindowAddedToLayout(aura::Window* child) {
void CompactLayoutManager::OnWillRemoveWindowFromLayout(aura::Window* child) {
BaseLayoutManager::OnWillRemoveWindowFromLayout(child);
UpdateStatusAreaVisibility();
- if (windows().size() > 1 && ShouldAnimateOnEntrance(child)) {
+ if (windows().size() > 1 && ShouldAnimateOnEntrance(child))
AdjustContainerLayerWidth(-child->bounds().width());
- }
if (child == current_window_) {
LayoutWindows(current_window_);
@@ -119,7 +119,7 @@ void CompactLayoutManager::SetChildBounds(aura::Window* child,
}
/////////////////////////////////////////////////////////////////////////////
-// CompactLayoutManager, WindowObserver overrides:
+// CompactLayoutManager, aura::WindowObserver overrides:
void CompactLayoutManager::OnWindowPropertyChanged(aura::Window* window,
const char* name,
diff --git a/ash/wm/compact_layout_manager.h b/ash/wm/compact_layout_manager.h
index 62f3f0d..42c33e6 100644
--- a/ash/wm/compact_layout_manager.h
+++ b/ash/wm/compact_layout_manager.h
@@ -42,13 +42,13 @@ class ASH_EXPORT CompactLayoutManager : public BaseLayoutManager,
virtual void SetChildBounds(aura::Window* child,
const gfx::Rect& requested_bounds) OVERRIDE;
- // WindowObserver overrides:
+ // aura::WindowObserver overrides:
virtual void OnWindowPropertyChanged(aura::Window* window,
const char* name,
void* old) OVERRIDE;
virtual void OnWindowStackingChanged(aura::Window* window) OVERRIDE;
- // ui::OnImplicitAnimationsCompleted:
+ // ui::LayerAnimationObserver overrides:
virtual void OnImplicitAnimationsCompleted() OVERRIDE;
private:
diff --git a/ash/wm/power_button_controller.h b/ash/wm/power_button_controller.h
index 4ecd4f0..9b069b5 100644
--- a/ash/wm/power_button_controller.h
+++ b/ash/wm/power_button_controller.h
@@ -202,6 +202,9 @@ class ASH_EXPORT PowerButtonController : public aura::RootWindowObserver {
// Layer that's stacked under all of the root window's children to provide a
// black background when we're scaling all of the other windows down.
+ // TODO(derat): Remove this in favor of having the compositor only clear the
+ // viewport when there are regions not covered by a layer:
+ // http://crbug.com/113445
scoped_ptr<ui::Layer> background_layer_;
// Started when the user first presses the power button while in a
diff --git a/ash/wm/root_window_layout_manager.cc b/ash/wm/root_window_layout_manager.cc
index 56013f6..f320ab8 100644
--- a/ash/wm/root_window_layout_manager.cc
+++ b/ash/wm/root_window_layout_manager.cc
@@ -31,6 +31,10 @@ void RootWindowLayoutManager::SetBackgroundWidget(views::Widget* widget) {
background_widget_ = widget;
}
+void RootWindowLayoutManager::SetBackgroundLayer(ui::Layer* layer) {
+ background_layer_.reset(layer);
+}
+
////////////////////////////////////////////////////////////////////////////////
// RootWindowLayoutManager, aura::LayoutManager implementation:
@@ -48,6 +52,8 @@ void RootWindowLayoutManager::OnWindowResized() {
if (background_widget_)
background_widget_->SetBounds(fullscreen_bounds);
+ if (background_layer_.get())
+ background_layer_->SetBounds(fullscreen_bounds);
}
void RootWindowLayoutManager::OnWindowAddedToLayout(aura::Window* child) {
diff --git a/ash/wm/root_window_layout_manager.h b/ash/wm/root_window_layout_manager.h
index d5f4a0c..e39f476 100644
--- a/ash/wm/root_window_layout_manager.h
+++ b/ash/wm/root_window_layout_manager.h
@@ -8,6 +8,7 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
#include "ui/aura/layout_manager.h"
namespace aura {
@@ -16,6 +17,9 @@ class Window;
namespace gfx {
class Rect;
}
+namespace ui {
+class Layer;
+}
namespace views {
class Widget;
}
@@ -31,11 +35,17 @@ class RootWindowLayoutManager : public aura::LayoutManager {
virtual ~RootWindowLayoutManager();
views::Widget* background_widget() { return background_widget_; }
+ ui::Layer* background_layer() { return background_layer_.get(); }
// Sets the background to |widget|. Closes and destroys the old widget if it
// exists and differs from the new widget.
void SetBackgroundWidget(views::Widget* widget);
+ // Sets a background layer, taking ownership of |layer|. This is provided as
+ // a lightweight alternative to SetBackgroundWidget(); layers can be simple
+ // colored quads instead of being textured.
+ void SetBackgroundLayer(ui::Layer* layer);
+
// Overridden from aura::LayoutManager:
virtual void OnWindowResized() OVERRIDE;
virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE;
@@ -50,6 +60,7 @@ class RootWindowLayoutManager : public aura::LayoutManager {
// May be NULL if we're not painting a background.
views::Widget* background_widget_;
+ scoped_ptr<ui::Layer> background_layer_;
DISALLOW_COPY_AND_ASSIGN(RootWindowLayoutManager);
};