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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 // In unified desktop mode, there is only one shelf in the 1st display. | 58 // In unified desktop mode, there is only one shelf in the 1st display. |
59 const gfx::Display& first = | 59 const gfx::Display& first = |
60 display_manager->software_mirroring_display_list()[0]; | 60 display_manager->software_mirroring_display_list()[0]; |
61 float scale = | 61 float scale = |
62 static_cast<float>(window->GetRootWindow()->bounds().height()) / | 62 static_cast<float>(window->GetRootWindow()->bounds().height()) / |
63 first.size().height(); | 63 first.size().height(); |
64 gfx::SizeF size(first.size()); | 64 gfx::SizeF size(first.size()); |
65 size.Scale(scale, scale); | 65 size.Scale(scale, scale); |
66 return gfx::Rect(gfx::ToCeiledSize(size)); | 66 return gfx::Rect(gfx::ToCeiledSize(size)); |
67 } else { | 67 } else { |
| 68 if (window->GetRootWindow()->bounds().IsEmpty()) { |
| 69 // TODO(sad): This only happens when running with mustash, since the |
| 70 // root-window here refers to the shelf Widget, which has not been |
| 71 // sized/positioned yet. Use the bounds of the display in this case. |
| 72 // Ideally, we would not run this code at all for mustash. |
| 73 NOTIMPLEMENTED(); |
| 74 gfx::Display display = |
| 75 gfx::Screen::GetScreen()->GetDisplayNearestWindow(window); |
| 76 return gfx::Rect(display.size()); |
| 77 } |
68 return window->GetRootWindow()->bounds(); | 78 return window->GetRootWindow()->bounds(); |
69 } | 79 } |
70 } | 80 } |
71 | 81 |
72 // static | 82 // static |
73 gfx::Rect ScreenUtil::ConvertRectToScreen(aura::Window* window, | 83 gfx::Rect ScreenUtil::ConvertRectToScreen(aura::Window* window, |
74 const gfx::Rect& rect) { | 84 const gfx::Rect& rect) { |
75 gfx::Point point = rect.origin(); | 85 gfx::Point point = rect.origin(); |
76 aura::client::GetScreenPositionClient(window->GetRootWindow())-> | 86 aura::client::GetScreenPositionClient(window->GetRootWindow())-> |
77 ConvertPointToScreen(window, &point); | 87 ConvertPointToScreen(window, &point); |
(...skipping 13 matching lines...) Expand all Loading... |
91 const gfx::Display& ScreenUtil::GetSecondaryDisplay() { | 101 const gfx::Display& ScreenUtil::GetSecondaryDisplay() { |
92 DisplayManager* display_manager = GetDisplayManager(); | 102 DisplayManager* display_manager = GetDisplayManager(); |
93 CHECK_LE(2U, display_manager->GetNumDisplays()); | 103 CHECK_LE(2U, display_manager->GetNumDisplays()); |
94 return display_manager->GetDisplayAt(0).id() == | 104 return display_manager->GetDisplayAt(0).id() == |
95 gfx::Screen::GetScreen()->GetPrimaryDisplay().id() | 105 gfx::Screen::GetScreen()->GetPrimaryDisplay().id() |
96 ? display_manager->GetDisplayAt(1) | 106 ? display_manager->GetDisplayAt(1) |
97 : display_manager->GetDisplayAt(0); | 107 : display_manager->GetDisplayAt(0); |
98 } | 108 } |
99 | 109 |
100 } // namespace ash | 110 } // namespace ash |
OLD | NEW |