OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_WM_CORE_WINDOW_UTIL_H_ | 5 #ifndef UI_WM_CORE_WINDOW_UTIL_H_ |
6 #define UI_WM_CORE_WINDOW_UTIL_H_ | 6 #define UI_WM_CORE_WINDOW_UTIL_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "ui/wm/wm_export.h" | 12 #include "ui/wm/wm_export.h" |
13 | 13 |
14 namespace aura { | 14 namespace aura { |
15 class Window; | 15 class Window; |
16 } | 16 } |
17 | 17 |
18 namespace ui { | 18 namespace ui { |
19 class Layer; | 19 class Layer; |
20 class LayerDelegate; | |
21 class LayerOwner; | 20 class LayerOwner; |
22 class LayerTreeOwner; | 21 class LayerTreeOwner; |
23 } | 22 } |
24 | 23 |
25 namespace wm { | 24 namespace wm { |
26 | 25 |
27 WM_EXPORT void ActivateWindow(aura::Window* window); | 26 WM_EXPORT void ActivateWindow(aura::Window* window); |
28 WM_EXPORT void DeactivateWindow(aura::Window* window); | 27 WM_EXPORT void DeactivateWindow(aura::Window* window); |
29 WM_EXPORT bool IsActiveWindow(aura::Window* window); | 28 WM_EXPORT bool IsActiveWindow(aura::Window* window); |
30 WM_EXPORT bool CanActivateWindow(aura::Window* window); | 29 WM_EXPORT bool CanActivateWindow(aura::Window* window); |
31 | 30 |
32 // Retrieves the activatable window for |window|. The ActivationClient makes | 31 // Retrieves the activatable window for |window|. The ActivationClient makes |
33 // this determination. | 32 // this determination. |
34 WM_EXPORT aura::Window* GetActivatableWindow(aura::Window* window); | 33 WM_EXPORT aura::Window* GetActivatableWindow(aura::Window* window); |
35 | 34 |
36 // Retrieves the toplevel window for |window|. The ActivationClient makes this | 35 // Retrieves the toplevel window for |window|. The ActivationClient makes this |
37 // determination. | 36 // determination. |
38 WM_EXPORT aura::Window* GetToplevelWindow(aura::Window* window); | 37 WM_EXPORT aura::Window* GetToplevelWindow(aura::Window* window); |
39 | 38 |
40 // A factory method to create a delegate for recreated layers. | |
41 class WM_EXPORT LayerDelegateFactory { | |
42 public: | |
43 virtual ~LayerDelegateFactory() = default; | |
44 // |original_layer| may already be deleted by the time the new | |
45 // delegate is created, so if the new delegate has to access it | |
46 // later, it is the new delegate's responsibility to make sure the | |
47 // original layer/delegate is alive. | |
48 virtual ui::LayerDelegate* CreateDelegate(ui::Layer* new_layer, | |
49 ui::Layer* original_layer) = 0; | |
50 }; | |
51 | |
52 // Returns the existing Layer for |root| (and all its descendants) and creates | 39 // Returns the existing Layer for |root| (and all its descendants) and creates |
53 // a new layer for |root| and all its descendants. This is intended for | 40 // a new layer for |root| and all its descendants. This is intended for |
54 // animations that want to animate between the existing visuals and a new state. | 41 // animations that want to animate between the existing visuals and a new state. |
55 // | 42 // |
56 // As a result of this |root| has freshly created layers, meaning the layers | 43 // As a result of this |root| has freshly created layers, meaning the layers |
57 // have not yet been painted to. | 44 // have not yet been painted to. |
58 // | |
59 // When a non null |delegate_factory| is passed, it will be used to | |
60 // create a delegate for an old layer which had its own delegate. | |
61 WM_EXPORT std::unique_ptr<ui::LayerTreeOwner> RecreateLayers( | 45 WM_EXPORT std::unique_ptr<ui::LayerTreeOwner> RecreateLayers( |
62 ui::LayerOwner* root, | 46 ui::LayerOwner* root); |
63 LayerDelegateFactory* delegate_factory); | 47 |
| 48 // Returns a layer tree that mirrors |root|. Used for live window previews. If |
| 49 // |sync_bounds| is true, the bounds of all mirror layers except the root are |
| 50 // synchronized. See |sync_bounds_| in ui::Layer. |
| 51 WM_EXPORT std::unique_ptr<ui::LayerTreeOwner> MirrorLayers( |
| 52 ui::LayerOwner* root, bool sync_bounds); |
64 | 53 |
65 // Convenience functions that get the TransientWindowManager for the window and | 54 // Convenience functions that get the TransientWindowManager for the window and |
66 // redirect appropriately. These are preferable to calling functions on | 55 // redirect appropriately. These are preferable to calling functions on |
67 // TransientWindowManager as they handle the appropriate NULL checks. | 56 // TransientWindowManager as they handle the appropriate NULL checks. |
68 WM_EXPORT aura::Window* GetTransientParent(aura::Window* window); | 57 WM_EXPORT aura::Window* GetTransientParent(aura::Window* window); |
69 WM_EXPORT const aura::Window* GetTransientParent( | 58 WM_EXPORT const aura::Window* GetTransientParent( |
70 const aura::Window* window); | 59 const aura::Window* window); |
71 WM_EXPORT const std::vector<aura::Window*>& GetTransientChildren( | 60 WM_EXPORT const std::vector<aura::Window*>& GetTransientChildren( |
72 const aura::Window* window); | 61 const aura::Window* window); |
73 WM_EXPORT void AddTransientChild(aura::Window* parent, aura::Window* child); | 62 WM_EXPORT void AddTransientChild(aura::Window* parent, aura::Window* child); |
74 WM_EXPORT void RemoveTransientChild(aura::Window* parent, aura::Window* child); | 63 WM_EXPORT void RemoveTransientChild(aura::Window* parent, aura::Window* child); |
75 | 64 |
76 // Returns true if |window| has |ancestor| as a transient ancestor. A transient | 65 // Returns true if |window| has |ancestor| as a transient ancestor. A transient |
77 // ancestor is found by following the transient parent chain of the window. | 66 // ancestor is found by following the transient parent chain of the window. |
78 WM_EXPORT bool HasTransientAncestor(const aura::Window* window, | 67 WM_EXPORT bool HasTransientAncestor(const aura::Window* window, |
79 const aura::Window* ancestor); | 68 const aura::Window* ancestor); |
80 | 69 |
81 } // namespace wm | 70 } // namespace wm |
82 | 71 |
83 #endif // UI_WM_CORE_WINDOW_UTIL_H_ | 72 #endif // UI_WM_CORE_WINDOW_UTIL_H_ |
OLD | NEW |