window_util.h revision 58537e28ecd584eab876aee8be7156509866d23a
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. 4 5#ifndef ASH_WM_WINDOW_UTIL_H_ 6#define ASH_WM_WINDOW_UTIL_H_ 7 8#include "ash/ash_export.h" 9#include "base/compiler_specific.h" 10#include "ui/base/ui_base_types.h" 11 12namespace aura { 13class Window; 14} 15 16namespace gfx { 17class Rect; 18} 19 20namespace ui { 21class Event; 22} 23 24namespace ash { 25// We force at least this many DIPs for any window on the screen. 26const int kMinimumOnScreenArea = 10; 27 28namespace wm { 29 30// Convenience setters/getters for |aura::client::kRootWindowActiveWindow|. 31ASH_EXPORT void ActivateWindow(aura::Window* window); 32ASH_EXPORT void DeactivateWindow(aura::Window* window); 33ASH_EXPORT bool IsActiveWindow(aura::Window* window); 34ASH_EXPORT aura::Window* GetActiveWindow(); 35ASH_EXPORT bool CanActivateWindow(aura::Window* window); 36 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 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, 41// this is probably what you're looking for. 42ASH_EXPORT aura::Window* GetActivatableWindow(aura::Window* window); 43 44// Returns true if |window| can be maximized. 45ASH_EXPORT bool CanMaximizeWindow(const aura::Window* window); 46 47// Returns true if |window| can be minimized. 48ASH_EXPORT bool CanMinimizeWindow(const aura::Window* window); 49 50// Returns true if |window| can be resized. 51ASH_EXPORT bool CanResizeWindow(const aura::Window* window); 52 53// Returns true if |window| can be snapped to the left or right. 54ASH_EXPORT bool CanSnapWindow(aura::Window* window); 55 56// Returns true if |window| is normal or default. 57ASH_EXPORT bool IsWindowNormal(const aura::Window* window); 58 59// Returns true if |state| is normal or default. 60ASH_EXPORT bool IsWindowStateNormal(const ui::WindowShowState state); 61 62// Returns true if |window| is in the maximized state. 63ASH_EXPORT bool IsWindowMaximized(const aura::Window* window); 64 65// Returns true if |window| is minimized. 66ASH_EXPORT bool IsWindowMinimized(const aura::Window* window); 67 68// Returns true if |window| is in the fullscreen state. 69ASH_EXPORT bool IsWindowFullscreen(const aura::Window* window); 70 71// Maximizes |window|, which must not be NULL. 72ASH_EXPORT void MaximizeWindow(aura::Window* window); 73 74// Minimizes |window|, which must not be NULL. 75ASH_EXPORT void MinimizeWindow(aura::Window* window); 76 77// Restores |window|, which must not be NULL. 78ASH_EXPORT void RestoreWindow(aura::Window* window); 79 80// Maximizes or restores |window| based on its state. |window| must not be NULL. 81ASH_EXPORT void ToggleMaximizedWindow(aura::Window* window); 82 83// Moves the window to the center of the display. 84ASH_EXPORT void CenterWindow(aura::Window* window); 85 86// Change the availability of animation to the fullscreen of the |window|. 87ASH_EXPORT void SetAnimateToFullscreen(aura::Window* window, bool animate); 88 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. 91ASH_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. 96ASH_EXPORT void SetPreAutoManageWindowBounds(aura::Window* window, 97 const gfx::Rect& bounds); 98 99// Move the given bounds inside the given |visible_area|, including a 100// safety margin given by |kMinimumOnScreenArea|. 101ASH_EXPORT void AdjustBoundsToEnsureMinimumWindowVisibility( 102 const gfx::Rect& visible_area, 103 gfx::Rect* bounds); 104 105// Move the given bounds inside the given |visible_area|, including a 106// safety margin given by |min_width| and |min_height|. 107ASH_EXPORT void AdjustBoundsToEnsureWindowVisibility( 108 const gfx::Rect& visible_area, 109 int min_width, 110 int min_height, 111 gfx::Rect* bounds); 112 113// 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. 115ASH_EXPORT bool MoveWindowToEventRoot(aura::Window* window, 116 const ui::Event& event); 117 118} // namespace wm 119} // namespace ash 120 121#endif // ASH_WM_WINDOW_UTIL_H_ 122