summaryrefslogtreecommitdiffstats
path: root/ash/screen_ash.cc
blob: ad679a15615b645dd62882635741f37f52b2bd96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ash/screen_ash.h"

#include "ash/shell.h"
#include "ash/wm/shelf_layout_manager.h"
#include "base/logging.h"
#include "ui/aura/env.h"
#include "ui/aura/monitor.h"
#include "ui/aura/monitor_manager.h"
#include "ui/aura/root_window.h"

namespace ash {

// TODO(oshima): For m19, the origin of work area/monitor bounds for
// views/aura is (0,0) because it's simple and enough. Fix this when
// real multi monitor support is implemented.

namespace {
aura::MonitorManager* GetMonitorManager() {
  return aura::Env::GetInstance()->monitor_manager();
}
}  // namespace

ScreenAsh::ScreenAsh(aura::RootWindow* root_window)
    : root_window_(root_window) {
}

ScreenAsh::~ScreenAsh() {
}

// static
gfx::Rect ScreenAsh::GetMaximizedWindowBounds(aura::Window* window) {
  return Shell::GetInstance()->shelf()->GetMaximizedWindowBounds(window);
}

// static
gfx::Rect ScreenAsh::GetUnmaximizedWorkAreaBounds(aura::Window* window) {
  return Shell::GetInstance()->shelf()->GetUnmaximizedWorkAreaBounds(window);
}

gfx::Point ScreenAsh::GetCursorScreenPointImpl() {
  return root_window_->last_mouse_location();
}

gfx::Rect ScreenAsh::GetMonitorWorkAreaNearestWindowImpl(
    gfx::NativeWindow window) {
  return GetMonitorManager()->GetMonitorNearestWindow(window)->
      GetWorkAreaBounds();
}

gfx::Rect ScreenAsh::GetMonitorAreaNearestWindowImpl(
    gfx::NativeWindow window) {
  // See the comment at the top.
  return gfx::Rect(
      GetMonitorManager()->GetMonitorNearestWindow(window)->size());
}

gfx::Rect ScreenAsh::GetMonitorWorkAreaNearestPointImpl(
    const gfx::Point& point) {
  return GetMonitorManager()->GetMonitorNearestPoint(point)->
      GetWorkAreaBounds();
}

gfx::Rect ScreenAsh::GetMonitorAreaNearestPointImpl(const gfx::Point& point) {
  // See the comment at the top.
  return gfx::Rect(GetMonitorManager()->GetMonitorNearestPoint(point)->size());
}

gfx::NativeWindow ScreenAsh::GetWindowAtCursorScreenPointImpl() {
  const gfx::Point point = GetCursorScreenPoint();
  return root_window_->GetTopWindowContainingPoint(point);
}

gfx::Size ScreenAsh::GetPrimaryMonitorSizeImpl() {
  return GetMonitorManager()->GetMonitorAt(0)->size();
}

int ScreenAsh::GetNumMonitorsImpl() {
  return GetMonitorManager()->GetNumMonitors();
}

}  // namespace ash