Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Side by Side Diff: ash/screen_ash.cc

Issue 9960042: Refactor screen/monitor so that gfx::Screen returns monitor object. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix command line Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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_ash.h" 5 #include "ash/screen_ash.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/wm/shelf_layout_manager.h" 8 #include "ash/wm/shelf_layout_manager.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "ui/aura/env.h" 10 #include "ui/aura/env.h"
11 #include "ui/aura/monitor.h" 11 #include "ui/aura/monitor_aura.h"
12 #include "ui/aura/monitor_manager.h" 12 #include "ui/aura/monitor_manager.h"
13 #include "ui/aura/root_window.h" 13 #include "ui/aura/root_window.h"
14 14
15 namespace ash { 15 namespace ash {
16 16
17 // TODO(oshima): For m19, the origin of work area/monitor bounds for
18 // views/aura is (0,0) because it's simple and enough. Fix this when
19 // real multi monitor support is implemented.
20
21 namespace { 17 namespace {
22 aura::MonitorManager* GetMonitorManager() { 18 aura::MonitorManager* GetMonitorManager() {
23 return aura::Env::GetInstance()->monitor_manager(); 19 return aura::Env::GetInstance()->monitor_manager();
24 } 20 }
25 } // namespace 21 } // namespace
26 22
27 ScreenAsh::ScreenAsh(aura::RootWindow* root_window) 23 ScreenAsh::ScreenAsh(aura::RootWindow* root_window)
28 : root_window_(root_window) { 24 : root_window_(root_window) {
29 } 25 }
30 26
31 ScreenAsh::~ScreenAsh() { 27 ScreenAsh::~ScreenAsh() {
32 } 28 }
33 29
34 // static 30 // static
35 gfx::Rect ScreenAsh::GetMaximizedWindowBounds(aura::Window* window) { 31 gfx::Rect ScreenAsh::GetMaximizedWindowBounds(aura::Window* window) {
36 return Shell::GetInstance()->shelf()->GetMaximizedWindowBounds(window); 32 return Shell::GetInstance()->shelf()->GetMaximizedWindowBounds(window);
37 } 33 }
38 34
39 // static 35 // static
40 gfx::Rect ScreenAsh::GetUnmaximizedWorkAreaBounds(aura::Window* window) { 36 gfx::Rect ScreenAsh::GetUnmaximizedWorkAreaBounds(aura::Window* window) {
41 return Shell::GetInstance()->shelf()->GetUnmaximizedWorkAreaBounds(window); 37 return Shell::GetInstance()->shelf()->GetUnmaximizedWorkAreaBounds(window);
42 } 38 }
43 39
44 gfx::Point ScreenAsh::GetCursorScreenPointImpl() { 40 gfx::Point ScreenAsh::GetCursorScreenPoint() {
45 return root_window_->last_mouse_location(); 41 return root_window_->last_mouse_location();
46 } 42 }
47 43
48 gfx::Rect ScreenAsh::GetMonitorWorkAreaNearestWindowImpl( 44 gfx::NativeWindow ScreenAsh::GetWindowAtCursorScreenPoint() {
49 gfx::NativeWindow window) { 45 const gfx::Point point = gfx::Screen::GetCursorScreenPoint();
50 return GetMonitorManager()->GetMonitorNearestWindow(window)->
51 GetWorkAreaBounds();
52 }
53
54 gfx::Rect ScreenAsh::GetMonitorAreaNearestWindowImpl(
55 gfx::NativeWindow window) {
56 // See the comment at the top.
57 return gfx::Rect(
58 GetMonitorManager()->GetMonitorNearestWindow(window)->size());
59 }
60
61 gfx::Rect ScreenAsh::GetMonitorWorkAreaNearestPointImpl(
62 const gfx::Point& point) {
63 return GetMonitorManager()->GetMonitorNearestPoint(point)->
64 GetWorkAreaBounds();
65 }
66
67 gfx::Rect ScreenAsh::GetMonitorAreaNearestPointImpl(const gfx::Point& point) {
68 // See the comment at the top.
69 return gfx::Rect(GetMonitorManager()->GetMonitorNearestPoint(point)->size());
70 }
71
72 gfx::NativeWindow ScreenAsh::GetWindowAtCursorScreenPointImpl() {
73 const gfx::Point point = GetCursorScreenPoint();
74 return root_window_->GetTopWindowContainingPoint(point); 46 return root_window_->GetTopWindowContainingPoint(point);
75 } 47 }
76 48
77 gfx::Size ScreenAsh::GetPrimaryMonitorSizeImpl() { 49 int ScreenAsh::GetNumMonitors() {
78 return GetMonitorManager()->GetMonitorAt(0)->size();
79 }
80
81 int ScreenAsh::GetNumMonitorsImpl() {
82 return GetMonitorManager()->GetNumMonitors(); 50 return GetMonitorManager()->GetNumMonitors();
83 } 51 }
84 52
53 const gfx::Monitor* ScreenAsh::GetMonitorNearestWindow(
54 gfx::NativeWindow window) {
55 return GetMonitorManager()->GetMonitorNearestWindow(window);
56 }
57
58 const gfx::Monitor* ScreenAsh::GetMonitorNearestPoint(
59 const gfx::Point& point) {
60 return GetMonitorManager()->GetMonitorNearestPoint(point);
61 }
62
63 const gfx::Monitor* ScreenAsh::GetPrimaryMonitor() {
64 return GetMonitorManager()->GetMonitorAt(0);
65 }
66
67 void ScreenAsh::AddMonitorObserver(gfx::MonitorObserver* observer) {
68 return GetMonitorManager()->AddObserver(observer);
69 }
70
71 void ScreenAsh::RemoveMonitorObserver(gfx::MonitorObserver* observer) {
72 return GetMonitorManager()->RemoveObserver(observer);
73 }
74
85 } // namespace ash 75 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698