blob: 6e6d799cb154400d6be68f0911d2d81a9936088b (
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
|
// 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.
#include "ash/desktop_background/desktop_background_widget_controller.h"
#include "ui/aura/root_window.h"
#include "ui/views/widget/widget.h"
DECLARE_WINDOW_PROPERTY_TYPE(ash::internal::DesktopBackgroundWidgetController*);
namespace ash {
namespace internal {
DEFINE_OWNED_WINDOW_PROPERTY_KEY(DesktopBackgroundWidgetController,
kWindowDesktopComponent, NULL);
DesktopBackgroundWidgetController::DesktopBackgroundWidgetController(
views::Widget* widget) : widget_(widget) {
}
DesktopBackgroundWidgetController::DesktopBackgroundWidgetController(
ui::Layer* layer) : widget_(NULL) {
layer_.reset(layer);
}
DesktopBackgroundWidgetController::~DesktopBackgroundWidgetController() {
if (widget_) {
widget_->CloseNow();
widget_ = NULL;
} else if (layer_.get())
layer_.reset(NULL);
}
void DesktopBackgroundWidgetController::SetBounds(gfx::Rect bounds) {
if (widget_)
widget_->SetBounds(bounds);
else if (layer_.get())
layer_->SetBounds(bounds);
}
void DesktopBackgroundWidgetController::Reparent(aura::RootWindow* root_window,
int src_container,
int dest_container) {
if (widget_) {
views::Widget::ReparentNativeView(widget_->GetNativeView(),
root_window->GetChildById(dest_container));
} else if (layer_.get()) {
ui::Layer* layer = layer_.get();
root_window->GetChildById(src_container)->layer()->Remove(layer);
root_window->GetChildById(dest_container)->layer()->Add(layer);
}
}
} // namespace internal
} // namespace ash
|