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

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: 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
« no previous file with comments | « ui/gfx/monitor_unittest.cc ('k') | ui/gfx/screen_android.cc » ('j') | 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) 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/monitor.h"
10 #include "ui/gfx/point.h" 11 #include "ui/gfx/point.h"
11 #include "ui/gfx/rect.h"
12 #include "ui/gfx/size.h"
13 12
14 namespace gfx { 13 namespace gfx {
14 class Rect;
15 class ScreenImpl;
15 16
16 // A utility class for getting various info about screen size, monitors, 17 // A utility class for getting various info about screen size, monitors,
17 // cursor position, etc. 18 // cursor position, etc.
18 // TODO(erikkay) add more of those methods here
19 class UI_EXPORT Screen { 19 class UI_EXPORT Screen {
20 public: 20 public:
21 virtual ~Screen() {} 21 virtual ~Screen() {}
22 22
23 #if defined(USE_ASH) 23 #if defined(USE_AURA)
24 // Sets the instance to use. This takes owernship of |screen|, deleting the 24 // 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 25 // old instance. This is used on aura to avoid circular dependencies between
26 // ui and aura. 26 // ui and aura.
27 static void SetInstance(Screen* screen); 27 static void SetInstance(ScreenImpl* screen);
28 #endif 28 #endif
29 29
30 // Returns the current absolute position of the mouse pointer. 30 // Returns the current absolute position of the mouse pointer.
31 static gfx::Point GetCursorScreenPoint(); 31 static gfx::Point GetCursorScreenPoint();
32 32
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. 33 // Returns the window under the cursor.
58 static gfx::NativeWindow GetWindowAtCursorScreenPoint(); 34 static gfx::NativeWindow GetWindowAtCursorScreenPoint();
59 35
60 // Returns the dimensions of the primary monitor in pixels.
61 static gfx::Size GetPrimaryMonitorSize();
62
63 // Returns the number of monitors. 36 // Returns the number of monitors.
64 // Mirrored displays are excluded; this method is intended to return the 37 // Mirrored displays are excluded; this method is intended to return the
65 // number of distinct, usable displays. 38 // number of distinct, usable displays.
66 static int GetNumMonitors(); 39 static int GetNumMonitors();
67 40
68 protected: 41 // Returns the monitor nearest the specified window.
69 virtual gfx::Point GetCursorScreenPointImpl() = 0; 42 static gfx::Monitor GetMonitorNearestWindow(gfx::NativeView view);
70 virtual gfx::Rect GetMonitorWorkAreaNearestWindowImpl(
71 gfx::NativeView view) = 0;
72 virtual gfx::Rect GetMonitorAreaNearestWindowImpl(
73 gfx::NativeView view) = 0;
74 virtual gfx::Rect GetMonitorWorkAreaNearestPointImpl(
75 const gfx::Point& point) = 0;
76 virtual gfx::Rect GetMonitorAreaNearestPointImpl(const gfx::Point& point) = 0;
77 virtual gfx::NativeWindow GetWindowAtCursorScreenPointImpl() = 0;
78 virtual gfx::Size GetPrimaryMonitorSizeImpl() = 0;
79 virtual int GetNumMonitorsImpl() = 0;
80 43
81 private: 44 // Returns the the monitor nearest the specified point.
82 #if defined(USE_AURA) 45 static gfx::Monitor GetMonitorNearestPoint(const gfx::Point& point);
83 // The singleton screen instance. Only used on aura. 46
84 static Screen* instance_; 47 // Returns the bounds of the work area of the primary monitor.
85 #endif 48 static gfx::Monitor GetPrimaryMonitor();
49
50 // Returns the monitor that most closely intersects the provided bounds.
51 static gfx::Monitor GetMonitorMatching(const gfx::Rect& match_rect);
86 }; 52 };
87 53
88 } // namespace gfx 54 } // namespace gfx
89 55
90 #endif // VIEWS_SCREEN_H_ 56 #endif // VIEWS_SCREEN_H_
OLDNEW
« no previous file with comments | « ui/gfx/monitor_unittest.cc ('k') | ui/gfx/screen_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698