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

Side by Side Diff: ui/gfx/screen_aura.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: sync 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
(Empty)
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.
4
5 #include "ui/gfx/screen.h"
6
7 #include "base/logging.h"
8 #include "ui/gfx/monitor.h"
9 #include "ui/gfx/native_widget_types.h"
10 #include "ui/gfx/screen_impl.h"
11
12 namespace gfx {
13
14 // gfx can't depend upon aura, otherwise we have circular dependencies. So,
15 // gfx::Screen is pluggable and Desktop plugs in the real implementation.
16 namespace {
17 ScreenImpl* g_instance_ = NULL;
18
19 // TODO(erg): Figure out what to do about the Screen class. For now, I've
20 // added default values for when a Screen instance class isn't passed in, but
21 // this is the wrong thing.
22 const Monitor* GetDefaultMonitor() {
23 static SimpleMonitor* default_monitor =
24 new SimpleMonitor(gfx::Rect(0, 0, 800, 800));
25 return default_monitor;
26 };
27
28 }
29
30 // static
31 void Screen::SetInstance(ScreenImpl* screen) {
32 delete g_instance_;
33 g_instance_ = screen;
34 }
35
36 // static
37 gfx::Point Screen::GetCursorScreenPoint() {
38 if (!g_instance_)
39 return gfx::Point();
40 return g_instance_->GetCursorScreenPoint();
41 }
42
43 // static
44 gfx::NativeWindow Screen::GetWindowAtCursorScreenPoint() {
45 if (!g_instance_)
46 return NULL;
47 return g_instance_->GetWindowAtCursorScreenPoint();
48 }
49
50 // static
51 int Screen::GetNumMonitors() {
52 if (!g_instance_)
53 return 1;
54 return g_instance_->GetNumMonitors();
55 }
56
57 // static
58 const gfx::Monitor* Screen::GetMonitorNearestWindow(gfx::NativeWindow window) {
59 if (!g_instance_)
60 return GetDefaultMonitor();
61 return g_instance_->GetMonitorNearestWindow(window);
62 }
63
64 // static
65 const gfx::Monitor* Screen::GetMonitorNearestPoint(const gfx::Point& point) {
66 if (!g_instance_)
67 return GetDefaultMonitor();
68 return g_instance_->GetMonitorNearestPoint(point);
69 }
70
71 // static
72 const gfx::Monitor* Screen::GetPrimaryMonitor() {
73 if (!g_instance_)
74 return GetDefaultMonitor();
75 return g_instance_->GetPrimaryMonitor();
76 }
77
78 // static
79 const gfx::Monitor* Screen::GetMonitorMatching(const gfx::Rect& match_rect) {
80 if (!g_instance_)
81 return GetDefaultMonitor();
82 return g_instance_->GetMonitorNearestPoint(match_rect.CenterPoint());
83 }
84
85 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/screen_ash.cc ('k') | ui/gfx/screen_gtk.cc » ('j') | ui/gfx/screen_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698