Chromium Code Reviews

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

Issue 1964153002: Move Screen, its impls, DisplayObserver and DisplayChangeNotifier to ui/display (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tabs Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « ui/display/mac/screen_mac.mm ('k') | ui/display/screen.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 2016 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_DISPLAY_SCREEN_H_ 5 #ifndef UI_DISPLAY_SCREEN_H_
6 #define UI_DISPLAY_SCREEN_H_ 6 #define UI_DISPLAY_SCREEN_H_
7 7
8 #include "ui/gfx/screen.h" 8 #include <vector>
9
10 #include "base/macros.h"
11 #include "ui/display/display.h"
12 #include "ui/display/display_export.h"
13 #include "ui/gfx/native_widget_types.h"
14
15 namespace gfx {
16 class Display;
17 class Point;
18 class Rect;
19 }
9 20
10 namespace display { 21 namespace display {
22 using Display = gfx::Display;
23 class DisplayObserver;
11 24
12 // TODO(oshima): move the gfx::Screen to display::Screen. 25 // A utility class for getting various info about screen size, displays,
13 using Display = gfx::Display; 26 // cursor position, etc.
14 using DisplayObserver = gfx::DisplayObserver; 27 //
15 using Screen = gfx::Screen; 28 // Note that this class does not represent an individual display connected to a
29 // computer -- see the Display class for that. A single Screen object exists
30 // regardless of the number of connected displays.
31 class DISPLAY_EXPORT Screen {
32 public:
33 Screen();
34 virtual ~Screen();
16 35
17 } // display 36 // Retrieves the single Screen object.
37 static Screen* GetScreen();
38
39 // Sets the global screen. NOTE: this does not take ownership of |screen|.
40 // Tests must be sure to reset any state they install.
41 static void SetScreenInstance(Screen* instance);
42
43 // Returns the current absolute position of the mouse pointer.
44 virtual gfx::Point GetCursorScreenPoint() = 0;
45
46 // Returns true if the cursor is directly over |window|.
47 virtual bool IsWindowUnderCursor(gfx::NativeWindow window) = 0;
48
49 // Returns the window at the given screen coordinate |point|.
50 virtual gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) = 0;
51
52 // Returns the number of displays.
53 // Mirrored displays are excluded; this method is intended to return the
54 // number of distinct, usable displays.
55 virtual int GetNumDisplays() const = 0;
56
57 // Returns the list of displays that are currently available.
58 virtual std::vector<display::Display> GetAllDisplays() const = 0;
59
60 // Returns the display nearest the specified window.
61 // If the window is NULL or the window is not rooted to a display this will
62 // return the primary display.
63 virtual display::Display GetDisplayNearestWindow(
64 gfx::NativeView view) const = 0;
65
66 // Returns the display nearest the specified point. |point| should be in DIPs.
67 virtual display::Display GetDisplayNearestPoint(
68 const gfx::Point& point) const = 0;
69
70 // Returns the display that most closely intersects the provided bounds.
71 virtual display::Display GetDisplayMatching(
72 const gfx::Rect& match_rect) const = 0;
73
74 // Returns the primary display.
75 virtual display::Display GetPrimaryDisplay() const = 0;
76
77 // Adds/Removes display observers.
78 virtual void AddObserver(DisplayObserver* observer) = 0;
79 virtual void RemoveObserver(DisplayObserver* observer) = 0;
80
81 // Converts |screen_rect| to DIP coordinates in the context of |view| clamping
82 // to the enclosing rect if the coordinates do not fall on pixel boundaries.
83 // If |view| is null, the primary display is used as the context.
84 virtual gfx::Rect ScreenToDIPRectInWindow(gfx::NativeView view,
85 const gfx::Rect& screen_rect) const;
86
87 // Converts |dip_rect| to screen coordinates in the context of |view| clamping
88 // to the enclosing rect if the coordinates do not fall on pixel boundaries.
89 // If |view| is null, the primary display is used as the context.
90 virtual gfx::Rect DIPToScreenRectInWindow(gfx::NativeView view,
91 const gfx::Rect& dip_rect) const;
92
93 private:
94 DISALLOW_COPY_AND_ASSIGN(Screen);
95 };
96
97 Screen* CreateNativeScreen();
98
99 } // namespace display
18 100
19 #endif // UI_DISPLAY_SCREEN_H_ 101 #endif // UI_DISPLAY_SCREEN_H_
OLDNEW
« no previous file with comments | « ui/display/mac/screen_mac.mm ('k') | ui/display/screen.cc » ('j') | no next file with comments »

Powered by Google App Engine