app_list/chromeos: Launch search results in a new tab.
[chromium-blink-merge.git] / ash / screen_ash.cc
blob71df546efd0a8e0ea53c25fef932d3f1b6ab400d
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"
7 #include "ash/shell.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"
16 namespace ash {
18 namespace {
19 aura::MonitorManager* GetMonitorManager() {
20 return aura::Env::GetInstance()->monitor_manager();
22 } // namespace
24 ScreenAsh::ScreenAsh() {
27 ScreenAsh::~ScreenAsh() {
30 // static
31 gfx::Rect ScreenAsh::GetMaximizedWindowBounds(aura::Window* window) {
32 if (window->GetRootWindow() == Shell::GetPrimaryRootWindow())
33 return Shell::GetInstance()->shelf()->GetMaximizedWindowBounds(window);
34 else
35 return gfx::Screen::GetMonitorNearestWindow(window).bounds();
38 // static
39 gfx::Rect ScreenAsh::GetUnmaximizedWorkAreaBounds(aura::Window* window) {
40 if (window->GetRootWindow() == Shell::GetPrimaryRootWindow())
41 return Shell::GetInstance()->shelf()->GetUnmaximizedWorkAreaBounds(window);
42 else
43 return gfx::Screen::GetMonitorNearestWindow(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::GetNumMonitors() {
58 return GetMonitorManager()->GetNumMonitors();
61 gfx::Display ScreenAsh::GetMonitorNearestWindow(gfx::NativeView window) const {
62 return GetMonitorManager()->GetMonitorNearestWindow(window);
65 gfx::Display ScreenAsh::GetMonitorNearestPoint(const gfx::Point& point) const {
66 return GetMonitorManager()->GetMonitorNearestPoint(point);
69 gfx::Display ScreenAsh::GetPrimaryMonitor() const {
70 return GetMonitorManager()->GetMonitorAt(0);
73 } // namespace ash