OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_POSITIONER_H_ | 5 #ifndef ASH_WM_WINDOW_POSITIONER_H_ |
6 #define ASH_WM_WINDOW_POSITIONER_H_ | 6 #define ASH_WM_WINDOW_POSITIONER_H_ |
7 | 7 |
8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "ui/base/ui_base_types.h" | 10 #include "ui/base/ui_base_types.h" |
11 | 11 |
| 12 namespace aura { |
| 13 class Window; |
| 14 } |
| 15 |
12 namespace display { | 16 namespace display { |
13 class Display; | 17 class Display; |
14 } | 18 } |
15 | 19 |
16 namespace gfx { | 20 namespace gfx { |
17 class Rect; | 21 class Rect; |
18 } | 22 } |
19 | 23 |
20 namespace ash { | 24 namespace ash { |
21 | 25 |
22 class WmWindow; | |
23 | |
24 namespace test { | 26 namespace test { |
25 class WindowPositionerTest; | 27 class WindowPositionerTest; |
26 } | 28 } |
27 | 29 |
28 // WindowPositioner is used by the browser to move new popups automatically to | 30 // WindowPositioner is used by the browser to move new popups automatically to |
29 // a usable position on the closest work area (of the active window). | 31 // a usable position on the closest work area (of the active window). |
30 class ASH_EXPORT WindowPositioner { | 32 class ASH_EXPORT WindowPositioner { |
31 public: | 33 public: |
32 // When the screen resolution width is smaller then this size, The algorithm | 34 // When the screen resolution width is smaller then this size, The algorithm |
33 // will default to maximized. | 35 // will default to maximized. |
34 static int GetForceMaximizedWidthLimit(); | 36 static int GetForceMaximizedWidthLimit(); |
35 | 37 |
36 // The number of pixels which are kept free top, left and right when a window | 38 // The number of pixels which are kept free top, left and right when a window |
37 // gets positioned to its default location. | 39 // gets positioned to its default location. |
38 static const int kDesktopBorderSize; | 40 static const int kDesktopBorderSize; |
39 | 41 |
40 // Maximum width of a window even if there is more room on the desktop. | 42 // Maximum width of a window even if there is more room on the desktop. |
41 static const int kMaximumWindowWidth; | 43 static const int kMaximumWindowWidth; |
42 | 44 |
43 // Computes and returns the bounds and show state for new window | 45 // Computes and returns the bounds and show state for new window |
44 // based on the parameter passed AND existing windows. |window| is | 46 // based on the parameter passed AND existing windows. |window| is |
45 // the one this function will generate a bounds for and used to | 47 // the one this function will generate a bounds for and used to |
46 // exclude the self window in making decision how to position the | 48 // exclude the self window in making decision how to position the |
47 // window. |window| can be (and in most case) NULL. | 49 // window. |window| can be (and in most case) NULL. |
48 // |is_saved_bounds| indicates the |bounds_in_out| is the saved | 50 // |is_saved_bounds| indicates the |bounds_in_out| is the saved |
49 // bounds. | 51 // bounds. |
50 static void GetBoundsAndShowStateForNewWindow( | 52 static void GetBoundsAndShowStateForNewWindow( |
51 const WmWindow* new_window, | 53 const aura::Window* new_window, |
52 bool is_saved_bounds, | 54 bool is_saved_bounds, |
53 ui::WindowShowState show_state_in, | 55 ui::WindowShowState show_state_in, |
54 gfx::Rect* bounds_in_out, | 56 gfx::Rect* bounds_in_out, |
55 ui::WindowShowState* show_state_out); | 57 ui::WindowShowState* show_state_out); |
56 | 58 |
57 // Returns the default bounds for a window to be created in the |display|. | 59 // Returns the default bounds for a window to be created in the |display|. |
58 static gfx::Rect GetDefaultWindowBounds(const display::Display& display); | 60 static gfx::Rect GetDefaultWindowBounds(const display::Display& display); |
59 | 61 |
60 // Check if after removal or hide of the given |removed_window| an | 62 // Check if after removal or hide of the given |removed_window| an |
61 // automated desktop location management can be performed and | 63 // automated desktop location management can be performed and |
62 // rearrange accordingly. | 64 // rearrange accordingly. |
63 static void RearrangeVisibleWindowOnHideOrRemove( | 65 static void RearrangeVisibleWindowOnHideOrRemove( |
64 const WmWindow* removed_window); | 66 const aura::Window* removed_window); |
65 | 67 |
66 // Turn the automatic positioning logic temporarily off. Returns the previous | 68 // Turn the automatic positioning logic temporarily off. Returns the previous |
67 // state. | 69 // state. |
68 static bool DisableAutoPositioning(bool ignore); | 70 static bool DisableAutoPositioning(bool ignore); |
69 | 71 |
70 // Check if after insertion or showing of the given |added_window| | 72 // Check if after insertion or showing of the given |added_window| |
71 // an automated desktop location management can be performed and | 73 // an automated desktop location management can be performed and |
72 // rearrange accordingly. | 74 // rearrange accordingly. |
73 static void RearrangeVisibleWindowOnShow(WmWindow* added_window); | 75 static void RearrangeVisibleWindowOnShow(aura::Window* added_window); |
74 | 76 |
75 WindowPositioner(); | 77 WindowPositioner(); |
76 ~WindowPositioner(); | 78 ~WindowPositioner(); |
77 | 79 |
78 // Find a suitable screen position for a popup window and return it. The | 80 // Find a suitable screen position for a popup window and return it. The |
79 // passed input position is only used to retrieve the width and height. | 81 // passed input position is only used to retrieve the width and height. |
80 // The position is determined on the left / right / top / bottom first. If | 82 // The position is determined on the left / right / top / bottom first. If |
81 // no smart space is found, the position will follow the standard what other | 83 // no smart space is found, the position will follow the standard what other |
82 // operating systems do (default cascading style). | 84 // operating systems do (default cascading style). |
83 gfx::Rect GetPopupPosition(const gfx::Rect& old_pos); | 85 gfx::Rect GetPopupPosition(const gfx::Rect& old_pos); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 // The last used position. | 121 // The last used position. |
120 int last_popup_position_x_; | 122 int last_popup_position_x_; |
121 int last_popup_position_y_; | 123 int last_popup_position_y_; |
122 | 124 |
123 DISALLOW_COPY_AND_ASSIGN(WindowPositioner); | 125 DISALLOW_COPY_AND_ASSIGN(WindowPositioner); |
124 }; | 126 }; |
125 | 127 |
126 } // namespace ash | 128 } // namespace ash |
127 | 129 |
128 #endif // ASH_WM_WINDOW_POSITIONER_H_ | 130 #endif // ASH_WM_WINDOW_POSITIONER_H_ |
OLD | NEW |