| 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 #include "ui/gfx/geometry/rect.h" | |
| 12 | |
| 13 namespace aura { | |
| 14 class Window; | |
| 15 class RootWindow; | |
| 16 } | |
| 17 | 11 |
| 18 namespace gfx { | 12 namespace gfx { |
| 19 class Display; | 13 class Display; |
| 20 class Rect; | 14 class Rect; |
| 21 class Screen; | |
| 22 } | 15 } |
| 23 | 16 |
| 24 namespace ash { | 17 namespace ash { |
| 18 namespace wm { |
| 19 class WmGlobals; |
| 20 class WmWindow; |
| 21 } |
| 25 | 22 |
| 26 namespace test { | 23 namespace test { |
| 27 class WindowPositionerTest; | 24 class WindowPositionerTest; |
| 28 } | 25 } |
| 29 | 26 |
| 30 // WindowPositioner is used by the browser to move new popups automatically to | 27 // WindowPositioner is used by the browser to move new popups automatically to |
| 31 // a usable position on the closest work area (of the active window). | 28 // a usable position on the closest work area (of the active window). |
| 32 class ASH_EXPORT WindowPositioner { | 29 class ASH_EXPORT WindowPositioner { |
| 33 public: | 30 public: |
| 34 // When the screen resolution width is smaller then this size, The algorithm | 31 // When the screen resolution width is smaller then this size, The algorithm |
| 35 // will default to maximized. | 32 // will default to maximized. |
| 36 static int GetForceMaximizedWidthLimit(); | 33 static int GetForceMaximizedWidthLimit(); |
| 37 | 34 |
| 38 // The number of pixels which are kept free top, left and right when a window | 35 // The number of pixels which are kept free top, left and right when a window |
| 39 // gets positioned to its default location. | 36 // gets positioned to its default location. |
| 40 static const int kDesktopBorderSize; | 37 static const int kDesktopBorderSize; |
| 41 | 38 |
| 42 // Maximum width of a window even if there is more room on the desktop. | 39 // Maximum width of a window even if there is more room on the desktop. |
| 43 static const int kMaximumWindowWidth; | 40 static const int kMaximumWindowWidth; |
| 44 | 41 |
| 45 // Computes and returns the bounds and show state for new window | 42 // Computes and returns the bounds and show state for new window |
| 46 // based on the parameter passed AND existing windows. |window| is | 43 // based on the parameter passed AND existing windows. |window| is |
| 47 // the one this function will generate a bounds for and used to | 44 // the one this function will generate a bounds for and used to |
| 48 // exclude the self window in making decision how to position the | 45 // exclude the self window in making decision how to position the |
| 49 // window. |window| can be (and in most case) NULL. | 46 // window. |window| can be (and in most case) NULL. |
| 50 // |is_saved_bounds| indicates the |bounds_in_out| is the saved | 47 // |is_saved_bounds| indicates the |bounds_in_out| is the saved |
| 51 // bounds. | 48 // bounds. |
| 52 static void GetBoundsAndShowStateForNewWindow( | 49 static void GetBoundsAndShowStateForNewWindow( |
| 53 const gfx::Screen* screen, | 50 const wm::WmWindow* new_window, |
| 54 const aura::Window* new_window, | |
| 55 bool is_saved_bounds, | 51 bool is_saved_bounds, |
| 56 ui::WindowShowState show_state_in, | 52 ui::WindowShowState show_state_in, |
| 57 gfx::Rect* bounds_in_out, | 53 gfx::Rect* bounds_in_out, |
| 58 ui::WindowShowState* show_state_out); | 54 ui::WindowShowState* show_state_out); |
| 59 | 55 |
| 60 // Returns the default bounds for a window to be created in the |display|. | 56 // Returns the default bounds for a window to be created in the |display|. |
| 61 static gfx::Rect GetDefaultWindowBounds(const gfx::Display& display); | 57 static gfx::Rect GetDefaultWindowBounds(const gfx::Display& display); |
| 62 | 58 |
| 63 // Check if after removal or hide of the given |removed_window| an | 59 // Check if after removal or hide of the given |removed_window| an |
| 64 // automated desktop location management can be performed and | 60 // automated desktop location management can be performed and |
| 65 // rearrange accordingly. | 61 // rearrange accordingly. |
| 66 static void RearrangeVisibleWindowOnHideOrRemove( | 62 static void RearrangeVisibleWindowOnHideOrRemove( |
| 67 const aura::Window* removed_window); | 63 const wm::WmWindow* removed_window); |
| 68 | 64 |
| 69 // Turn the automatic positioning logic temporarily off. Returns the previous | 65 // Turn the automatic positioning logic temporarily off. Returns the previous |
| 70 // state. | 66 // state. |
| 71 static bool DisableAutoPositioning(bool ignore); | 67 static bool DisableAutoPositioning(bool ignore); |
| 72 | 68 |
| 73 // Check if after insertion or showing of the given |added_window| | 69 // Check if after insertion or showing of the given |added_window| |
| 74 // an automated desktop location management can be performed and | 70 // an automated desktop location management can be performed and |
| 75 // rearrange accordingly. | 71 // rearrange accordingly. |
| 76 static void RearrangeVisibleWindowOnShow(aura::Window* added_window); | 72 static void RearrangeVisibleWindowOnShow(wm::WmWindow* added_window); |
| 77 | 73 |
| 78 WindowPositioner(); | 74 explicit WindowPositioner(wm::WmGlobals* globals); |
| 79 ~WindowPositioner(); | 75 ~WindowPositioner(); |
| 80 | 76 |
| 81 // Find a suitable screen position for a popup window and return it. The | 77 // Find a suitable screen position for a popup window and return it. The |
| 82 // passed input position is only used to retrieve the width and height. | 78 // passed input position is only used to retrieve the width and height. |
| 83 // The position is determined on the left / right / top / bottom first. If | 79 // The position is determined on the left / right / top / bottom first. If |
| 84 // no smart space is found, the position will follow the standard what other | 80 // no smart space is found, the position will follow the standard what other |
| 85 // operating systems do (default cascading style). | 81 // operating systems do (default cascading style). |
| 86 gfx::Rect GetPopupPosition(const gfx::Rect& old_pos); | 82 gfx::Rect GetPopupPosition(const gfx::Rect& old_pos); |
| 87 | 83 |
| 88 // Accessor to set a flag indicating whether the first window in ASH should | 84 // Accessor to set a flag indicating whether the first window in ASH should |
| (...skipping 14 matching lines...) Expand all Loading... |
| 103 const gfx::Rect& work_area); | 99 const gfx::Rect& work_area); |
| 104 | 100 |
| 105 // Align the location to the grid / snap to the right / bottom corner. | 101 // Align the location to the grid / snap to the right / bottom corner. |
| 106 gfx::Rect AlignPopupPosition(const gfx::Rect &pos, | 102 gfx::Rect AlignPopupPosition(const gfx::Rect &pos, |
| 107 const gfx::Rect &work_area, | 103 const gfx::Rect &work_area, |
| 108 int grid); | 104 int grid); |
| 109 | 105 |
| 110 // Constant exposed for unittest. | 106 // Constant exposed for unittest. |
| 111 static const int kMinimumWindowOffset; | 107 static const int kMinimumWindowOffset; |
| 112 | 108 |
| 109 wm::WmGlobals* globals_; |
| 110 |
| 113 // The offset in X and Y for the next popup which opens. | 111 // The offset in X and Y for the next popup which opens. |
| 114 int pop_position_offset_increment_x; | 112 int pop_position_offset_increment_x; |
| 115 int pop_position_offset_increment_y; | 113 int pop_position_offset_increment_y; |
| 116 | 114 |
| 117 // The position on the screen for the first popup which gets shown if no | 115 // The position on the screen for the first popup which gets shown if no |
| 118 // empty space can be found. | 116 // empty space can be found. |
| 119 int popup_position_offset_from_screen_corner_x; | 117 int popup_position_offset_from_screen_corner_x; |
| 120 int popup_position_offset_from_screen_corner_y; | 118 int popup_position_offset_from_screen_corner_y; |
| 121 | 119 |
| 122 // The last used position. | 120 // The last used position. |
| 123 int last_popup_position_x_; | 121 int last_popup_position_x_; |
| 124 int last_popup_position_y_; | 122 int last_popup_position_y_; |
| 125 | 123 |
| 126 DISALLOW_COPY_AND_ASSIGN(WindowPositioner); | 124 DISALLOW_COPY_AND_ASSIGN(WindowPositioner); |
| 127 }; | 125 }; |
| 128 | 126 |
| 129 } // namespace ash | 127 } // namespace ash |
| 130 | 128 |
| 131 #endif // ASH_WM_WINDOW_POSITIONER_H_ | 129 #endif // ASH_WM_WINDOW_POSITIONER_H_ |
| OLD | NEW |