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

Side by Side Diff: ash/wm/workspace/workspace_window_resizer.cc

Issue 9960042: Refactor screen/monitor so that gfx::Screen returns monitor object. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years, 8 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/workspace/workspace_window_resizer.h" 5 #include "ash/wm/workspace/workspace_window_resizer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 if (phantom_window_controller_.get() && 205 if (phantom_window_controller_.get() &&
206 phantom_window_controller_->IsShowing()) { 206 phantom_window_controller_->IsShowing()) {
207 return phantom_window_controller_->bounds(); 207 return phantom_window_controller_->bounds();
208 } 208 }
209 return AdjustBoundsToGrid(bounds, grid_size); 209 return AdjustBoundsToGrid(bounds, grid_size);
210 } 210 }
211 211
212 void WorkspaceWindowResizer::LayoutAttachedWindows( 212 void WorkspaceWindowResizer::LayoutAttachedWindows(
213 const gfx::Rect& bounds, 213 const gfx::Rect& bounds,
214 int grid_size) { 214 int grid_size) {
215 gfx::Rect work_area(gfx::Screen::GetMonitorWorkAreaNearestWindow(window())); 215 gfx::Rect work_area(
216 gfx::Screen::GetMonitorNearestWindow(window()).work_area());
216 std::vector<int> sizes; 217 std::vector<int> sizes;
217 CalculateAttachedSizes( 218 CalculateAttachedSizes(
218 PrimaryAxisSize(details_.initial_bounds.size()), 219 PrimaryAxisSize(details_.initial_bounds.size()),
219 PrimaryAxisSize(bounds.size()), 220 PrimaryAxisSize(bounds.size()),
220 PrimaryAxisCoordinate(bounds.right(), bounds.bottom()), 221 PrimaryAxisCoordinate(bounds.right(), bounds.bottom()),
221 PrimaryAxisCoordinate(work_area.right(), work_area.bottom()), 222 PrimaryAxisCoordinate(work_area.right(), work_area.bottom()),
222 grid_size, 223 grid_size,
223 &sizes); 224 &sizes);
224 DCHECK_EQ(attached_windows_.size(), sizes.size()); 225 DCHECK_EQ(attached_windows_.size(), sizes.size());
225 int last = PrimaryAxisCoordinate(bounds.right(), bounds.bottom()); 226 int last = PrimaryAxisCoordinate(bounds.right(), bounds.bottom());
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 size = end - current; 275 size = end - current;
275 current += size; 276 current += size;
276 sizes->push_back(size); 277 sizes->push_back(size);
277 } 278 }
278 } 279 }
279 } 280 }
280 281
281 void WorkspaceWindowResizer::AdjustBoundsForMainWindow( 282 void WorkspaceWindowResizer::AdjustBoundsForMainWindow(
282 gfx::Rect* bounds, int grid_size) const { 283 gfx::Rect* bounds, int grid_size) const {
283 // Always keep kMinOnscreenHeight on the bottom. 284 // Always keep kMinOnscreenHeight on the bottom.
284 gfx::Rect work_area(gfx::Screen::GetMonitorWorkAreaNearestWindow(window())); 285 gfx::Rect work_area(
286 gfx::Screen::GetMonitorNearestWindow(window()).work_area());
285 int max_y = AlignToGridRoundUp(work_area.bottom() - kMinOnscreenHeight, 287 int max_y = AlignToGridRoundUp(work_area.bottom() - kMinOnscreenHeight,
286 grid_size); 288 grid_size);
287 if (bounds->y() > max_y) 289 if (bounds->y() > max_y)
288 bounds->set_y(max_y); 290 bounds->set_y(max_y);
289 291
290 // Don't allow dragging above the top of the monitor. 292 // Don't allow dragging above the top of the monitor.
291 if (bounds->y() <= work_area.y()) 293 if (bounds->y() <= work_area.y())
292 bounds->set_y(work_area.y()); 294 bounds->set_y(work_area.y());
293 295
294 if (grid_size >= 0 && details_.window_component == HTCAPTION) 296 if (grid_size >= 0 && details_.window_component == HTCAPTION)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 bounds->height() < (bottom_edge - top_edge)) { 330 bounds->height() < (bottom_edge - top_edge)) {
329 // Only snap to the bottom if the window is smaller than the work area. 331 // Only snap to the bottom if the window is smaller than the work area.
330 // Doing otherwise can lead to window snapping in weird ways as it bounces 332 // Doing otherwise can lead to window snapping in weird ways as it bounces
331 // between snapping to top then bottom. 333 // between snapping to top then bottom.
332 bounds->set_y(bottom_edge - bounds->height()); 334 bounds->set_y(bottom_edge - bounds->height());
333 } 335 }
334 } 336 }
335 337
336 bool WorkspaceWindowResizer::TouchesBottomOfScreen() const { 338 bool WorkspaceWindowResizer::TouchesBottomOfScreen() const {
337 gfx::Rect work_area( 339 gfx::Rect work_area(
338 gfx::Screen::GetMonitorWorkAreaNearestWindow(details_.window)); 340 gfx::Screen::GetMonitorNearestWindow(details_.window).work_area());
339 return (attached_windows_.empty() && 341 return (attached_windows_.empty() &&
340 details_.window->bounds().bottom() == work_area.bottom()) || 342 details_.window->bounds().bottom() == work_area.bottom()) ||
341 (!attached_windows_.empty() && 343 (!attached_windows_.empty() &&
342 attached_windows_.back()->bounds().bottom() == work_area.bottom()); 344 attached_windows_.back()->bounds().bottom() == work_area.bottom());
343 } 345 }
344 346
345 int WorkspaceWindowResizer::PrimaryAxisSize(const gfx::Size& size) const { 347 int WorkspaceWindowResizer::PrimaryAxisSize(const gfx::Size& size) const {
346 return PrimaryAxisCoordinate(size.width(), size.height()); 348 return PrimaryAxisCoordinate(size.width(), size.height());
347 } 349 }
348 350
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 ++i; 417 ++i;
416 if (i != map.rend()) 418 if (i != map.rend())
417 parent->StackChildBelow(i->second, window); 419 parent->StackChildBelow(i->second, window);
418 } 420 }
419 } 421 }
420 422
421 WorkspaceWindowResizer::SnapType WorkspaceWindowResizer::GetSnapType( 423 WorkspaceWindowResizer::SnapType WorkspaceWindowResizer::GetSnapType(
422 const gfx::Point& location) const { 424 const gfx::Point& location) const {
423 // TODO: this likely only wants total monitor area, not the area of a single 425 // TODO: this likely only wants total monitor area, not the area of a single
424 // monitor. 426 // monitor.
425 gfx::Rect area(gfx::Screen::GetMonitorAreaNearestWindow(details_.window)); 427 gfx::Rect area(
428 gfx::Screen::GetMonitorNearestWindow(details_.window).bounds());
426 if (location.x() <= area.x()) 429 if (location.x() <= area.x())
427 return SNAP_LEFT_EDGE; 430 return SNAP_LEFT_EDGE;
428 if (location.x() >= area.right() - 1) 431 if (location.x() >= area.right() - 1)
429 return SNAP_RIGHT_EDGE; 432 return SNAP_RIGHT_EDGE;
430 return SNAP_NONE; 433 return SNAP_NONE;
431 } 434 }
432 435
433 } // namespace internal 436 } // namespace internal
434 } // namespace ash 437 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace_manager_unittest.cc ('k') | chrome/browser/chromeos/input_method/candidate_window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698