Remove WebKitTestRunner::setClientWindowRect.
[chromium-blink-merge.git] / ui / gfx / screen.h
blob1d36d1b51cbefb9bff481219a7bddb6596b6875c
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.
5 #ifndef UI_GFX_SCREEN_H_
6 #define UI_GFX_SCREEN_H_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "ui/gfx/display.h"
12 #include "ui/gfx/gfx_export.h"
13 #include "ui/gfx/native_widget_types.h"
14 #include "ui/gfx/point.h"
15 #include "ui/gfx/screen_type_delegate.h"
17 namespace gfx {
18 class DisplayObserver;
19 class Rect;
21 // A utility class for getting various info about screen size, displays,
22 // cursor position, etc.
24 // Note that this class does not represent an individual display connected to a
25 // computer -- see the Display class for that. A single Screen object exists on
26 // most operating systems regardless of the number of connected displays. On
27 // Windows 8, two Screens exist: one for Metro UI and another for the desktop.
28 class GFX_EXPORT Screen {
29 public:
30 // Retrieves the Screen that the specified NativeView belongs to. A value of
31 // NULL is treated as |SCREEN_TYPE_NATIVE|.
32 static Screen* GetScreenFor(NativeView view);
34 // Returns the SCREEN_TYPE_NATIVE Screen. This should be used with caution,
35 // as it is likely to be incorrect for code that runs on Windows.
36 static Screen* GetNativeScreen();
38 // Sets the global screen for a particular screen type. Only the _NATIVE
39 // ScreenType must be provided.
40 static void SetScreenInstance(ScreenType type, Screen* instance);
42 // Returns the global screen for a particular type. Types other than _NATIVE
43 // may be NULL.
44 static Screen* GetScreenByType(ScreenType type);
46 // Sets the global ScreenTypeDelegate. May be left unset if the platform
47 // uses only the _NATIVE ScreenType.
48 static void SetScreenTypeDelegate(ScreenTypeDelegate* delegate);
50 Screen();
51 virtual ~Screen();
53 // Returns true if DIP is enabled.
54 virtual bool IsDIPEnabled() = 0;
56 // Returns the current absolute position of the mouse pointer.
57 virtual gfx::Point GetCursorScreenPoint() = 0;
59 // Returns the window under the cursor.
60 virtual gfx::NativeWindow GetWindowUnderCursor() = 0;
62 // Returns the window at the given screen coordinate |point|.
63 virtual gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) = 0;
65 // Returns the number of displays.
66 // Mirrored displays are excluded; this method is intended to return the
67 // number of distinct, usable displays.
68 virtual int GetNumDisplays() const = 0;
70 // Returns the list of displays that are currently available.
71 virtual std::vector<gfx::Display> GetAllDisplays() const = 0;
73 // Returns the display nearest the specified window.
74 virtual gfx::Display GetDisplayNearestWindow(NativeView view) const = 0;
76 // Returns the display nearest the specified point.
77 virtual gfx::Display GetDisplayNearestPoint(
78 const gfx::Point& point) const = 0;
80 // Returns the display that most closely intersects the provided bounds.
81 virtual gfx::Display GetDisplayMatching(
82 const gfx::Rect& match_rect) const = 0;
84 // Returns the primary display.
85 virtual gfx::Display GetPrimaryDisplay() const = 0;
87 // Adds/Removes display observers.
88 virtual void AddObserver(DisplayObserver* observer) = 0;
89 virtual void RemoveObserver(DisplayObserver* observer) = 0;
91 private:
92 DISALLOW_COPY_AND_ASSIGN(Screen);
95 Screen* CreateNativeScreen();
97 } // namespace gfx
99 #endif // UI_GFX_SCREEN_H_