summaryrefslogtreecommitdiffstats
path: root/ui/gfx/screen.h
blob: bf9a8f4e17c94137b4c43b8a6daae0b8b5e8a109 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_GFX_SCREEN_H_
#define UI_GFX_SCREEN_H_

#include "base/basictypes.h"
#include "ui/base/ui_export.h"
#include "ui/gfx/display.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/point.h"

namespace gfx {
class Rect;
class ScreenImpl;

// A utility class for getting various info about screen size, displays,
// cursor position, etc.
class UI_EXPORT Screen {
 public:
#if defined(USE_AURA)
  // Sets the instance to use. This takes owernship of |screen|, deleting the
  // old instance. This is used on aura to avoid circular dependencies between
  // ui and aura.
  static void SetInstance(ScreenImpl* screen);
#endif

  // Returns true if DIP is enabled.
  static bool IsDIPEnabled();

  // Returns the current absolute position of the mouse pointer.
  static gfx::Point GetCursorScreenPoint();

  // Returns the window under the cursor.
  static gfx::NativeWindow GetWindowAtCursorScreenPoint();

  // Returns the number of displays.
  // Mirrored displays are excluded; this method is intended to return the
  // number of distinct, usable displays.
  static int GetNumDisplays();

  // Returns the display nearest the specified window.
  static gfx::Display GetDisplayNearestWindow(gfx::NativeView view);

  // Returns the the display nearest the specified point.
  static gfx::Display GetDisplayNearestPoint(const gfx::Point& point);

  // Returns the display that most closely intersects the provided bounds.
  static gfx::Display GetDisplayMatching(const gfx::Rect& match_rect);

  // Returns the primary display.
  static gfx::Display GetPrimaryDisplay();

 private:
  DISALLOW_IMPLICIT_CONSTRUCTORS(Screen);
};

}  // namespace gfx

#endif  // UI_GFX_SCREEN_H_