blob: d5653328bf04206e1cbdb671c9796603b5f5bf16 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
// 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_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_WIDGET_CONTROLLER_H_
#define ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_WIDGET_CONTROLLER_H_
#include "base/memory/scoped_ptr.h"
#include "ui/aura/window_property.h"
#include "ui/compositor/layer.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_observer.h"
namespace ash {
namespace internal {
// This class hides difference between two possible background implementations:
// effective Layer-based for solid color, and Widget-based for images.
// DesktopBackgroundWidgetController is installed as an owned property on the
// RootWindow. To avoid a white flash during wallpaper changes the old
// DesktopBackgroundWidgetController is moved to a secondary property
// (kComponentWrapper). When the animation completes the old
// DesktopBackgroundWidgetController is destroyed.
class DesktopBackgroundWidgetController : public views::WidgetObserver {
public:
// Create
explicit DesktopBackgroundWidgetController(views::Widget* widget);
explicit DesktopBackgroundWidgetController(ui::Layer* layer);
virtual ~DesktopBackgroundWidgetController();
// Overridden from views::WidgetObserver.
virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE;
// Set bounds of component that draws background.
void SetBounds(gfx::Rect bounds);
// Move component from |src_container| in |root_window| to |dest_container|.
// It is required for lock screen, when we need to move background so that
// it hides user's windows.
void Reparent(aura::RootWindow* root_window,
int src_container,
int dest_container);
views::Widget* widget() { return widget_; }
ui::Layer* layer() { return layer_.get(); }
private:
views::Widget* widget_;
scoped_ptr<ui::Layer> layer_;
DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundWidgetController);
};
// This class wraps a DesktopBackgroundWidgetController pointer. It is installed
// as an owned property on the RootWindow. DesktopBackgroundWidgetController is
// moved to this property before animation completes. After animation completes,
// the kWindowDesktopComponent property on RootWindow is set to the
// DesktopBackgroundWidgetController in this class.
class ComponentWrapper {
public:
explicit ComponentWrapper(
DesktopBackgroundWidgetController* component);
~ComponentWrapper();
// Gets the wrapped DesktopBackgroundWidgetController pointer. Caller should
// take ownership of the pointer if |pass_ownership| is true.
DesktopBackgroundWidgetController* GetComponent(bool pass_ownership);
private:
scoped_ptr<DesktopBackgroundWidgetController> component_;
DISALLOW_COPY_AND_ASSIGN(ComponentWrapper);
};
// Window property key, that binds instance of DesktopBackgroundWidgetController
// to root windows.
extern const aura::WindowProperty<DesktopBackgroundWidgetController*>* const
kWindowDesktopComponent;
extern const aura::WindowProperty<ComponentWrapper*>* const kComponentWrapper;
} // namespace internal
} // namespace ash
#endif // ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_WIDGET_CONTROLLER_H_
|