blob: b933282cde31a8215f5203d584f7e906f4099376 (
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
|
// 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/wm/visibility_controller.h"
#include "ash/shell.h"
#include "ash/wm/window_animations.h"
#include "ash/wm/window_properties.h"
#include "ui/aura/window.h"
#include "ui/compositor/layer.h"
namespace ash {
namespace {
bool GetChildWindowVisibilityChangesAnimated(aura::Window* window) {
if (!window)
return false;
return window->GetProperty(
internal::kChildWindowVisibilityChangesAnimatedKey);
}
} // namespace
namespace internal {
VisibilityController::VisibilityController() {
aura::client::SetVisibilityClient(Shell::GetPrimaryRootWindow(), this);
}
VisibilityController::~VisibilityController() {
}
void VisibilityController::UpdateLayerVisibility(aura::Window* window,
bool visible) {
bool animated = GetChildWindowVisibilityChangesAnimated(window->parent()) &&
window->type() != aura::client::WINDOW_TYPE_CONTROL &&
window->type() != aura::client::WINDOW_TYPE_UNKNOWN;
animated = animated && AnimateOnChildWindowVisibilityChanged(window, visible);
if (!visible) {
// For window hiding animation, we want to check if the window is already
// animating, and not do SetVisible(false) if it is.
// TODO(vollick): remove this.
animated = animated || (window->layer()->GetAnimator()->
IsAnimatingProperty(ui::LayerAnimationElement::OPACITY) &&
window->layer()->GetTargetOpacity() == 0.0f);
}
// When a window is made visible, we always make its layer visible
// immediately. When a window is hidden, the layer must be left visible and
// only made not visible once the animation is complete.
if (!animated || visible)
window->layer()->SetVisible(visible);
}
} // namespace internal
void SetChildWindowVisibilityChangesAnimated(aura::Window* window) {
window->SetProperty(internal::kChildWindowVisibilityChangesAnimatedKey, true);
}
} // namespace ash
|