| 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_manager.h" | 7 #include "ash/display/display_manager.h" |
| 8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
| 9 #include "ash/shelf/shelf_widget.h" | 9 #include "ash/shelf/shelf_widget.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 // static | 47 // static |
| 48 gfx::Rect ScreenUtil::GetDisplayWorkAreaBoundsInParent(aura::Window* window) { | 48 gfx::Rect ScreenUtil::GetDisplayWorkAreaBoundsInParent(aura::Window* window) { |
| 49 return ConvertRectFromScreen(window->parent(), | 49 return ConvertRectFromScreen(window->parent(), |
| 50 display::Screen::GetScreen() | 50 display::Screen::GetScreen() |
| 51 ->GetDisplayNearestWindow(window) | 51 ->GetDisplayNearestWindow(window) |
| 52 .work_area()); | 52 .work_area()); |
| 53 } | 53 } |
| 54 | 54 |
| 55 // static | 55 // static |
| 56 gfx::Rect ScreenUtil::GetShelfDisplayBoundsInRoot(aura::Window* window) { | |
| 57 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | |
| 58 if (display_manager->IsInUnifiedMode()) { | |
| 59 // In unified desktop mode, there is only one shelf in the 1st display. | |
| 60 const display::Display& first = | |
| 61 display_manager->software_mirroring_display_list()[0]; | |
| 62 float scale = | |
| 63 static_cast<float>(window->GetRootWindow()->bounds().height()) / | |
| 64 first.size().height(); | |
| 65 gfx::SizeF size(first.size()); | |
| 66 size.Scale(scale, scale); | |
| 67 return gfx::Rect(gfx::ToCeiledSize(size)); | |
| 68 } | |
| 69 | |
| 70 if (Shell::GetInstance()->in_mus()) { | |
| 71 // In mus the RootWindow is the widget's root window, so use the display | |
| 72 // bounds. | |
| 73 display::Display display = | |
| 74 display::Screen::GetScreen()->GetDisplayNearestWindow(window); | |
| 75 return display.bounds(); | |
| 76 } | |
| 77 | |
| 78 return window->GetRootWindow()->bounds(); | |
| 79 } | |
| 80 | |
| 81 // static | |
| 82 gfx::Rect ScreenUtil::ConvertRectToScreen(aura::Window* window, | 56 gfx::Rect ScreenUtil::ConvertRectToScreen(aura::Window* window, |
| 83 const gfx::Rect& rect) { | 57 const gfx::Rect& rect) { |
| 84 gfx::Point point = rect.origin(); | 58 gfx::Point point = rect.origin(); |
| 85 aura::client::GetScreenPositionClient(window->GetRootWindow()) | 59 aura::client::GetScreenPositionClient(window->GetRootWindow()) |
| 86 ->ConvertPointToScreen(window, &point); | 60 ->ConvertPointToScreen(window, &point); |
| 87 return gfx::Rect(point, rect.size()); | 61 return gfx::Rect(point, rect.size()); |
| 88 } | 62 } |
| 89 | 63 |
| 90 // static | 64 // static |
| 91 gfx::Rect ScreenUtil::ConvertRectFromScreen(aura::Window* window, | 65 gfx::Rect ScreenUtil::ConvertRectFromScreen(aura::Window* window, |
| 92 const gfx::Rect& rect) { | 66 const gfx::Rect& rect) { |
| 93 gfx::Point point = rect.origin(); | 67 gfx::Point point = rect.origin(); |
| 94 aura::client::GetScreenPositionClient(window->GetRootWindow()) | 68 aura::client::GetScreenPositionClient(window->GetRootWindow()) |
| 95 ->ConvertPointFromScreen(window, &point); | 69 ->ConvertPointFromScreen(window, &point); |
| 96 return gfx::Rect(point, rect.size()); | 70 return gfx::Rect(point, rect.size()); |
| 97 } | 71 } |
| 98 | 72 |
| 99 // static | 73 // static |
| 100 const display::Display& ScreenUtil::GetSecondaryDisplay() { | 74 const display::Display& ScreenUtil::GetSecondaryDisplay() { |
| 101 DisplayManager* display_manager = GetDisplayManager(); | 75 DisplayManager* display_manager = GetDisplayManager(); |
| 102 CHECK_LE(2U, display_manager->GetNumDisplays()); | 76 CHECK_LE(2U, display_manager->GetNumDisplays()); |
| 103 return display_manager->GetDisplayAt(0).id() == | 77 return display_manager->GetDisplayAt(0).id() == |
| 104 display::Screen::GetScreen()->GetPrimaryDisplay().id() | 78 display::Screen::GetScreen()->GetPrimaryDisplay().id() |
| 105 ? display_manager->GetDisplayAt(1) | 79 ? display_manager->GetDisplayAt(1) |
| 106 : display_manager->GetDisplayAt(0); | 80 : display_manager->GetDisplayAt(0); |
| 107 } | 81 } |
| 108 | 82 |
| 109 } // namespace ash | 83 } // namespace ash |
| OLD | NEW |