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

Side by Side Diff: ash/wm/window_resizer.cc

Issue 1608053002: Remove now-unnecessary wrappers around gfx::Screen::GetScreen() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@metro-mode-5
Patch Set: cros Created 4 years, 11 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/window_positioner_unittest.cc ('k') | ash/wm/window_state_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ash/wm/window_resizer.h" 5 #include "ash/wm/window_resizer.h"
6 6
7 #include "ash/screen_util.h" 7 #include "ash/screen_util.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/shell_window_ids.h" 9 #include "ash/shell_window_ids.h"
10 #include "ash/wm/coordinate_conversion.h" 10 #include "ash/wm/coordinate_conversion.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 // position. For example, dragging the left edge to the right should stop 130 // position. For example, dragging the left edge to the right should stop
131 // repositioning the window when the minimize size is reached. 131 // repositioning the window when the minimize size is reached.
132 gfx::Size size = GetSizeForDrag(&delta_x, &delta_y); 132 gfx::Size size = GetSizeForDrag(&delta_x, &delta_y);
133 gfx::Point origin = GetOriginForDrag(delta_x, delta_y); 133 gfx::Point origin = GetOriginForDrag(delta_x, delta_y);
134 gfx::Rect new_bounds(origin, size); 134 gfx::Rect new_bounds(origin, size);
135 135
136 // Sizing has to keep the result on the screen. Note that this correction 136 // Sizing has to keep the result on the screen. Note that this correction
137 // has to come first since it might have an impact on the origin as well as 137 // has to come first since it might have an impact on the origin as well as
138 // on the size. 138 // on the size.
139 if (details().bounds_change & kBoundsChange_Resizes) { 139 if (details().bounds_change & kBoundsChange_Resizes) {
140 gfx::Rect work_area = 140 gfx::Rect work_area = gfx::Screen::GetScreen()
141 Shell::GetScreen()->GetDisplayNearestWindow(GetTarget()).work_area(); 141 ->GetDisplayNearestWindow(GetTarget())
142 .work_area();
142 aura::Window* dock_container = Shell::GetContainer( 143 aura::Window* dock_container = Shell::GetContainer(
143 GetTarget()->GetRootWindow(), kShellWindowId_DockedContainer); 144 GetTarget()->GetRootWindow(), kShellWindowId_DockedContainer);
144 DockedWindowLayoutManager* dock_layout = 145 DockedWindowLayoutManager* dock_layout =
145 static_cast<DockedWindowLayoutManager*>( 146 static_cast<DockedWindowLayoutManager*>(
146 dock_container->layout_manager()); 147 dock_container->layout_manager());
147 148
148 work_area.Union(dock_layout->docked_bounds()); 149 work_area.Union(dock_layout->docked_bounds());
149 work_area = ScreenUtil::ConvertRectFromScreen(GetTarget()->parent(), 150 work_area = ScreenUtil::ConvertRectFromScreen(GetTarget()->parent(),
150 work_area); 151 work_area);
151 if (details().size_change_direction & kBoundsChangeDirection_Horizontal) { 152 if (details().size_change_direction & kBoundsChangeDirection_Horizontal) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 // Make sure that |new_bounds| doesn't leave any of the displays. Note that 201 // Make sure that |new_bounds| doesn't leave any of the displays. Note that
201 // the |work_area| above isn't good for this check since it is the work area 202 // the |work_area| above isn't good for this check since it is the work area
202 // for the current display but the window can move to a different one. 203 // for the current display but the window can move to a different one.
203 aura::Window* parent = GetTarget()->parent(); 204 aura::Window* parent = GetTarget()->parent();
204 gfx::Point passed_location_in_screen(passed_location); 205 gfx::Point passed_location_in_screen(passed_location);
205 ::wm::ConvertPointToScreen(parent, &passed_location_in_screen); 206 ::wm::ConvertPointToScreen(parent, &passed_location_in_screen);
206 gfx::Rect near_passed_location(passed_location_in_screen, gfx::Size()); 207 gfx::Rect near_passed_location(passed_location_in_screen, gfx::Size());
207 // Use a pointer location (matching the logic in DragWindowResizer) to 208 // Use a pointer location (matching the logic in DragWindowResizer) to
208 // calculate the target display after the drag. 209 // calculate the target display after the drag.
209 const gfx::Display& display = 210 const gfx::Display& display =
210 Shell::GetScreen()->GetDisplayMatching(near_passed_location); 211 gfx::Screen::GetScreen()->GetDisplayMatching(near_passed_location);
211 aura::Window* dock_container = 212 aura::Window* dock_container =
212 Shell::GetContainer(wm::GetRootWindowMatching(near_passed_location), 213 Shell::GetContainer(wm::GetRootWindowMatching(near_passed_location),
213 kShellWindowId_DockedContainer); 214 kShellWindowId_DockedContainer);
214 DockedWindowLayoutManager* dock_layout = 215 DockedWindowLayoutManager* dock_layout =
215 static_cast<DockedWindowLayoutManager*>( 216 static_cast<DockedWindowLayoutManager*>(
216 dock_container->layout_manager()); 217 dock_container->layout_manager());
217 218
218 gfx::Rect screen_work_area = display.work_area(); 219 gfx::Rect screen_work_area = display.work_area();
219 screen_work_area.Union(dock_layout->docked_bounds()); 220 screen_work_area.Union(dock_layout->docked_bounds());
220 screen_work_area.Inset(kMinimumOnScreenArea, 0); 221 screen_work_area.Inset(kMinimumOnScreenArea, 0);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 302
302 // Ensure we don't shrink past the minimum width and clamp delta_x 303 // Ensure we don't shrink past the minimum width and clamp delta_x
303 // for the window origin computation. 304 // for the window origin computation.
304 if (width < min_width) { 305 if (width < min_width) {
305 width = min_width; 306 width = min_width;
306 *delta_x = -x_multiplier * (details().initial_bounds_in_parent.width() - 307 *delta_x = -x_multiplier * (details().initial_bounds_in_parent.width() -
307 min_width); 308 min_width);
308 } 309 }
309 310
310 // And don't let the window go bigger than the display. 311 // And don't let the window go bigger than the display.
311 int max_width = Shell::GetScreen()->GetDisplayNearestWindow( 312 int max_width = gfx::Screen::GetScreen()
312 GetTarget()).bounds().width(); 313 ->GetDisplayNearestWindow(GetTarget())
314 .bounds()
315 .width();
313 gfx::Size max_size = GetTarget()->delegate()->GetMaximumSize(); 316 gfx::Size max_size = GetTarget()->delegate()->GetMaximumSize();
314 if (max_size.width() != 0) 317 if (max_size.width() != 0)
315 max_width = std::min(max_width, max_size.width()); 318 max_width = std::min(max_width, max_size.width());
316 if (width > max_width) { 319 if (width > max_width) {
317 width = max_width; 320 width = max_width;
318 *delta_x = -x_multiplier * (details().initial_bounds_in_parent.width() - 321 *delta_x = -x_multiplier * (details().initial_bounds_in_parent.width() -
319 max_width); 322 max_width);
320 } 323 }
321 } 324 }
322 return width; 325 return width;
323 } 326 }
324 327
325 int WindowResizer::GetHeightForDrag(int min_height, int* delta_y) { 328 int WindowResizer::GetHeightForDrag(int min_height, int* delta_y) {
326 int height = details().initial_bounds_in_parent.height(); 329 int height = details().initial_bounds_in_parent.height();
327 if (details().size_change_direction & kBoundsChangeDirection_Vertical) { 330 if (details().size_change_direction & kBoundsChangeDirection_Vertical) {
328 // Along the bottom edge, positive delta_y increases the window size. 331 // Along the bottom edge, positive delta_y increases the window size.
329 int y_multiplier = IsBottomEdge(details().window_component) ? 1 : -1; 332 int y_multiplier = IsBottomEdge(details().window_component) ? 1 : -1;
330 height += y_multiplier * (*delta_y); 333 height += y_multiplier * (*delta_y);
331 334
332 // Ensure we don't shrink past the minimum height and clamp delta_y 335 // Ensure we don't shrink past the minimum height and clamp delta_y
333 // for the window origin computation. 336 // for the window origin computation.
334 if (height < min_height) { 337 if (height < min_height) {
335 height = min_height; 338 height = min_height;
336 *delta_y = -y_multiplier * (details().initial_bounds_in_parent.height() - 339 *delta_y = -y_multiplier * (details().initial_bounds_in_parent.height() -
337 min_height); 340 min_height);
338 } 341 }
339 342
340 // And don't let the window go bigger than the display. 343 // And don't let the window go bigger than the display.
341 int max_height = Shell::GetScreen()->GetDisplayNearestWindow( 344 int max_height = gfx::Screen::GetScreen()
342 GetTarget()).bounds().height(); 345 ->GetDisplayNearestWindow(GetTarget())
346 .bounds()
347 .height();
343 gfx::Size max_size = GetTarget()->delegate()->GetMaximumSize(); 348 gfx::Size max_size = GetTarget()->delegate()->GetMaximumSize();
344 if (max_size.height() != 0) 349 if (max_size.height() != 0)
345 max_height = std::min(max_height, max_size.height()); 350 max_height = std::min(max_height, max_size.height());
346 if (height > max_height) { 351 if (height > max_height) {
347 height = max_height; 352 height = max_height;
348 *delta_y = -y_multiplier * (details().initial_bounds_in_parent.height() - 353 *delta_y = -y_multiplier * (details().initial_bounds_in_parent.height() -
349 max_height); 354 max_height);
350 } 355 }
351 } 356 }
352 return height; 357 return height;
353 } 358 }
354 359
355 } // namespace ash 360 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/window_positioner_unittest.cc ('k') | ash/wm/window_state_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698