summaryrefslogtreecommitdiffstats
path: root/ash/screen_util.cc
diff options
context:
space:
mode:
authoroshima <oshima@chromium.org>2015-07-17 19:23:57 -0700
committerCommit bot <commit-bot@chromium.org>2015-07-18 02:24:33 +0000
commit5337ca9c963bb2f9f70a9333a8569a933c91086b (patch)
tree86e07d34954ee1f7a3e5266b424f1102a6af62e6 /ash/screen_util.cc
parentfd0f0755afb906cc43542b44895a03a854633745 (diff)
downloadchromium_src-5337ca9c963bb2f9f70a9333a8569a933c91086b.zip
chromium_src-5337ca9c963bb2f9f70a9333a8569a933c91086b.tar.gz
chromium_src-5337ca9c963bb2f9f70a9333a8569a933c91086b.tar.bz2
Scale the content of unified desktop to fit the displays with different size.
* A user can pick the scale that fits to one of displays. * scale won't be saved because the scale value changes depending on the display size connected. * minor cleanup: remove unnecessary code. BUG=483811 TEST=covered unit tests. manual. Review URL: https://codereview.chromium.org/1231003002 Cr-Commit-Position: refs/heads/master@{#339380}
Diffstat (limited to 'ash/screen_util.cc')
-rw-r--r--ash/screen_util.cc14
1 files changed, 10 insertions, 4 deletions
diff --git a/ash/screen_util.cc b/ash/screen_util.cc
index 95b70ca..bd4f22d 100644
--- a/ash/screen_util.cc
+++ b/ash/screen_util.cc
@@ -15,6 +15,7 @@
#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/gfx/display.h"
+#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/screen.h"
namespace ash {
@@ -52,16 +53,21 @@ gfx::Rect ScreenUtil::GetDisplayWorkAreaBoundsInParent(aura::Window* window) {
Shell::GetScreen()->GetDisplayNearestWindow(window).work_area());
}
-gfx::Rect ScreenUtil::GetShelfDisplayBoundsInScreen(aura::Window* root_window) {
+gfx::Rect ScreenUtil::GetShelfDisplayBoundsInScreen(aura::Window* window) {
DisplayManager* display_manager = Shell::GetInstance()->display_manager();
if (display_manager->IsInUnifiedMode()) {
// In unified desktop mode, there is only one shelf in the 1st display.
const gfx::Display& first =
display_manager->software_mirroring_display_list()[0];
- return first.bounds();
+ float scale =
+ static_cast<float>(window->GetRootWindow()->bounds().height()) /
+ first.size().height();
+ gfx::SizeF size(first.size());
+ size.Scale(scale, scale);
+ return gfx::Rect(gfx::ToCeiledSize(size));
} else {
- return gfx::Screen::GetScreenFor(root_window)
- ->GetDisplayNearestWindow(root_window)
+ return gfx::Screen::GetScreenFor(window)
+ ->GetDisplayNearestWindow(window)
.bounds();
}
}