1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "ash/wm/system_background_controller.h" 6 7 #include "ui/aura/window.h" 8 #include "ui/compositor/layer.h" 9 #include "ui/compositor/layer_type.h" 10 11 namespace ash { 12 namespace internal { 13 SystemBackgroundController(aura::Window * root_window,SkColor color)14SystemBackgroundController::SystemBackgroundController( 15 aura::Window* root_window, 16 SkColor color) 17 : root_window_(root_window), 18 layer_(new ui::Layer(ui::LAYER_SOLID_COLOR)) { 19 root_window_->AddObserver(this); 20 layer_->SetColor(color); 21 22 ui::Layer* root_layer = root_window_->layer(); 23 layer_->SetBounds(gfx::Rect(root_layer->bounds().size())); 24 root_layer->Add(layer_.get()); 25 root_layer->StackAtBottom(layer_.get()); 26 } 27 ~SystemBackgroundController()28SystemBackgroundController::~SystemBackgroundController() { 29 root_window_->RemoveObserver(this); 30 } 31 SetColor(SkColor color)32void SystemBackgroundController::SetColor(SkColor color) { 33 layer_->SetColor(color); 34 } 35 OnWindowBoundsChanged(aura::Window * root,const gfx::Rect & old_bounds,const gfx::Rect & new_bounds)36void SystemBackgroundController::OnWindowBoundsChanged( 37 aura::Window* root, 38 const gfx::Rect& old_bounds, 39 const gfx::Rect& new_bounds) { 40 DCHECK_EQ(root_window_, root); 41 layer_->SetBounds(gfx::Rect(root_window_->layer()->bounds().size())); 42 } 43 44 } // namespace internal 45 } // namespace ash 46