Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: ash/common/wm/window_positioner.h

Issue 2734653002: chromeos: Move files in //ash/common to //ash (Closed)
Patch Set: fix a11y tests, fix docs Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/common/wm/window_parenting_utils.cc ('k') | ash/common/wm/window_positioner.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef ASH_COMMON_WM_WINDOW_POSITIONER_H_
6 #define ASH_COMMON_WM_WINDOW_POSITIONER_H_
7
8 #include "ash/ash_export.h"
9 #include "base/macros.h"
10 #include "ui/base/ui_base_types.h"
11
12 namespace display {
13 class Display;
14 }
15
16 namespace gfx {
17 class Rect;
18 }
19
20 namespace ash {
21
22 class WmShell;
23 class WmWindow;
24
25 namespace test {
26 class WindowPositionerTest;
27 }
28
29 // WindowPositioner is used by the browser to move new popups automatically to
30 // a usable position on the closest work area (of the active window).
31 class ASH_EXPORT WindowPositioner {
32 public:
33 // When the screen resolution width is smaller then this size, The algorithm
34 // will default to maximized.
35 static int GetForceMaximizedWidthLimit();
36
37 // The number of pixels which are kept free top, left and right when a window
38 // gets positioned to its default location.
39 static const int kDesktopBorderSize;
40
41 // Maximum width of a window even if there is more room on the desktop.
42 static const int kMaximumWindowWidth;
43
44 // Computes and returns the bounds and show state for new window
45 // based on the parameter passed AND existing windows. |window| is
46 // the one this function will generate a bounds for and used to
47 // exclude the self window in making decision how to position the
48 // window. |window| can be (and in most case) NULL.
49 // |is_saved_bounds| indicates the |bounds_in_out| is the saved
50 // bounds.
51 static void GetBoundsAndShowStateForNewWindow(
52 const WmWindow* new_window,
53 bool is_saved_bounds,
54 ui::WindowShowState show_state_in,
55 gfx::Rect* bounds_in_out,
56 ui::WindowShowState* show_state_out);
57
58 // Returns the default bounds for a window to be created in the |display|.
59 static gfx::Rect GetDefaultWindowBounds(const display::Display& display);
60
61 // Check if after removal or hide of the given |removed_window| an
62 // automated desktop location management can be performed and
63 // rearrange accordingly.
64 static void RearrangeVisibleWindowOnHideOrRemove(
65 const WmWindow* removed_window);
66
67 // Turn the automatic positioning logic temporarily off. Returns the previous
68 // state.
69 static bool DisableAutoPositioning(bool ignore);
70
71 // Check if after insertion or showing of the given |added_window|
72 // an automated desktop location management can be performed and
73 // rearrange accordingly.
74 static void RearrangeVisibleWindowOnShow(WmWindow* added_window);
75
76 explicit WindowPositioner(WmShell* shell);
77 ~WindowPositioner();
78
79 // Find a suitable screen position for a popup window and return it. The
80 // passed input position is only used to retrieve the width and height.
81 // The position is determined on the left / right / top / bottom first. If
82 // no smart space is found, the position will follow the standard what other
83 // operating systems do (default cascading style).
84 gfx::Rect GetPopupPosition(const gfx::Rect& old_pos);
85
86 // Accessor to set a flag indicating whether the first window in ASH should
87 // be maximized.
88 static void SetMaximizeFirstWindow(bool maximize);
89
90 protected:
91 friend class test::WindowPositionerTest;
92
93 // Find a smart way to position the popup window. If there is no space this
94 // function will return an empty rectangle.
95 gfx::Rect SmartPopupPosition(const gfx::Rect& old_pos,
96 const gfx::Rect& work_area,
97 int grid);
98
99 // Find the next available cascading popup position (on the given screen).
100 gfx::Rect NormalPopupPosition(const gfx::Rect& old_pos,
101 const gfx::Rect& work_area);
102
103 // Align the location to the grid / snap to the right / bottom corner.
104 gfx::Rect AlignPopupPosition(const gfx::Rect& pos,
105 const gfx::Rect& work_area,
106 int grid);
107
108 // Constant exposed for unittest.
109 static const int kMinimumWindowOffset;
110
111 WmShell* shell_;
112
113 // The offset in X and Y for the next popup which opens.
114 int pop_position_offset_increment_x;
115 int pop_position_offset_increment_y;
116
117 // The position on the screen for the first popup which gets shown if no
118 // empty space can be found.
119 int popup_position_offset_from_screen_corner_x;
120 int popup_position_offset_from_screen_corner_y;
121
122 // The last used position.
123 int last_popup_position_x_;
124 int last_popup_position_y_;
125
126 DISALLOW_COPY_AND_ASSIGN(WindowPositioner);
127 };
128
129 } // namespace ash
130
131 #endif // ASH_COMMON_WM_WINDOW_POSITIONER_H_
OLDNEW
« no previous file with comments | « ash/common/wm/window_parenting_utils.cc ('k') | ash/common/wm/window_positioner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698