| 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_util.h" | 9 #include "ash/wm/window_util.h" |
| 10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
| 11 #include "ui/aura/window_delegate.h" | 11 #include "ui/aura/window_delegate.h" |
| 12 #include "ui/gfx/compositor/layer.h" | 12 #include "ui/gfx/compositor/layer.h" |
| 13 #include "ui/gfx/monitor.h" |
| 13 #include "ui/gfx/screen.h" | 14 #include "ui/gfx/screen.h" |
| 14 | 15 |
| 15 WindowPositioner::WindowPositioner() | 16 WindowPositioner::WindowPositioner() |
| 16 : pop_position_offset_increment_x(0), | 17 : pop_position_offset_increment_x(0), |
| 17 pop_position_offset_increment_y(0), | 18 pop_position_offset_increment_y(0), |
| 18 popup_position_offset_from_screen_corner_x(0), | 19 popup_position_offset_from_screen_corner_x(0), |
| 19 popup_position_offset_from_screen_corner_y(0), | 20 popup_position_offset_from_screen_corner_y(0), |
| 20 last_popup_position_x_(0), | 21 last_popup_position_x_(0), |
| 21 last_popup_position_y_(0) { | 22 last_popup_position_y_(0) { |
| 22 } | 23 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 40 last_popup_position_x_ = popup_position_offset_from_screen_corner_x; | 41 last_popup_position_x_ = popup_position_offset_from_screen_corner_x; |
| 41 last_popup_position_y_ = popup_position_offset_from_screen_corner_y; | 42 last_popup_position_y_ = popup_position_offset_from_screen_corner_y; |
| 42 } | 43 } |
| 43 pop_position_offset_increment_x = grid; | 44 pop_position_offset_increment_x = grid; |
| 44 pop_position_offset_increment_y = grid; | 45 pop_position_offset_increment_y = grid; |
| 45 // We handle the Multi monitor support by retrieving the active window's | 46 // We handle the Multi monitor support by retrieving the active window's |
| 46 // work area. | 47 // work area. |
| 47 aura::Window* window = ash::wm::GetActiveWindow(); | 48 aura::Window* window = ash::wm::GetActiveWindow(); |
| 48 const gfx::Rect work_area = window && window->IsVisible() ? | 49 const gfx::Rect work_area = window && window->IsVisible() ? |
| 49 gfx::Screen::GetMonitorWorkAreaNearestWindow(window) : | 50 gfx::Screen::GetMonitorWorkAreaNearestWindow(window) : |
| 50 gfx::Screen::GetPrimaryMonitorWorkArea(); | 51 gfx::Screen::GetPrimaryMonitor()->GetWorkArea(); |
| 51 // Only try to reposition the popup when it is not spanning the entire | 52 // Only try to reposition the popup when it is not spanning the entire |
| 52 // screen. | 53 // screen. |
| 53 if ((old_pos.width() + popup_position_offset_from_screen_corner_x >= | 54 if ((old_pos.width() + popup_position_offset_from_screen_corner_x >= |
| 54 work_area.width()) || | 55 work_area.width()) || |
| 55 (old_pos.height() + popup_position_offset_from_screen_corner_y >= | 56 (old_pos.height() + popup_position_offset_from_screen_corner_y >= |
| 56 work_area.height())) | 57 work_area.height())) |
| 57 return old_pos; | 58 return old_pos; |
| 58 const gfx::Rect result = SmartPopupPosition(old_pos, work_area); | 59 const gfx::Rect result = SmartPopupPosition(old_pos, work_area); |
| 59 if (!result.IsEmpty()) | 60 if (!result.IsEmpty()) |
| 60 return result; | 61 return result; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 break; | 152 break; |
| 152 } | 153 } |
| 153 } | 154 } |
| 154 if (i >= regions.size()) | 155 if (i >= regions.size()) |
| 155 return gfx::Rect(x + work_area.x(), y + work_area.y(), w, h); | 156 return gfx::Rect(x + work_area.x(), y + work_area.y(), w, h); |
| 156 } | 157 } |
| 157 } | 158 } |
| 158 } | 159 } |
| 159 return gfx::Rect(0, 0, 0, 0); | 160 return gfx::Rect(0, 0, 0, 0); |
| 160 } | 161 } |
| OLD | NEW |