OLD | NEW |
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 "chrome/browser/ui/views/ash/window_positioner.h" | 5 #include "chrome/browser/ui/views/ash/window_positioner.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/wm/window_cycle_controller.h" | 8 #include "ash/wm/window_cycle_controller.h" |
9 #include "ash/wm/window_resizer.h" | 9 #include "ash/wm/window_resizer.h" |
10 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 // was not yet initialized. | 41 // was not yet initialized. |
42 last_popup_position_x_ = popup_position_offset_from_screen_corner_x; | 42 last_popup_position_x_ = popup_position_offset_from_screen_corner_x; |
43 last_popup_position_y_ = popup_position_offset_from_screen_corner_y; | 43 last_popup_position_y_ = popup_position_offset_from_screen_corner_y; |
44 } | 44 } |
45 pop_position_offset_increment_x = grid; | 45 pop_position_offset_increment_x = grid; |
46 pop_position_offset_increment_y = grid; | 46 pop_position_offset_increment_y = grid; |
47 // We handle the Multi monitor support by retrieving the active window's | 47 // We handle the Multi monitor support by retrieving the active window's |
48 // work area. | 48 // work area. |
49 aura::Window* window = ash::wm::GetActiveWindow(); | 49 aura::Window* window = ash::wm::GetActiveWindow(); |
50 const gfx::Rect work_area = window && window->IsVisible() ? | 50 const gfx::Rect work_area = window && window->IsVisible() ? |
51 gfx::Screen::GetMonitorWorkAreaNearestWindow(window) : | 51 gfx::Screen::GetMonitorNearestWindow(window).work_area() : |
52 gfx::Screen::GetPrimaryMonitorWorkArea(); | 52 gfx::Screen::GetPrimaryMonitor().work_area(); |
53 // Only try to reposition the popup when it is not spanning the entire | 53 // Only try to reposition the popup when it is not spanning the entire |
54 // screen. | 54 // screen. |
55 if ((old_pos.width() + popup_position_offset_from_screen_corner_x >= | 55 if ((old_pos.width() + popup_position_offset_from_screen_corner_x >= |
56 work_area.width()) || | 56 work_area.width()) || |
57 (old_pos.height() + popup_position_offset_from_screen_corner_y >= | 57 (old_pos.height() + popup_position_offset_from_screen_corner_y >= |
58 work_area.height())) | 58 work_area.height())) |
59 return AlignPopupPosition(old_pos, work_area, grid); | 59 return AlignPopupPosition(old_pos, work_area, grid); |
60 const gfx::Rect result = SmartPopupPosition(old_pos, work_area, grid); | 60 const gfx::Rect result = SmartPopupPosition(old_pos, work_area, grid); |
61 if (!result.IsEmpty()) | 61 if (!result.IsEmpty()) |
62 return AlignPopupPosition(result, work_area, grid); | 62 return AlignPopupPosition(result, work_area, grid); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 int h = pos.height(); | 181 int h = pos.height(); |
182 | 182 |
183 // If the alignment was pushing the window out of the screen, we ignore the | 183 // If the alignment was pushing the window out of the screen, we ignore the |
184 // alignment for that call. | 184 // alignment for that call. |
185 if (abs(pos.right() - work_area.right()) < grid) | 185 if (abs(pos.right() - work_area.right()) < grid) |
186 x = work_area.right() - w; | 186 x = work_area.right() - w; |
187 if (abs(pos.bottom() - work_area.bottom()) < grid) | 187 if (abs(pos.bottom() - work_area.bottom()) < grid) |
188 y = work_area.bottom() - h; | 188 y = work_area.bottom() - h; |
189 return gfx::Rect(x, y, w, h); | 189 return gfx::Rect(x, y, w, h); |
190 } | 190 } |
OLD | NEW |