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

Side by Side Diff: ui/gfx/screen.h

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 #ifndef UI_GFX_SCREEN_H_ 5 #ifndef UI_GFX_SCREEN_H_
6 #define UI_GFX_SCREEN_H_ 6 #define UI_GFX_SCREEN_H_
7 #pragma once 7 #pragma once
8 8
9 #include "ui/gfx/native_widget_types.h" 9 #include "ui/gfx/native_widget_types.h"
10 #include "ui/gfx/point.h" 10 #include "ui/gfx/point.h"
11 #include "ui/gfx/rect.h" 11 #include "ui/gfx/rect.h"
12 #include "ui/gfx/size.h" 12 #include "ui/gfx/size.h"
13 13
14 namespace gfx { 14 namespace gfx {
15 15
16 class Monitor;
17 class MonitorObserver;
18 class ScreenImpl;
19
16 // A utility class for getting various info about screen size, monitors, 20 // A utility class for getting various info about screen size, monitors,
17 // cursor position, etc. 21 // cursor position, etc. The monitor object returned by Screen's method
18 // TODO(erikkay) add more of those methods here 22 // is valid only until the next |GetMonitorXXX| method is called.
23 // TODO(oshima): Implment monitor observers on other platforms and
24 // remove above restruction.
19 class UI_EXPORT Screen { 25 class UI_EXPORT Screen {
20 public: 26 public:
21 virtual ~Screen() {} 27 virtual ~Screen() {}
22 28
23 #if defined(USE_ASH) 29 #if defined(USE_AURA)
24 // Sets the instance to use. This takes owernship of |screen|, deleting the 30 // Sets the instance to use. This takes owernship of |screen|, deleting the
25 // old instance. This is used on aura to avoid circular dependencies between 31 // old instance. This is used on aura to avoid circular dependencies between
26 // ui and aura. 32 // ui and aura.
27 static void SetInstance(Screen* screen); 33 static void SetInstance(ScreenImpl* screen);
28 #endif 34 #endif
29 35
36 static void AddMonitorObserver(MonitorObserver* observer);
37 static void RemoveMonitorObserver(MonitorObserver* observer);
38
30 // Returns the current absolute position of the mouse pointer. 39 // Returns the current absolute position of the mouse pointer.
31 static gfx::Point GetCursorScreenPoint(); 40 static gfx::Point GetCursorScreenPoint();
32 41
33 // Returns the work area of the monitor nearest the specified window.
34 static gfx::Rect GetMonitorWorkAreaNearestWindow(gfx::NativeView view);
35
36 // Returns the bounds of the monitor nearest the specified window.
37 static gfx::Rect GetMonitorAreaNearestWindow(gfx::NativeView view);
38
39 // Returns the work area of the monitor nearest the specified point.
40 static gfx::Rect GetMonitorWorkAreaNearestPoint(const gfx::Point& point);
41
42 // Returns the monitor area (not the work area, but the complete bounds) of
43 // the monitor nearest the specified point.
44 static gfx::Rect GetMonitorAreaNearestPoint(const gfx::Point& point);
45
46 // Returns the bounds of the work area of the primary monitor.
47 static gfx::Rect GetPrimaryMonitorWorkArea();
48
49 // Returns the bounds of the primary monitor.
50 static gfx::Rect GetPrimaryMonitorBounds();
51
52 // Returns the bounds of the work area of the monitor that most closely
53 // intersects the provided bounds.
54 static gfx::Rect GetMonitorWorkAreaMatching(
55 const gfx::Rect& match_rect);
56
57 // Returns the window under the cursor. 42 // Returns the window under the cursor.
58 static gfx::NativeWindow GetWindowAtCursorScreenPoint(); 43 static gfx::NativeWindow GetWindowAtCursorScreenPoint();
59 44
60 // Returns the dimensions of the primary monitor in pixels.
61 static gfx::Size GetPrimaryMonitorSize();
62
63 // Returns the number of monitors. 45 // Returns the number of monitors.
64 // Mirrored displays are excluded; this method is intended to return the 46 // Mirrored displays are excluded; this method is intended to return the
65 // number of distinct, usable displays. 47 // number of distinct, usable displays.
66 static int GetNumMonitors(); 48 static int GetNumMonitors();
67 49
68 protected: 50 // Returns the monitor nearest the specified window. See the comment at the
69 virtual gfx::Point GetCursorScreenPointImpl() = 0; 51 // top regarding the life sycle of |gfx::Monitor| object.
70 virtual gfx::Rect GetMonitorWorkAreaNearestWindowImpl( 52 static const gfx::Monitor* GetMonitorNearestWindow(gfx::NativeView view);
53
54 // Returns the the monitor nearest the specified point. See the comment at the
55 // top regarding the life sycle of |gfx::Monitor| object.
56 static const gfx::Monitor* GetMonitorNearestPoint(const gfx::Point& point);
57
58 // Returns the bounds of the work area of the primary monitor. See
59 // the comment at the top regarding the life sycle of |gfx::Monitor|
60 // object.
61 static const gfx::Monitor* GetPrimaryMonitor();
62
63 // Returns the monitor that most closely intersects the provided bounds. See
64 // the comment at the top regarding the life sycle of |gfx::Monitor|
65 // object.
66 static const gfx::Monitor* GetMonitorMatching(const gfx::Rect& match_rect);
67
68 // Utility functions to get Monitor bounds/WorkArea bounds.
69 static gfx::Rect GetMonitorAreaNearestWindow(gfx::NativeView view);
70 static gfx::Rect GetMonitorWorkAreaNearestWindow(gfx::NativeView view);
71 static gfx::Rect GetMonitorAreaNearestPoint(const gfx::Point& point);
72 static gfx::Rect GetMonitorWorkAreaNearestPoint(const gfx::Point& point);
73 };
74
75 #if defined(USE_AURA)
76 // A class that provides |gfx::Screen|'s implementation on aura.
Ben Goodger (Google) 2012/04/10 16:37:20 yes please move to a separate file. note that you
oshima 2012/04/10 21:31:46 Done.
77 class UI_EXPORT ScreenImpl {
78 public:
79 virtual ~ScreenImpl();
80
81 virtual gfx::Point GetCursorScreenPoint() = 0;
82 virtual gfx::NativeWindow GetWindowAtCursorScreenPoint() = 0;
83
84 virtual int GetNumMonitors() = 0;
85 virtual const gfx::Monitor* GetMonitorNearestWindow(
71 gfx::NativeView view) = 0; 86 gfx::NativeView view) = 0;
72 virtual gfx::Rect GetMonitorAreaNearestWindowImpl( 87 virtual const gfx::Monitor* GetMonitorNearestPoint(
73 gfx::NativeView view) = 0;
74 virtual gfx::Rect GetMonitorWorkAreaNearestPointImpl(
75 const gfx::Point& point) = 0; 88 const gfx::Point& point) = 0;
76 virtual gfx::Rect GetMonitorAreaNearestPointImpl(const gfx::Point& point) = 0; 89 virtual const gfx::Monitor* GetPrimaryMonitor() = 0;
77 virtual gfx::NativeWindow GetWindowAtCursorScreenPointImpl() = 0;
78 virtual gfx::Size GetPrimaryMonitorSizeImpl() = 0;
79 virtual int GetNumMonitorsImpl() = 0;
80 90
81 private: 91 virtual void AddMonitorObserver(MonitorObserver* observer) = 0;
82 #if defined(USE_AURA) 92 virtual void RemoveMonitorObserver(MonitorObserver* observer) = 0;
83 // The singleton screen instance. Only used on aura. 93 };
84 static Screen* instance_;
85 #endif 94 #endif
86 };
87 95
88 } // namespace gfx 96 } // namespace gfx
89 97
90 #endif // VIEWS_SCREEN_H_ 98 #endif // VIEWS_SCREEN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698