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
3 // found in the LICENSE file.
5 #ifndef ASH_WM_WINDOW_UTIL_H_
6 #define ASH_WM_WINDOW_UTIL_H_
8 #include "ash/ash_export.h"
9 #include "base/compiler_specific.h"
10 #include "ui/base/ui_base_types.h"
27 // We force at least this many DIPs for any window on the screen.
28 const int kMinimumOnScreenArea
= 10;
32 // Convenience setters/getters for |aura::client::kRootWindowActiveWindow|.
33 ASH_EXPORT
void ActivateWindow(aura::Window
* window
);
34 ASH_EXPORT
void DeactivateWindow(aura::Window
* window
);
35 ASH_EXPORT
bool IsActiveWindow(aura::Window
* window
);
36 ASH_EXPORT
aura::Window
* GetActiveWindow();
37 ASH_EXPORT
bool CanActivateWindow(aura::Window
* window
);
39 // Retrieves the activatable window for |window|. If |window| is activatable,
40 // this will just return it, otherwise it will climb the parent/transient parent
41 // chain looking for a window that is activatable, per the ActivationController.
42 // If you're looking for a function to get the activatable "top level" window,
43 // this is probably what you're looking for.
44 ASH_EXPORT
aura::Window
* GetActivatableWindow(aura::Window
* window
);
46 // Returns true if |window| can be maximized.
47 ASH_EXPORT
bool CanMaximizeWindow(const aura::Window
* window
);
49 // Returns true if |window| can be minimized.
50 ASH_EXPORT
bool CanMinimizeWindow(const aura::Window
* window
);
52 // Returns true if |window| can be resized.
53 ASH_EXPORT
bool CanResizeWindow(const aura::Window
* window
);
55 // Returns true if |window| can be snapped to the left or right.
56 ASH_EXPORT
bool CanSnapWindow(aura::Window
* window
);
58 // Returns true if |window| is normal or default.
59 ASH_EXPORT
bool IsWindowNormal(const aura::Window
* window
);
61 // Returns true if |state| is normal or default.
62 ASH_EXPORT
bool IsWindowStateNormal(const ui::WindowShowState state
);
64 // Returns true if |window| is in the maximized state.
65 ASH_EXPORT
bool IsWindowMaximized(const aura::Window
* window
);
67 // Returns true if |window| is minimized.
68 ASH_EXPORT
bool IsWindowMinimized(const aura::Window
* window
);
70 // Returns true if |window| is in the fullscreen state.
71 ASH_EXPORT
bool IsWindowFullscreen(const aura::Window
* window
);
73 // Maximizes |window|, which must not be NULL.
74 ASH_EXPORT
void MaximizeWindow(aura::Window
* window
);
76 // Minimizes |window|, which must not be NULL.
77 ASH_EXPORT
void MinimizeWindow(aura::Window
* window
);
79 // Restores |window|, which must not be NULL.
80 ASH_EXPORT
void RestoreWindow(aura::Window
* window
);
82 // Maximizes or restores |window| based on its state. |window| must not be NULL.
83 ASH_EXPORT
void ToggleMaximizedWindow(aura::Window
* window
);
85 // Moves the window to the center of the display.
86 ASH_EXPORT
void CenterWindow(aura::Window
* window
);
88 // Returns true if |window|'s position can automatically be managed.
89 ASH_EXPORT
bool IsWindowPositionManaged(const aura::Window
* window
);
91 // Change the |window|'s position manageability to |managed|.
92 ASH_EXPORT
void SetWindowPositionManaged(aura::Window
* window
, bool managed
);
94 // Returns true if the user has changed the |window|'s position or size.
95 ASH_EXPORT
bool HasUserChangedWindowPositionOrSize(const aura::Window
* window
);
97 // Marks a |window|'s coordinates to be changed by a user.
98 ASH_EXPORT
void SetUserHasChangedWindowPositionOrSize(aura::Window
* window
,
101 // Get |window| bounds of the window before it was moved by the auto window
102 // management. As long as it was not managed, it will return NULL.
103 ASH_EXPORT
const gfx::Rect
* GetPreAutoManageWindowBounds(
104 const aura::Window
* window
);
106 // Remember the |bounds| of a |window| before an automated window management
107 // operation takes place.
108 ASH_EXPORT
void SetPreAutoManageWindowBounds(aura::Window
* window
,
109 const gfx::Rect
& bounds
);
111 // Move the given bounds inside the given work area, including a safety margin
112 // given by |kMinimumOnScreenArea|.
113 ASH_EXPORT
void AdjustBoundsToEnsureMinimumWindowVisibility(
114 const gfx::Rect
& work_area
,
117 // Move the given bounds inside the given work area, including a safety margin
118 // given by |min_width| and |min_height|.
119 ASH_EXPORT
void AdjustBoundsToEnsureWindowVisibility(
120 const gfx::Rect
& work_area
,
125 // Moves |window| to the root window where the |event| occured if it is not
126 // already in the same root window. Returns true if |window| was moved.
127 ASH_EXPORT
bool MoveWindowToEventRoot(aura::Window
* window
,
128 const ui::Event
& event
);
133 #endif // ASH_WM_WINDOW_UTIL_H_