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 ASH_WM_WINDOW_UTIL_H_ | 5 #ifndef ASH_WM_WINDOW_UTIL_H_ |
6 #define ASH_WM_WINDOW_UTIL_H_ | 6 #define ASH_WM_WINDOW_UTIL_H_ |
7 | 7 |
8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "ui/base/ui_base_types.h" | 10 #include "ui/base/ui_base_types.h" |
11 | 11 |
12 namespace aura { | 12 namespace aura { |
13 class Window; | 13 class Window; |
14 } | 14 } |
15 | 15 |
16 namespace gfx { | 16 namespace gfx { |
17 class Rect; | 17 class Rect; |
18 } | 18 } |
19 | 19 |
20 namespace ui { | 20 namespace ui { |
21 class Event; | 21 class Event; |
22 } | 22 } |
23 | 23 |
24 namespace ash { | 24 namespace ash { |
25 // We force at least this many DIPs for any window on the screen. | 25 // We force at least this many DIPs for any window on the screen. |
26 const int kMinimumOnScreenArea = 10; | 26 const int kMinimumOnScreenArea = 10; |
27 | 27 |
28 namespace wm { | 28 namespace wm { |
29 | 29 |
30 // Convenience setters/getters for |aura::client::kRootWindowActiveWindow|. | 30 // Utility functions for window activation. |
31 ASH_EXPORT void ActivateWindow(aura::Window* window); | 31 ASH_EXPORT void ActivateWindow(aura::Window* window); |
32 ASH_EXPORT void DeactivateWindow(aura::Window* window); | 32 ASH_EXPORT void DeactivateWindow(aura::Window* window); |
33 ASH_EXPORT bool IsActiveWindow(aura::Window* window); | 33 ASH_EXPORT bool IsActiveWindow(aura::Window* window); |
34 ASH_EXPORT aura::Window* GetActiveWindow(); | 34 ASH_EXPORT aura::Window* GetActiveWindow(); |
35 ASH_EXPORT bool CanActivateWindow(aura::Window* window); | 35 ASH_EXPORT bool CanActivateWindow(aura::Window* window); |
36 | 36 |
37 // Retrieves the activatable window for |window|. If |window| is activatable, | 37 // Retrieves the activatable window for |window|. If |window| is activatable, |
38 // this will just return it, otherwise it will climb the parent/transient parent | 38 // this will just return it, otherwise it will climb the parent/transient parent |
39 // chain looking for a window that is activatable, per the ActivationController. | 39 // chain looking for a window that is activatable, per the ActivationController. |
40 // If you're looking for a function to get the activatable "top level" window, | 40 // If you're looking for a function to get the activatable "top level" window, |
41 // this is probably what you're looking for. | 41 // this is probably what you're looking for. |
42 ASH_EXPORT aura::Window* GetActivatableWindow(aura::Window* window); | 42 ASH_EXPORT aura::Window* GetActivatableWindow(aura::Window* window); |
43 | 43 |
44 // Returns true if |window| can be maximized. | 44 // TODO(oshima): remove this. |
45 ASH_EXPORT bool CanMaximizeWindow(const aura::Window* window); | 45 ASH_EXPORT bool IsWindowMinimized(aura::Window* window); |
46 | |
47 // Returns true if |window| can be minimized. | |
48 ASH_EXPORT bool CanMinimizeWindow(const aura::Window* window); | |
49 | |
50 // Returns true if |window| can be resized. | |
51 ASH_EXPORT bool CanResizeWindow(const aura::Window* window); | |
52 | |
53 // Returns true if |window| can be snapped to the left or right. | |
54 ASH_EXPORT bool CanSnapWindow(aura::Window* window); | |
55 | |
56 // Returns true if |window| is normal or default. | |
57 ASH_EXPORT bool IsWindowNormal(const aura::Window* window); | |
58 | |
59 // Returns true if |state| is normal or default. | |
60 ASH_EXPORT bool IsWindowStateNormal(const ui::WindowShowState state); | |
61 | |
62 // Returns true if |window| is in the maximized state. | |
63 ASH_EXPORT bool IsWindowMaximized(const aura::Window* window); | |
64 | |
65 // Returns true if |window| is minimized. | |
66 ASH_EXPORT bool IsWindowMinimized(const aura::Window* window); | |
67 | |
68 // Returns true if |window| is in the fullscreen state. | |
69 ASH_EXPORT bool IsWindowFullscreen(const aura::Window* window); | |
70 | |
71 // Maximizes |window|, which must not be NULL. | |
72 ASH_EXPORT void MaximizeWindow(aura::Window* window); | |
73 | |
74 // Minimizes |window|, which must not be NULL. | |
75 ASH_EXPORT void MinimizeWindow(aura::Window* window); | |
76 | |
77 // Restores |window|, which must not be NULL. | |
78 ASH_EXPORT void RestoreWindow(aura::Window* window); | |
79 | |
80 // Maximizes or restores |window| based on its state. |window| must not be NULL. | |
81 ASH_EXPORT void ToggleMaximizedWindow(aura::Window* window); | |
82 | 46 |
83 // Moves the window to the center of the display. | 47 // Moves the window to the center of the display. |
84 ASH_EXPORT void CenterWindow(aura::Window* window); | 48 ASH_EXPORT void CenterWindow(aura::Window* window); |
85 | 49 |
86 // Change the availability of animation to the fullscreen of the |window|. | 50 // Change the availability of animation to the fullscreen of the |window|. |
87 ASH_EXPORT void SetAnimateToFullscreen(aura::Window* window, bool animate); | 51 ASH_EXPORT void SetAnimateToFullscreen(aura::Window* window, bool animate); |
88 | 52 |
89 // Get |window| bounds of the window before it was moved by the auto window | |
90 // management. As long as it was not managed, it will return NULL. | |
91 ASH_EXPORT const gfx::Rect* GetPreAutoManageWindowBounds( | |
92 const aura::Window* window); | |
93 | |
94 // Remember the |bounds| of a |window| before an automated window management | |
95 // operation takes place. | |
96 ASH_EXPORT void SetPreAutoManageWindowBounds(aura::Window* window, | |
97 const gfx::Rect& bounds); | |
98 | |
99 // Move the given bounds inside the given |visible_area|, including a | 53 // Move the given bounds inside the given |visible_area|, including a |
100 // safety margin given by |kMinimumOnScreenArea|. | 54 // safety margin given by |kMinimumOnScreenArea|. |
101 ASH_EXPORT void AdjustBoundsToEnsureMinimumWindowVisibility( | 55 ASH_EXPORT void AdjustBoundsToEnsureMinimumWindowVisibility( |
102 const gfx::Rect& visible_area, | 56 const gfx::Rect& visible_area, |
103 gfx::Rect* bounds); | 57 gfx::Rect* bounds); |
104 | 58 |
105 // Move the given bounds inside the given |visible_area|, including a | 59 // Move the given bounds inside the given |visible_area|, including a |
106 // safety margin given by |min_width| and |min_height|. | 60 // safety margin given by |min_width| and |min_height|. |
107 ASH_EXPORT void AdjustBoundsToEnsureWindowVisibility( | 61 ASH_EXPORT void AdjustBoundsToEnsureWindowVisibility( |
108 const gfx::Rect& visible_area, | 62 const gfx::Rect& visible_area, |
109 int min_width, | 63 int min_width, |
110 int min_height, | 64 int min_height, |
111 gfx::Rect* bounds); | 65 gfx::Rect* bounds); |
112 | 66 |
113 // Moves |window| to the root window where the |event| occured if it is not | 67 // Moves |window| to the root window where the |event| occured if it is not |
114 // already in the same root window. Returns true if |window| was moved. | 68 // already in the same root window. Returns true if |window| was moved. |
115 ASH_EXPORT bool MoveWindowToEventRoot(aura::Window* window, | 69 ASH_EXPORT bool MoveWindowToEventRoot(aura::Window* window, |
116 const ui::Event& event); | 70 const ui::Event& event); |
117 | 71 |
118 } // namespace wm | 72 } // namespace wm |
119 } // namespace ash | 73 } // namespace ash |
120 | 74 |
121 #endif // ASH_WM_WINDOW_UTIL_H_ | 75 #endif // ASH_WM_WINDOW_UTIL_H_ |
OLD | NEW |