OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_positioner.h" | 5 #include "ash/wm/window_positioner.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_delegate.h" | 9 #include "ash/shell_delegate.h" |
10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 !window_state->bounds_changed_by_user(); | 74 !window_state->bounds_changed_by_user(); |
75 } | 75 } |
76 | 76 |
77 // Get the work area for a given |window| in parent coordinates. | 77 // Get the work area for a given |window| in parent coordinates. |
78 gfx::Rect GetWorkAreaForWindowInParent(aura::Window* window) { | 78 gfx::Rect GetWorkAreaForWindowInParent(aura::Window* window) { |
79 #if defined(OS_WIN) | 79 #if defined(OS_WIN) |
80 // On Win 8, the host window can't be resized, so | 80 // On Win 8, the host window can't be resized, so |
81 // use window's bounds instead. | 81 // use window's bounds instead. |
82 // TODO(oshima): Emulate host window resize on win8. | 82 // TODO(oshima): Emulate host window resize on win8. |
83 gfx::Rect work_area = gfx::Rect(window->parent()->bounds().size()); | 83 gfx::Rect work_area = gfx::Rect(window->parent()->bounds().size()); |
84 work_area.Inset(Shell::GetScreen()->GetDisplayMatching( | 84 work_area.Inset( |
85 window->parent()->GetBoundsInScreen()).GetWorkAreaInsets()); | 85 gfx::Screen::GetScreen() |
| 86 ->GetDisplayMatching(window->parent()->GetBoundsInScreen()) |
| 87 .GetWorkAreaInsets()); |
86 return work_area; | 88 return work_area; |
87 #else | 89 #else |
88 return ScreenUtil::GetDisplayWorkAreaBoundsInParent(window); | 90 return ScreenUtil::GetDisplayWorkAreaBoundsInParent(window); |
89 #endif | 91 #endif |
90 } | 92 } |
91 | 93 |
92 // Move the given |bounds| on the available |work_area| in the direction | 94 // Move the given |bounds| on the available |work_area| in the direction |
93 // indicated by |move_right|. If |move_right| is true, the rectangle gets moved | 95 // indicated by |move_right|. If |move_right| is true, the rectangle gets moved |
94 // to the right edge, otherwise to the left one. | 96 // to the right edge, otherwise to the left one. |
95 bool MoveRectToOneSide(const gfx::Rect& work_area, | 97 bool MoveRectToOneSide(const gfx::Rect& work_area, |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 // When the popup position increment is 0, the last popup position | 452 // When the popup position increment is 0, the last popup position |
451 // was not yet initialized. | 453 // was not yet initialized. |
452 last_popup_position_x_ = popup_position_offset_from_screen_corner_x; | 454 last_popup_position_x_ = popup_position_offset_from_screen_corner_x; |
453 last_popup_position_y_ = popup_position_offset_from_screen_corner_y; | 455 last_popup_position_y_ = popup_position_offset_from_screen_corner_y; |
454 } | 456 } |
455 pop_position_offset_increment_x = grid; | 457 pop_position_offset_increment_x = grid; |
456 pop_position_offset_increment_y = grid; | 458 pop_position_offset_increment_y = grid; |
457 // We handle the Multi monitor support by retrieving the active window's | 459 // We handle the Multi monitor support by retrieving the active window's |
458 // work area. | 460 // work area. |
459 aura::Window* window = wm::GetActiveWindow(); | 461 aura::Window* window = wm::GetActiveWindow(); |
460 const gfx::Rect work_area = window && window->IsVisible() ? | 462 const gfx::Rect work_area = |
461 Shell::GetScreen()->GetDisplayNearestWindow(window).work_area() : | 463 window && window->IsVisible() |
462 Shell::GetScreen()->GetPrimaryDisplay().work_area(); | 464 ? gfx::Screen::GetScreen() |
| 465 ->GetDisplayNearestWindow(window) |
| 466 .work_area() |
| 467 : gfx::Screen::GetScreen()->GetPrimaryDisplay().work_area(); |
463 // Only try to reposition the popup when it is not spanning the entire | 468 // Only try to reposition the popup when it is not spanning the entire |
464 // screen. | 469 // screen. |
465 if ((old_pos.width() + popup_position_offset_from_screen_corner_x >= | 470 if ((old_pos.width() + popup_position_offset_from_screen_corner_x >= |
466 work_area.width()) || | 471 work_area.width()) || |
467 (old_pos.height() + popup_position_offset_from_screen_corner_y >= | 472 (old_pos.height() + popup_position_offset_from_screen_corner_y >= |
468 work_area.height())) | 473 work_area.height())) |
469 return AlignPopupPosition(old_pos, work_area, grid); | 474 return AlignPopupPosition(old_pos, work_area, grid); |
470 const gfx::Rect result = SmartPopupPosition(old_pos, work_area, grid); | 475 const gfx::Rect result = SmartPopupPosition(old_pos, work_area, grid); |
471 if (!result.IsEmpty()) | 476 if (!result.IsEmpty()) |
472 return AlignPopupPosition(result, work_area, grid); | 477 return AlignPopupPosition(result, work_area, grid); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 // If the alignment was pushing the window out of the screen, we ignore the | 599 // If the alignment was pushing the window out of the screen, we ignore the |
595 // alignment for that call. | 600 // alignment for that call. |
596 if (abs(pos.right() - work_area.right()) < grid) | 601 if (abs(pos.right() - work_area.right()) < grid) |
597 x = work_area.right() - w; | 602 x = work_area.right() - w; |
598 if (abs(pos.bottom() - work_area.bottom()) < grid) | 603 if (abs(pos.bottom() - work_area.bottom()) < grid) |
599 y = work_area.bottom() - h; | 604 y = work_area.bottom() - h; |
600 return gfx::Rect(x, y, w, h); | 605 return gfx::Rect(x, y, w, h); |
601 } | 606 } |
602 | 607 |
603 } // namespace ash | 608 } // namespace ash |
OLD | NEW |