| 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_layout_manager.h" | 9 #include "ash/shelf/shelf_layout_manager.h" |
| 10 #include "ash/shelf/shelf_widget.h" | 10 #include "ash/shelf/shelf_widget.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 } | 46 } |
| 47 | 47 |
| 48 // static | 48 // static |
| 49 gfx::Rect ScreenUtil::GetDisplayWorkAreaBoundsInParent(aura::Window* window) { | 49 gfx::Rect ScreenUtil::GetDisplayWorkAreaBoundsInParent(aura::Window* window) { |
| 50 return ConvertRectFromScreen(window->parent(), | 50 return ConvertRectFromScreen(window->parent(), |
| 51 display::Screen::GetScreen() | 51 display::Screen::GetScreen() |
| 52 ->GetDisplayNearestWindow(window) | 52 ->GetDisplayNearestWindow(window) |
| 53 .work_area()); | 53 .work_area()); |
| 54 } | 54 } |
| 55 | 55 |
| 56 // static |
| 56 gfx::Rect ScreenUtil::GetShelfDisplayBoundsInRoot(aura::Window* window) { | 57 gfx::Rect ScreenUtil::GetShelfDisplayBoundsInRoot(aura::Window* window) { |
| 57 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 58 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 58 if (display_manager->IsInUnifiedMode()) { | 59 if (display_manager->IsInUnifiedMode()) { |
| 59 // In unified desktop mode, there is only one shelf in the 1st display. | 60 // In unified desktop mode, there is only one shelf in the 1st display. |
| 60 const display::Display& first = | 61 const display::Display& first = |
| 61 display_manager->software_mirroring_display_list()[0]; | 62 display_manager->software_mirroring_display_list()[0]; |
| 62 float scale = | 63 float scale = |
| 63 static_cast<float>(window->GetRootWindow()->bounds().height()) / | 64 static_cast<float>(window->GetRootWindow()->bounds().height()) / |
| 64 first.size().height(); | 65 first.size().height(); |
| 65 gfx::SizeF size(first.size()); | 66 gfx::SizeF size(first.size()); |
| 66 size.Scale(scale, scale); | 67 size.Scale(scale, scale); |
| 67 return gfx::Rect(gfx::ToCeiledSize(size)); | 68 return gfx::Rect(gfx::ToCeiledSize(size)); |
| 68 } else { | |
| 69 if (window->GetRootWindow()->bounds().IsEmpty()) { | |
| 70 // TODO(sad): This only happens when running with mustash, since the | |
| 71 // root-window here refers to the shelf Widget, which has not been | |
| 72 // sized/positioned yet. Use the bounds of the display in this case. | |
| 73 // Ideally, we would not run this code at all for mustash. | |
| 74 NOTIMPLEMENTED(); | |
| 75 display::Display display = | |
| 76 display::Screen::GetScreen()->GetDisplayNearestWindow(window); | |
| 77 return gfx::Rect(display.size()); | |
| 78 } | |
| 79 return window->GetRootWindow()->bounds(); | |
| 80 } | 69 } |
| 70 |
| 71 if (Shell::GetInstance()->in_mus()) { |
| 72 // In mus the RootWindow is the widget's root window, so use the display |
| 73 // bounds. |
| 74 display::Display display = |
| 75 display::Screen::GetScreen()->GetDisplayNearestWindow(window); |
| 76 return display.bounds(); |
| 77 } |
| 78 |
| 79 return window->GetRootWindow()->bounds(); |
| 81 } | 80 } |
| 82 | 81 |
| 83 // static | 82 // static |
| 84 gfx::Rect ScreenUtil::ConvertRectToScreen(aura::Window* window, | 83 gfx::Rect ScreenUtil::ConvertRectToScreen(aura::Window* window, |
| 85 const gfx::Rect& rect) { | 84 const gfx::Rect& rect) { |
| 86 gfx::Point point = rect.origin(); | 85 gfx::Point point = rect.origin(); |
| 87 aura::client::GetScreenPositionClient(window->GetRootWindow())-> | 86 aura::client::GetScreenPositionClient(window->GetRootWindow())-> |
| 88 ConvertPointToScreen(window, &point); | 87 ConvertPointToScreen(window, &point); |
| 89 return gfx::Rect(point, rect.size()); | 88 return gfx::Rect(point, rect.size()); |
| 90 } | 89 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 102 const display::Display& ScreenUtil::GetSecondaryDisplay() { | 101 const display::Display& ScreenUtil::GetSecondaryDisplay() { |
| 103 DisplayManager* display_manager = GetDisplayManager(); | 102 DisplayManager* display_manager = GetDisplayManager(); |
| 104 CHECK_LE(2U, display_manager->GetNumDisplays()); | 103 CHECK_LE(2U, display_manager->GetNumDisplays()); |
| 105 return display_manager->GetDisplayAt(0).id() == | 104 return display_manager->GetDisplayAt(0).id() == |
| 106 display::Screen::GetScreen()->GetPrimaryDisplay().id() | 105 display::Screen::GetScreen()->GetPrimaryDisplay().id() |
| 107 ? display_manager->GetDisplayAt(1) | 106 ? display_manager->GetDisplayAt(1) |
| 108 : display_manager->GetDisplayAt(0); | 107 : display_manager->GetDisplayAt(0); |
| 109 } | 108 } |
| 110 | 109 |
| 111 } // namespace ash | 110 } // namespace ash |
| OLD | NEW |