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

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: update bounds without removing Created 6 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 | Annotate | Revision Log
« no previous file with comments | « ash/wm/system_gesture_event_filter_unittest.cc ('k') | ash/wm/window_util_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_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 20 matching lines...) Expand all
139 ++i) { 139 ++i) {
140 ReparentChildWithTransientChildren( 140 ReparentChildWithTransientChildren(
141 views::corewm::GetTransientChildren(child)[i], 141 views::corewm::GetTransientChildren(child)[i],
142 old_parent, 142 old_parent,
143 new_parent); 143 new_parent);
144 } 144 }
145 } 145 }
146 146
147 } // namespace wm 147 } // namespace wm
148 } // namespace ash 148 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/system_gesture_event_filter_unittest.cc ('k') | ash/wm/window_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698