forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscreen_ozone.cc
92 lines (70 loc) · 2.61 KB
/
screen_ozone.cc
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
80
81
82
83
84
85
86
87
88
89
90
91
92
// Copyright 2018 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.
#include "ui/aura/screen_ozone.h"
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
namespace aura {
ScreenOzone::ScreenOzone(std::unique_ptr<ui::PlatformScreen> platform_screen)
: platform_screen_(std::move(platform_screen)) {}
ScreenOzone::~ScreenOzone() = default;
gfx::Point ScreenOzone::GetCursorScreenPoint() {
return platform_screen_->GetCursorScreenPoint();
}
bool ScreenOzone::IsWindowUnderCursor(gfx::NativeWindow window) {
return GetWindowAtScreenPoint(GetCursorScreenPoint()) == window;
}
gfx::NativeWindow ScreenOzone::GetWindowAtScreenPoint(const gfx::Point& point) {
auto widget = platform_screen_->GetAcceleratedWidgetAtScreenPoint(point);
if (!widget)
return nullptr;
aura::WindowTreeHost* host =
aura::WindowTreeHost::GetForAcceleratedWidget(widget);
return host ? host->window() : nullptr;
}
int ScreenOzone::GetNumDisplays() const {
return GetAllDisplays().size();
}
const std::vector<display::Display>& ScreenOzone::GetAllDisplays() const {
return platform_screen_->GetAllDisplays();
}
display::Display ScreenOzone::GetDisplayNearestWindow(
gfx::NativeWindow window) const {
gfx::AcceleratedWidget widget = GetAcceleratedWidgetForWindow(window);
if (!widget)
return GetPrimaryDisplay();
return platform_screen_->GetDisplayForAcceleratedWidget(widget);
}
display::Display ScreenOzone::GetDisplayNearestView(
gfx::NativeView view) const {
return GetDisplayNearestWindow(view);
}
display::Display ScreenOzone::GetDisplayNearestPoint(
const gfx::Point& point) const {
return platform_screen_->GetDisplayNearestPoint(point);
}
display::Display ScreenOzone::GetDisplayMatching(
const gfx::Rect& match_rect) const {
return platform_screen_->GetDisplayMatching(match_rect);
}
display::Display ScreenOzone::GetPrimaryDisplay() const {
return platform_screen_->GetPrimaryDisplay();
}
void ScreenOzone::AddObserver(display::DisplayObserver* observer) {
platform_screen_->AddObserver(observer);
}
void ScreenOzone::RemoveObserver(display::DisplayObserver* observer) {
platform_screen_->RemoveObserver(observer);
}
gfx::AcceleratedWidget ScreenOzone::GetAcceleratedWidgetForWindow(
aura::Window* window) const {
if (!window)
return gfx::kNullAcceleratedWidget;
aura::WindowTreeHost* host = window->GetHost();
if (!host)
return gfx::kNullAcceleratedWidget;
return host->GetAcceleratedWidget();
}
} // namespace aura