| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/screen_util.h" | 5 #include "ash/screen_util.h" |
| 6 | 6 |
| 7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
| 8 #include "ash/display/display_manager.h" | 8 #include "ash/display/display_manager.h" |
| 9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
| 10 #include "ash/shelf/shelf_layout_manager.h" | 10 #include "ash/shelf/shelf_layout_manager.h" |
| 11 #include "ash/shelf/shelf_widget.h" | 11 #include "ash/shelf/shelf_widget.h" |
| 12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 13 #include "ash/wm/coordinate_conversion.h" | 13 #include "ash/wm/coordinate_conversion.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "ui/aura/client/screen_position_client.h" | 15 #include "ui/aura/client/screen_position_client.h" |
| 16 #include "ui/aura/window_event_dispatcher.h" | 16 #include "ui/aura/window_event_dispatcher.h" |
| 17 #include "ui/gfx/display.h" | 17 #include "ui/gfx/display.h" |
| 18 #include "ui/gfx/screen.h" | 18 #include "ui/gfx/screen.h" |
| 19 | 19 |
| 20 namespace ash { | 20 namespace ash { |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 internal::DisplayManager* GetDisplayManager() { | 23 DisplayManager* GetDisplayManager() { |
| 24 return Shell::GetInstance()->display_manager(); | 24 return Shell::GetInstance()->display_manager(); |
| 25 } | 25 } |
| 26 } | 26 } |
| 27 | 27 |
| 28 // static | 28 // static |
| 29 gfx::Display ScreenUtil::FindDisplayContainingPoint(const gfx::Point& point) { | 29 gfx::Display ScreenUtil::FindDisplayContainingPoint(const gfx::Point& point) { |
| 30 return GetDisplayManager()->FindDisplayContainingPoint(point); | 30 return GetDisplayManager()->FindDisplayContainingPoint(point); |
| 31 } | 31 } |
| 32 | 32 |
| 33 // static | 33 // static |
| 34 gfx::Rect ScreenUtil::GetMaximizedWindowBoundsInParent(aura::Window* window) { | 34 gfx::Rect ScreenUtil::GetMaximizedWindowBoundsInParent(aura::Window* window) { |
| 35 if (internal::GetRootWindowController(window->GetRootWindow())->shelf()) | 35 if (GetRootWindowController(window->GetRootWindow())->shelf()) |
| 36 return GetDisplayWorkAreaBoundsInParent(window); | 36 return GetDisplayWorkAreaBoundsInParent(window); |
| 37 else | 37 else |
| 38 return GetDisplayBoundsInParent(window); | 38 return GetDisplayBoundsInParent(window); |
| 39 } | 39 } |
| 40 | 40 |
| 41 // static | 41 // static |
| 42 gfx::Rect ScreenUtil::GetDisplayBoundsInParent(aura::Window* window) { | 42 gfx::Rect ScreenUtil::GetDisplayBoundsInParent(aura::Window* window) { |
| 43 return ConvertRectFromScreen( | 43 return ConvertRectFromScreen( |
| 44 window->parent(), | 44 window->parent(), |
| 45 Shell::GetScreen()->GetDisplayNearestWindow(window).bounds()); | 45 Shell::GetScreen()->GetDisplayNearestWindow(window).bounds()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 65 gfx::Rect ScreenUtil::ConvertRectFromScreen(aura::Window* window, | 65 gfx::Rect ScreenUtil::ConvertRectFromScreen(aura::Window* window, |
| 66 const gfx::Rect& rect) { | 66 const gfx::Rect& rect) { |
| 67 gfx::Point point = rect.origin(); | 67 gfx::Point point = rect.origin(); |
| 68 aura::client::GetScreenPositionClient(window->GetRootWindow())-> | 68 aura::client::GetScreenPositionClient(window->GetRootWindow())-> |
| 69 ConvertPointFromScreen(window, &point); | 69 ConvertPointFromScreen(window, &point); |
| 70 return gfx::Rect(point, rect.size()); | 70 return gfx::Rect(point, rect.size()); |
| 71 } | 71 } |
| 72 | 72 |
| 73 // static | 73 // static |
| 74 const gfx::Display& ScreenUtil::GetSecondaryDisplay() { | 74 const gfx::Display& ScreenUtil::GetSecondaryDisplay() { |
| 75 internal::DisplayManager* display_manager = GetDisplayManager(); | 75 DisplayManager* display_manager = GetDisplayManager(); |
| 76 CHECK_EQ(2U, display_manager->GetNumDisplays()); | 76 CHECK_EQ(2U, display_manager->GetNumDisplays()); |
| 77 return display_manager->GetDisplayAt(0).id() == | 77 return display_manager->GetDisplayAt(0).id() == |
| 78 Shell::GetScreen()->GetPrimaryDisplay().id() ? | 78 Shell::GetScreen()->GetPrimaryDisplay().id() ? |
| 79 display_manager->GetDisplayAt(1) : display_manager->GetDisplayAt(0); | 79 display_manager->GetDisplayAt(1) : display_manager->GetDisplayAt(0); |
| 80 } | 80 } |
| 81 | 81 |
| 82 // static | 82 // static |
| 83 const gfx::Display& ScreenUtil::GetDisplayForId(int64 display_id) { | 83 const gfx::Display& ScreenUtil::GetDisplayForId(int64 display_id) { |
| 84 return GetDisplayManager()->GetDisplayForId(display_id); | 84 return GetDisplayManager()->GetDisplayForId(display_id); |
| 85 } | 85 } |
| 86 | 86 |
| 87 } // namespace ash | 87 } // namespace ash |
| OLD | NEW |