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

Side by Side Diff: chrome/browser/ui/window_sizer/window_sizer_ash.cc

Issue 11072002: Combined window positioning and show state determiniation in the WindowSizer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 8 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 #include "chrome/browser/ui/window_sizer/window_sizer.h" 5 #include "chrome/browser/ui/window_sizer/window_sizer.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/wm/window_cycle_controller.h" 8 #include "ash/wm/window_cycle_controller.h"
9 #include "ash/wm/window_util.h" 9 #include "ash/wm/window_util.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 bounds_in_screen.set_x(work_area.x()); 113 bounds_in_screen.set_x(work_area.x());
114 return true; 114 return true;
115 } 115 }
116 } 116 }
117 return false; 117 return false;
118 } 118 }
119 119
120 } // namespace 120 } // namespace
121 121
122 bool WindowSizer::GetBoundsOverrideAsh(const gfx::Rect& specified_bounds, 122 bool WindowSizer::GetBoundsOverrideAsh(const gfx::Rect& specified_bounds,
123 gfx::Rect* bounds_in_screen) const { 123 gfx::Rect* bounds_in_screen,
124 ui::WindowShowState* show_state) const {
125 DCHECK(show_state);
126 DCHECK(bounds_in_screen);
124 *bounds_in_screen = specified_bounds; 127 *bounds_in_screen = specified_bounds;
125 DCHECK(bounds_in_screen->IsEmpty()); 128 DCHECK(bounds_in_screen->IsEmpty());
126 129
127 if (!GetSavedWindowBounds(bounds_in_screen)) 130 ui::WindowShowState passed_show_state = *show_state;
131 if (!GetSavedWindowBounds(bounds_in_screen, show_state))
128 GetDefaultWindowBounds(bounds_in_screen); 132 GetDefaultWindowBounds(bounds_in_screen);
129 133
130 if (browser_ && browser_->is_type_tabbed()) { 134 if (browser_ && browser_->is_type_tabbed()) {
131 gfx::Rect work_area = 135 gfx::Rect work_area =
132 monitor_info_provider_->GetMonitorWorkAreaMatching(*bounds_in_screen); 136 monitor_info_provider_->GetMonitorWorkAreaMatching(*bounds_in_screen);
133 // This is a window / app. See if there is no window and try to place it. 137 // This is a window / app. See if there is no window and try to place it.
134 int count = GetNumberOfValidTopLevelBrowserWindows(work_area); 138 int count = GetNumberOfValidTopLevelBrowserWindows(work_area);
135 aura::Window* top_window = GetTopWindow(work_area); 139 aura::Window* top_window = GetTopWindow(work_area);
140 // The window should not be able to reflect on itself.
141 if (browser_->window() &&
142 top_window == browser_->window()->GetNativeWindow())
143 return true;
144 // If there is no valid other window we take the coordinates as is.
145 if (!count || !top_window)
146 return true;
136 147
137 // If there is no valid other window we take the coordinates as is. 148 bool maximized = ash::wm::IsWindowMaximized(top_window);
138 if (!count || !top_window || ash::wm::IsWindowMaximized(top_window)) 149 // We ignore the saved show state, but look instead for the top level
150 // window's show state.
151 if (passed_show_state == ui::SHOW_STATE_DEFAULT) {
152 *show_state = maximized ? ui::SHOW_STATE_MAXIMIZED :
153 ui::SHOW_STATE_DEFAULT;
154 }
155
156 if (maximized)
139 return true; 157 return true;
140 158
141 gfx::Rect other_bounds_in_screen = top_window->GetBoundsInScreen(); 159 gfx::Rect other_bounds_in_screen = top_window->GetBoundsInScreen();
142 bool move_right = 160 bool move_right =
143 other_bounds_in_screen.CenterPoint().x() < work_area.CenterPoint().x(); 161 other_bounds_in_screen.CenterPoint().x() < work_area.CenterPoint().x();
144 162
145 // In case we have only one window, we move the other window fully to the 163 // In case we have only one window, we move the other window fully to the
146 // "other side" - making room for this new window. 164 // "other side" - making room for this new window.
147 if (count == 1) { 165 if (count == 1) {
148 gfx::Display display = 166 gfx::Display display =
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 if (default_width > kMaximumWindowWidth) { 203 if (default_width > kMaximumWindowWidth) {
186 // The window should get centered on the screen and not follow the grid. 204 // The window should get centered on the screen and not follow the grid.
187 offset_x = (work_area.width() - kMaximumWindowWidth) / 2; 205 offset_x = (work_area.width() - kMaximumWindowWidth) / 2;
188 default_width = kMaximumWindowWidth; 206 default_width = kMaximumWindowWidth;
189 } 207 }
190 default_bounds->SetRect(work_area.x() + offset_x, 208 default_bounds->SetRect(work_area.x() + offset_x,
191 work_area.y() + kDesktopBorderSize, 209 work_area.y() + kDesktopBorderSize,
192 default_width, 210 default_width,
193 default_height); 211 default_height);
194 } 212 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/window_sizer/window_sizer.cc ('k') | chrome/browser/ui/window_sizer/window_sizer_ash_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698