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

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

Issue 106303005: Fix AdjustBoundsToEnsureWindowVisibility to work with non primary display bounds (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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_ash.h" 10 #include "ash/screen_ash.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 void AdjustBoundsToEnsureWindowVisibility(const gfx::Rect& visible_area, 87 void AdjustBoundsToEnsureWindowVisibility(const gfx::Rect& visible_area,
88 int min_width, 88 int min_width,
89 int min_height, 89 int min_height,
90 gfx::Rect* bounds) { 90 gfx::Rect* bounds) {
91 bounds->set_width(std::min(bounds->width(), visible_area.width())); 91 bounds->set_width(std::min(bounds->width(), visible_area.width()));
92 bounds->set_height(std::min(bounds->height(), visible_area.height())); 92 bounds->set_height(std::min(bounds->height(), visible_area.height()));
93 93
94 min_width = std::min(min_width, visible_area.width()); 94 min_width = std::min(min_width, visible_area.width());
95 min_height = std::min(min_height, visible_area.height()); 95 min_height = std::min(min_height, visible_area.height());
96 96
97 if (bounds->x() + min_width > visible_area.right()) { 97 if (bounds->right() < visible_area.x() + min_width) {
98 bounds->set_x(visible_area.x() + min_width - bounds->width());
99 } else if (bounds->x() > visible_area.right() - min_width) {
98 bounds->set_x(visible_area.right() - min_width); 100 bounds->set_x(visible_area.right() - min_width);
99 } else if (bounds->right() - min_width < 0) {
100 bounds->set_x(min_width - bounds->width());
101 } 101 }
102 if (bounds->y() + min_height > visible_area.bottom()) { 102 if (bounds->bottom() < visible_area.y() + min_height) {
103 bounds->set_y(visible_area.y() + min_height - bounds->height());
104 } else if (bounds->y() > visible_area.bottom() - min_height) {
103 bounds->set_y(visible_area.bottom() - min_height); 105 bounds->set_y(visible_area.bottom() - min_height);
104 } else if (bounds->bottom() - min_height < 0) {
105 bounds->set_y(min_height - bounds->height());
106 } 106 }
107 if (bounds->y() < 0) 107 if (bounds->y() < visible_area.y())
108 bounds->set_y(0); 108 bounds->set_y(visible_area.y());
109 } 109 }
110 110
111 bool MoveWindowToEventRoot(aura::Window* window, const ui::Event& event) { 111 bool MoveWindowToEventRoot(aura::Window* window, const ui::Event& event) {
112 views::View* target = static_cast<views::View*>(event.target()); 112 views::View* target = static_cast<views::View*>(event.target());
113 if (!target) 113 if (!target)
114 return false; 114 return false;
115 aura::Window* target_root = 115 aura::Window* target_root =
116 target->GetWidget()->GetNativeView()->GetRootWindow(); 116 target->GetWidget()->GetNativeView()->GetRootWindow();
117 if (!target_root || target_root == window->GetRootWindow()) 117 if (!target_root || target_root == window->GetRootWindow())
118 return false; 118 return false;
(...skipping 17 matching lines...) Expand all
136 aura::Window* new_parent) { 136 aura::Window* new_parent) {
137 for (size_t i = 0; i < child->transient_children().size(); ++i) { 137 for (size_t i = 0; i < child->transient_children().size(); ++i) {
138 ReparentChildWithTransientChildren(child->transient_children()[i], 138 ReparentChildWithTransientChildren(child->transient_children()[i],
139 old_parent, 139 old_parent,
140 new_parent); 140 new_parent);
141 } 141 }
142 } 142 }
143 143
144 } // namespace wm 144 } // namespace wm
145 } // namespace ash 145 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698