| 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_port.h" | 9 #include "ash/shell_port.h" |
| 10 #include "ash/wm/mru_window_tracker.h" | 10 #include "ash/wm/mru_window_tracker.h" |
| 11 #include "ash/wm/window_positioning_utils.h" | 11 #include "ash/wm/window_positioning_utils.h" |
| 12 #include "ash/wm/window_state.h" | 12 #include "ash/wm/window_state.h" |
| 13 #include "ash/wm/window_util.h" | 13 #include "ash/wm/window_util.h" |
| 14 #include "ash/wm_window.h" | |
| 15 #include "ui/compositor/layer.h" | 14 #include "ui/compositor/layer.h" |
| 15 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 16 #include "ui/display/display.h" | 16 #include "ui/display/display.h" |
| 17 #include "ui/display/screen.h" | 17 #include "ui/display/screen.h" |
| 18 #include "ui/gfx/geometry/insets.h" | 18 #include "ui/gfx/geometry/insets.h" |
| 19 #include "ui/wm/core/window_animations.h" |
| 19 #include "ui/wm/core/window_util.h" | 20 #include "ui/wm/core/window_util.h" |
| 20 | 21 |
| 21 namespace ash { | 22 namespace ash { |
| 22 | 23 |
| 23 const int WindowPositioner::kMinimumWindowOffset = 32; | 24 const int WindowPositioner::kMinimumWindowOffset = 32; |
| 24 | 25 |
| 25 // The number of pixels which are kept free top, left and right when a window | 26 // The number of pixels which are kept free top, left and right when a window |
| 26 // gets positioned to its default location. | 27 // gets positioned to its default location. |
| 27 // static | 28 // static |
| 28 const int WindowPositioner::kDesktopBorderSize = 16; | 29 const int WindowPositioner::kDesktopBorderSize = 16; |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 if (!pop_position_offset_increment_x) { | 429 if (!pop_position_offset_increment_x) { |
| 429 // When the popup position increment is 0, the last popup position | 430 // When the popup position increment is 0, the last popup position |
| 430 // was not yet initialized. | 431 // was not yet initialized. |
| 431 last_popup_position_x_ = popup_position_offset_from_screen_corner_x; | 432 last_popup_position_x_ = popup_position_offset_from_screen_corner_x; |
| 432 last_popup_position_y_ = popup_position_offset_from_screen_corner_y; | 433 last_popup_position_y_ = popup_position_offset_from_screen_corner_y; |
| 433 } | 434 } |
| 434 pop_position_offset_increment_x = grid; | 435 pop_position_offset_increment_x = grid; |
| 435 pop_position_offset_increment_y = grid; | 436 pop_position_offset_increment_y = grid; |
| 436 // We handle the Multi monitor support by retrieving the active window's | 437 // We handle the Multi monitor support by retrieving the active window's |
| 437 // work area. | 438 // work area. |
| 438 WmWindow* window = WmWindow::Get(wm::GetActiveWindow()); | 439 aura::Window* window = wm::GetActiveWindow(); |
| 439 const gfx::Rect work_area = | 440 const gfx::Rect work_area = |
| 440 window && window->IsVisible() | 441 window && window->IsVisible() |
| 441 ? window->GetDisplayNearestWindow().work_area() | 442 ? display::Screen::GetScreen() |
| 443 ->GetDisplayNearestWindow(window) |
| 444 .work_area() |
| 442 : display::Screen::GetScreen()->GetPrimaryDisplay().work_area(); | 445 : display::Screen::GetScreen()->GetPrimaryDisplay().work_area(); |
| 443 // Only try to reposition the popup when it is not spanning the entire | 446 // Only try to reposition the popup when it is not spanning the entire |
| 444 // screen. | 447 // screen. |
| 445 if ((old_pos.width() + popup_position_offset_from_screen_corner_x >= | 448 if ((old_pos.width() + popup_position_offset_from_screen_corner_x >= |
| 446 work_area.width()) || | 449 work_area.width()) || |
| 447 (old_pos.height() + popup_position_offset_from_screen_corner_y >= | 450 (old_pos.height() + popup_position_offset_from_screen_corner_y >= |
| 448 work_area.height())) | 451 work_area.height())) |
| 449 return AlignPopupPosition(old_pos, work_area, grid); | 452 return AlignPopupPosition(old_pos, work_area, grid); |
| 450 const gfx::Rect result = SmartPopupPosition(old_pos, work_area, grid); | 453 const gfx::Rect result = SmartPopupPosition(old_pos, work_area, grid); |
| 451 if (!result.IsEmpty()) | 454 if (!result.IsEmpty()) |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 // If the alignment was pushing the window out of the screen, we ignore the | 574 // If the alignment was pushing the window out of the screen, we ignore the |
| 572 // alignment for that call. | 575 // alignment for that call. |
| 573 if (abs(pos.right() - work_area.right()) < grid) | 576 if (abs(pos.right() - work_area.right()) < grid) |
| 574 x = work_area.right() - w; | 577 x = work_area.right() - w; |
| 575 if (abs(pos.bottom() - work_area.bottom()) < grid) | 578 if (abs(pos.bottom() - work_area.bottom()) < grid) |
| 576 y = work_area.bottom() - h; | 579 y = work_area.bottom() - h; |
| 577 return gfx::Rect(x, y, w, h); | 580 return gfx::Rect(x, y, w, h); |
| 578 } | 581 } |
| 579 | 582 |
| 580 } // namespace ash | 583 } // namespace ash |
| OLD | NEW |