Fix translation extraction failure.
[chromium-blink-merge.git] / ash / wm / window_util.h
blobe1240ae22d46d160ba8dc48dd012e555d38890ed
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"
12 namespace aura {
13 class Window;
16 namespace gfx {
17 class Point;
18 class Rect;
19 class Size;
22 namespace ui {
23 class Event;
26 namespace ash {
27 // We force at least this many DIPs for any window on the screen.
28 const int kMinimumOnScreenArea = 25;
30 namespace wm {
32 // Utility functions for window activation.
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 // TODO(oshima): remove this.
47 ASH_EXPORT bool IsWindowMinimized(aura::Window* window);
49 // Returns true if |window|'s location can be controlled by the user.
50 ASH_EXPORT bool IsWindowUserPositionable(aura::Window* window);
52 // Moves the window to the center of the display.
53 ASH_EXPORT void CenterWindow(aura::Window* window);
55 // Returns the bounds of a left snapped window with default width in parent
56 // coordinates.
57 ASH_EXPORT gfx::Rect GetDefaultLeftSnappedWindowBoundsInParent(
58 aura::Window* window);
60 // Returns the bounds of a right snapped window with default width in parent
61 // coordinates.
62 ASH_EXPORT gfx::Rect GetDefaultRightSnappedWindowBoundsInParent(
63 aura::Window* window);
65 // Adjusts |bounds| so that the size does not exceed |max_size|.
66 ASH_EXPORT void AdjustBoundsSmallerThan(const gfx::Size& max_size,
67 gfx::Rect* bounds);
69 // Move the given bounds inside the given |visible_area| in parent coordinates,
70 // including a safety margin given by |kMinimumOnScreenArea|.
71 // This also ensures that the top of the bounds is visible.
72 ASH_EXPORT void AdjustBoundsToEnsureMinimumWindowVisibility(
73 const gfx::Rect& visible_area,
74 gfx::Rect* bounds);
76 // Move the given bounds inside the given |visible_area| in parent coordinates,
77 // including a safety margin given by |min_width| and |min_height|.
78 // This also ensures that the top of the bounds is visible.
79 ASH_EXPORT void AdjustBoundsToEnsureWindowVisibility(
80 const gfx::Rect& visible_area,
81 int min_width,
82 int min_height,
83 gfx::Rect* bounds);
85 // Moves |window| to the root window where the |event| occured if it is not
86 // already in the same root window. Returns true if |window| was moved.
87 ASH_EXPORT bool MoveWindowToEventRoot(aura::Window* window,
88 const ui::Event& event);
90 // Changes the parent of a |child| and all its transient children that are
91 // themselves children of |old_parent| to |new_parent|.
92 void ReparentChildWithTransientChildren(aura::Window* child,
93 aura::Window* old_parent,
94 aura::Window* new_parent);
96 // Changes the parent of all transient children of a |child| to |new_parent|.
97 // Does not change parent of the transient children that are not themselves
98 // children of |old_parent|.
99 void ReparentTransientChildrenOfChild(aura::Window* child,
100 aura::Window* old_parent,
101 aura::Window* new_parent);
103 // Snap the window's layer to physical pixel boundary.
104 void SnapWindowToPixelBoundary(aura::Window* window);
106 // Mark the container window so that InstallSnapLayoutManagerToContainers
107 // installs the SnapToPixelLayoutManager.
108 ASH_EXPORT void SetSnapsChildrenToPhysicalPixelBoundary(
109 aura::Window* container);
111 // Traverse the |container| tree and installs SnapToPixelLayoutManager.
112 void InstallSnapLayoutManagerToContainers(aura::Window* container);
114 } // namespace wm
115 } // namespace ash
117 #endif // ASH_WM_WINDOW_UTIL_H_