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

Side by Side Diff: ui/gfx/screen_aura.cc

Issue 8205018: Gets component build to work with aura. As part of this I needed to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 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
« ui/gfx/screen.h ('K') | « ui/gfx/screen.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ui/gfx/screen.h" 5 #include "ui/gfx/screen.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #endif 9 #endif
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "ui/aura/desktop.h"
13 #include "ui/aura/window.h"
14 #include "ui/gfx/native_widget_types.h" 12 #include "ui/gfx/native_widget_types.h"
15 13
16 namespace {
17
18 gfx::Rect GetMonitorAreaOrWorkAreaNearestPoint(const gfx::Point& point,
19 bool work_area) {
20 // TODO(oshima): Take point/work_area into account. Support multiple monitors.
21 return gfx::Rect(aura::Desktop::GetInstance()->GetSize());
22 }
23
24 } // namespace
25
26 namespace gfx { 14 namespace gfx {
27 15
16 // gfx can't depend upon aura, otherwise we have circular dependencies. So,
17 // gfx::Screen is pluggable for aura and Desktop plugs in the real
18 // implementation.
19
20 // static
21 Screen* Screen::instance_ = NULL;
22
23 // static
24 void Screen::SetInstance(Screen* screen) {
25 delete instance_;
26 instance_ = screen;
27 }
28
28 // static 29 // static
29 gfx::Point Screen::GetCursorScreenPoint() { 30 gfx::Point Screen::GetCursorScreenPoint() {
30 #if defined(OS_WIN) 31 #if defined(OS_WIN)
31 POINT pt; 32 POINT pt;
32 GetCursorPos(&pt); 33 GetCursorPos(&pt);
33 return gfx::Point(pt); 34 return gfx::Point(pt);
34 #endif 35 #endif
35 NOTIMPLEMENTED(); 36 NOTIMPLEMENTED();
36 return gfx::Point(); 37 return gfx::Point();
37 } 38 }
38 39
39 // static 40 // static
40 gfx::Rect Screen::GetMonitorWorkAreaNearestWindow(gfx::NativeWindow window) { 41 gfx::Rect Screen::GetMonitorWorkAreaNearestWindow(gfx::NativeWindow window) {
41 gfx::Rect bounds = GetMonitorAreaNearestWindow(window); 42 DCHECK(instance_);
42 // Emulate that a work area can be smaller than its monitor. 43 return instance_->GetMonitorWorkAreaNearestWindowImpl(window);
43 bounds.Inset(10, 10, 10, 10);
44 return bounds;
45 } 44 }
46 45
47 // static 46 // static
48 gfx::Rect Screen::GetMonitorAreaNearestWindow(gfx::NativeWindow window) { 47 gfx::Rect Screen::GetMonitorAreaNearestWindow(gfx::NativeWindow window) {
49 // TODO(oshima): Take point/work_area into account. Support multiple monitors. 48 DCHECK(instance_);
50 return gfx::Rect(aura::Desktop::GetInstance()->GetSize()); 49 return instance_->GetMonitorAreaNearestWindowImpl(window);
51 } 50 }
52 51
53 // static 52 // static
54 gfx::Rect Screen::GetMonitorWorkAreaNearestPoint(const gfx::Point& point) { 53 gfx::Rect Screen::GetMonitorWorkAreaNearestPoint(const gfx::Point& point) {
55 return GetMonitorAreaOrWorkAreaNearestPoint(point, true); 54 DCHECK(instance_);
55 return instance_->GetMonitorWorkAreaNearestPointImpl(point);
56 } 56 }
57 57
58 // static 58 // static
59 gfx::Rect Screen::GetMonitorAreaNearestPoint(const gfx::Point& point) { 59 gfx::Rect Screen::GetMonitorAreaNearestPoint(const gfx::Point& point) {
60 return GetMonitorAreaOrWorkAreaNearestPoint(point, false); 60 DCHECK(instance_);
61 return instance_->GetMonitorAreaNearestPointImpl(point);
61 } 62 }
62 63
63 gfx::NativeWindow Screen::GetWindowAtCursorScreenPoint() { 64 gfx::NativeWindow Screen::GetWindowAtCursorScreenPoint() {
64 NOTIMPLEMENTED(); 65 DCHECK(instance_);
65 return NULL; 66 return instance_->GetWindowAtCursorScreenPointImpl();
66 } 67 }
67 68
68 } // namespace gfx 69 } // namespace gfx
OLDNEW
« ui/gfx/screen.h ('K') | « ui/gfx/screen.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698