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

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

Issue 1926913002: Moves more code to ash/wm/common (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@refactor_workspace_layout_manager
Patch Set: merge to trunk Created 4 years, 7 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/wm/stacking_controller.cc ('k') | ash/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_WM_WINDOW_POSITIONER_H_
6 #define ASH_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 gfx {
13 class Display;
14 class Rect;
15 }
16
17 namespace display {
18 using Display = gfx::Display;
19 }
20
21 namespace ash {
22 namespace wm {
23 class WmGlobals;
24 class WmWindow;
25 }
26
27 namespace test {
28 class WindowPositionerTest;
29 }
30
31 // WindowPositioner is used by the browser to move new popups automatically to
32 // a usable position on the closest work area (of the active window).
33 class ASH_EXPORT WindowPositioner {
34 public:
35 // When the screen resolution width is smaller then this size, The algorithm
36 // will default to maximized.
37 static int GetForceMaximizedWidthLimit();
38
39 // The number of pixels which are kept free top, left and right when a window
40 // gets positioned to its default location.
41 static const int kDesktopBorderSize;
42
43 // Maximum width of a window even if there is more room on the desktop.
44 static const int kMaximumWindowWidth;
45
46 // Computes and returns the bounds and show state for new window
47 // based on the parameter passed AND existing windows. |window| is
48 // the one this function will generate a bounds for and used to
49 // exclude the self window in making decision how to position the
50 // window. |window| can be (and in most case) NULL.
51 // |is_saved_bounds| indicates the |bounds_in_out| is the saved
52 // bounds.
53 static void GetBoundsAndShowStateForNewWindow(
54 const wm::WmWindow* new_window,
55 bool is_saved_bounds,
56 ui::WindowShowState show_state_in,
57 gfx::Rect* bounds_in_out,
58 ui::WindowShowState* show_state_out);
59
60 // Returns the default bounds for a window to be created in the |display|.
61 static gfx::Rect GetDefaultWindowBounds(const display::Display& display);
62
63 // Check if after removal or hide of the given |removed_window| an
64 // automated desktop location management can be performed and
65 // rearrange accordingly.
66 static void RearrangeVisibleWindowOnHideOrRemove(
67 const wm::WmWindow* removed_window);
68
69 // Turn the automatic positioning logic temporarily off. Returns the previous
70 // state.
71 static bool DisableAutoPositioning(bool ignore);
72
73 // Check if after insertion or showing of the given |added_window|
74 // an automated desktop location management can be performed and
75 // rearrange accordingly.
76 static void RearrangeVisibleWindowOnShow(wm::WmWindow* added_window);
77
78 explicit WindowPositioner(wm::WmGlobals* globals);
79 ~WindowPositioner();
80
81 // 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.
83 // 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
85 // operating systems do (default cascading style).
86 gfx::Rect GetPopupPosition(const gfx::Rect& old_pos);
87
88 // Accessor to set a flag indicating whether the first window in ASH should
89 // be maximized.
90 static void SetMaximizeFirstWindow(bool maximize);
91
92 protected:
93 friend class test::WindowPositionerTest;
94
95 // Find a smart way to position the popup window. If there is no space this
96 // function will return an empty rectangle.
97 gfx::Rect SmartPopupPosition(const gfx::Rect& old_pos,
98 const gfx::Rect& work_area,
99 int grid);
100
101 // Find the next available cascading popup position (on the given screen).
102 gfx::Rect NormalPopupPosition(const gfx::Rect& old_pos,
103 const gfx::Rect& work_area);
104
105 // Align the location to the grid / snap to the right / bottom corner.
106 gfx::Rect AlignPopupPosition(const gfx::Rect &pos,
107 const gfx::Rect &work_area,
108 int grid);
109
110 // Constant exposed for unittest.
111 static const int kMinimumWindowOffset;
112
113 wm::WmGlobals* globals_;
114
115 // The offset in X and Y for the next popup which opens.
116 int pop_position_offset_increment_x;
117 int pop_position_offset_increment_y;
118
119 // The position on the screen for the first popup which gets shown if no
120 // empty space can be found.
121 int popup_position_offset_from_screen_corner_x;
122 int popup_position_offset_from_screen_corner_y;
123
124 // The last used position.
125 int last_popup_position_x_;
126 int last_popup_position_y_;
127
128 DISALLOW_COPY_AND_ASSIGN(WindowPositioner);
129 };
130
131 } // namespace ash
132
133 #endif // ASH_WM_WINDOW_POSITIONER_H_
OLDNEW
« no previous file with comments | « ash/wm/stacking_controller.cc ('k') | ash/wm/window_positioner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698