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

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

Issue 161293003: Add test case for updating the bounds of snapped window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 "ash/wm/window_util.h" 5 #include "ash/wm/window_util.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/ash_constants.h" 9 #include "ash/ash_constants.h"
10 #include "ash/screen_util.h" 10 #include "ash/screen_util.h"
11 #include "ash/shell.h" 11 #include "ash/shell.h"
12 #include "ash/wm/window_properties.h" 12 #include "ash/wm/window_properties.h"
13 #include "ash/wm/window_state.h" 13 #include "ash/wm/window_state.h"
14 #include "ui/aura/client/activation_client.h" 14 #include "ui/aura/client/activation_client.h"
15 #include "ui/aura/client/aura_constants.h" 15 #include "ui/aura/client/aura_constants.h"
16 #include "ui/aura/root_window.h" 16 #include "ui/aura/root_window.h"
17 #include "ui/aura/window.h" 17 #include "ui/aura/window.h"
18 #include "ui/gfx/display.h" 18 #include "ui/gfx/display.h"
19 #include "ui/gfx/rect.h" 19 #include "ui/gfx/rect.h"
pkotwicz 2014/02/13 02:26:16 Nit: include ui/gfx/geometry/size.h here
20 #include "ui/gfx/screen.h" 20 #include "ui/gfx/screen.h"
21 #include "ui/views/corewm/window_util.h" 21 #include "ui/views/corewm/window_util.h"
22 #include "ui/views/view.h" 22 #include "ui/views/view.h"
23 #include "ui/views/widget/widget.h" 23 #include "ui/views/widget/widget.h"
24 24
25 namespace ash { 25 namespace ash {
26 namespace wm { 26 namespace wm {
27 27
28 // TODO(beng): replace many of these functions with the corewm versions. 28 // TODO(beng): replace many of these functions with the corewm versions.
29 void ActivateWindow(aura::Window* window) { 29 void ActivateWindow(aura::Window* window) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 window_state->SetRestoreBoundsInScreen(center); 70 window_state->SetRestoreBoundsInScreen(center);
71 window_state->Restore(); 71 window_state->Restore();
72 } else { 72 } else {
73 center = ScreenUtil::ConvertRectFromScreen(window->parent(), 73 center = ScreenUtil::ConvertRectFromScreen(window->parent(),
74 center); 74 center);
75 center.ClampToCenteredSize(size); 75 center.ClampToCenteredSize(size);
76 window->SetBounds(center); 76 window->SetBounds(center);
77 } 77 }
78 } 78 }
79 79
80 // Adjust bounds so that the size does not exceeds |max_size|.
pkotwicz 2014/02/13 02:26:16 Nit: You have a comment in the .h file. It is unne
81 void AdjustBoundsSmallerThan(const gfx::Size& max_size, gfx::Rect* bounds) {
82 bounds->set_width(std::min(bounds->width(), max_size.width()));
83 bounds->set_height(std::min(bounds->height(), max_size.height()));
84 }
85
80 void AdjustBoundsToEnsureMinimumWindowVisibility(const gfx::Rect& visible_area, 86 void AdjustBoundsToEnsureMinimumWindowVisibility(const gfx::Rect& visible_area,
81 gfx::Rect* bounds) { 87 gfx::Rect* bounds) {
82 AdjustBoundsToEnsureWindowVisibility( 88 AdjustBoundsToEnsureWindowVisibility(
83 visible_area, kMinimumOnScreenArea, kMinimumOnScreenArea, bounds); 89 visible_area, kMinimumOnScreenArea, kMinimumOnScreenArea, bounds);
84 } 90 }
85 91
86 void AdjustBoundsToEnsureWindowVisibility(const gfx::Rect& visible_area, 92 void AdjustBoundsToEnsureWindowVisibility(const gfx::Rect& visible_area,
87 int min_width, 93 int min_width,
88 int min_height, 94 int min_height,
89 gfx::Rect* bounds) { 95 gfx::Rect* bounds) {
90 bounds->set_width(std::min(bounds->width(), visible_area.width())); 96 AdjustBoundsSmallerThan(visible_area.size(), bounds);
91 bounds->set_height(std::min(bounds->height(), visible_area.height()));
92 97
93 min_width = std::min(min_width, visible_area.width()); 98 min_width = std::min(min_width, visible_area.width());
94 min_height = std::min(min_height, visible_area.height()); 99 min_height = std::min(min_height, visible_area.height());
95 100
96 if (bounds->right() < visible_area.x() + min_width) { 101 if (bounds->right() < visible_area.x() + min_width) {
97 bounds->set_x(visible_area.x() + min_width - bounds->width()); 102 bounds->set_x(visible_area.x() + min_width - bounds->width());
98 } else if (bounds->x() > visible_area.right() - min_width) { 103 } else if (bounds->x() > visible_area.right() - min_width) {
99 bounds->set_x(visible_area.right() - min_width); 104 bounds->set_x(visible_area.right() - min_width);
100 } 105 }
101 if (bounds->bottom() < visible_area.y() + min_height) { 106 if (bounds->bottom() < visible_area.y() + min_height) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 ++i) { 143 ++i) {
139 ReparentChildWithTransientChildren( 144 ReparentChildWithTransientChildren(
140 views::corewm::GetTransientChildren(child)[i], 145 views::corewm::GetTransientChildren(child)[i],
141 old_parent, 146 old_parent,
142 new_parent); 147 new_parent);
143 } 148 }
144 } 149 }
145 150
146 } // namespace wm 151 } // namespace wm
147 } // namespace ash 152 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698