blob: 45a15adf3cb4e78e6acefd7593377de16d031377 (
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
// Copyright (c) 2011 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_
#pragma once
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/point.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/size.h"
namespace gfx {
// A utility class for getting various info about screen size, monitors,
// cursor position, etc.
// TODO(erikkay) add more of those methods here
class UI_EXPORT Screen {
public:
virtual ~Screen() {}
#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(Screen* screen);
#endif
// Returns the current absolute position of the mouse pointer.
static gfx::Point GetCursorScreenPoint();
// Returns the work area of the monitor nearest the specified window.
static gfx::Rect GetMonitorWorkAreaNearestWindow(gfx::NativeView view);
// Returns the bounds of the monitor nearest the specified window.
static gfx::Rect GetMonitorAreaNearestWindow(gfx::NativeView view);
// Returns the work area of the monitor nearest the specified point.
static gfx::Rect GetMonitorWorkAreaNearestPoint(const gfx::Point& point);
// Returns the monitor area (not the work area, but the complete bounds) of
// the monitor nearest the specified point.
static gfx::Rect GetMonitorAreaNearestPoint(const gfx::Point& point);
// Returns the window under the cursor.
static gfx::NativeWindow GetWindowAtCursorScreenPoint();
// Returns the dimensions of the primary monitor in pixels.
static gfx::Size GetPrimaryMonitorSize();
// Returns the number of monitors.
// Mirrored displays are excluded; this method is intended to return the
// number of distinct, usable displays.
static int GetNumMonitors();
protected:
virtual gfx::Point GetCursorScreenPointImpl() = 0;
virtual gfx::Rect GetMonitorWorkAreaNearestWindowImpl(
gfx::NativeView view) = 0;
virtual gfx::Rect GetMonitorAreaNearestWindowImpl(
gfx::NativeView view) = 0;
virtual gfx::Rect GetMonitorWorkAreaNearestPointImpl(
const gfx::Point& point) = 0;
virtual gfx::Rect GetMonitorAreaNearestPointImpl(const gfx::Point& point) = 0;
virtual gfx::NativeWindow GetWindowAtCursorScreenPointImpl() = 0;
virtual gfx::Size GetPrimaryMonitorSizeImpl() = 0;
virtual int GetNumMonitorsImpl() = 0;
private:
#if defined(USE_AURA)
// The singleton screen instance. Only used on aura.
static Screen* instance_;
#endif
};
} // namespace gfx
#endif // VIEWS_SCREEN_H_
|