1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ash/screen_ash.h"
8 #include "ash/wm/shelf_layout_manager.h"
9 #include "base/logging.h"
10 #include "ui/aura/env.h"
11 #include "ui/aura/monitor_manager.h"
12 #include "ui/aura/root_window.h"
13 #include "ui/gfx/display.h"
14 #include "ui/gfx/screen.h"
19 aura::MonitorManager
* GetMonitorManager() {
20 return aura::Env::GetInstance()->monitor_manager();
24 ScreenAsh::ScreenAsh() {
27 ScreenAsh::~ScreenAsh() {
31 gfx::Rect
ScreenAsh::GetMaximizedWindowBounds(aura::Window
* window
) {
32 if (window
->GetRootWindow() == Shell::GetPrimaryRootWindow())
33 return Shell::GetInstance()->shelf()->GetMaximizedWindowBounds(window
);
35 return gfx::Screen::GetDisplayNearestWindow(window
).bounds();
39 gfx::Rect
ScreenAsh::GetUnmaximizedWorkAreaBounds(aura::Window
* window
) {
40 if (window
->GetRootWindow() == Shell::GetPrimaryRootWindow())
41 return Shell::GetInstance()->shelf()->GetUnmaximizedWorkAreaBounds(window
);
43 return gfx::Screen::GetDisplayNearestWindow(window
).work_area();
46 gfx::Point
ScreenAsh::GetCursorScreenPoint() {
47 // TODO(oshima): Support multiple root window.
48 return Shell::GetPrimaryRootWindow()->last_mouse_location();
51 gfx::NativeWindow
ScreenAsh::GetWindowAtCursorScreenPoint() {
52 const gfx::Point point
= gfx::Screen::GetCursorScreenPoint();
53 // TODO(oshima): convert point to relateive to the root window.
54 return Shell::GetRootWindowAt(point
)->GetTopWindowContainingPoint(point
);
57 int ScreenAsh::GetNumDisplays() {
58 return GetMonitorManager()->GetNumDisplays();
61 gfx::Display
ScreenAsh::GetDisplayNearestWindow(gfx::NativeView window
) const {
62 return GetMonitorManager()->GetDisplayNearestWindow(window
);
65 gfx::Display
ScreenAsh::GetDisplayNearestPoint(const gfx::Point
& point
) const {
66 return GetMonitorManager()->GetDisplayNearestPoint(point
);
69 gfx::Display
ScreenAsh::GetPrimaryDisplay() const {
70 return GetMonitorManager()->GetDisplayAt(0);