forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathash_window_tree_host_mirroring_unified.cc
79 lines (65 loc) · 2.87 KB
/
ash_window_tree_host_mirroring_unified.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
// Copyright 2017 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 "ash/host/ash_window_tree_host_mirroring_unified.h"
#include "ash/host/ash_window_tree_host_mirroring_delegate.h"
#include "ui/gfx/geometry/point3_f.h"
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/transform.h"
#include "ui/platform_window/platform_window_init_properties.h"
namespace ash {
AshWindowTreeHostMirroringUnified::AshWindowTreeHostMirroringUnified(
const gfx::Rect& initial_bounds,
int64_t mirroring_display_id,
AshWindowTreeHostMirroringDelegate* delegate)
: AshWindowTreeHostPlatform(
ui::PlatformWindowInitProperties{initial_bounds}),
mirroring_display_id_(mirroring_display_id),
delegate_(delegate) {
DCHECK(delegate_);
}
AshWindowTreeHostMirroringUnified::~AshWindowTreeHostMirroringUnified() =
default;
gfx::Transform
AshWindowTreeHostMirroringUnified::GetRootTransformForLocalEventCoordinates()
const {
gfx::Transform trans = GetRootTransform();
if (!is_shutting_down_) {
const auto* display =
delegate_->GetMirroringDisplayById(mirroring_display_id_);
DCHECK(display);
// Undo the translation in the root window transform, since this transform
// should be applied on local points to this host.
trans.Translate(SkIntToScalar(display->bounds().x()),
SkIntToScalar(display->bounds().y()));
}
return trans;
}
void AshWindowTreeHostMirroringUnified::ConvertDIPToPixels(
gfx::Point* point) const {
auto point_3f = gfx::Point3F(gfx::PointF(*point));
// GetRootTransform() returns a transform that takes a point from the
// *unified* host coordinates to the *mirroring* host's pixel coordinates.
// ConvertDIPToPixels() and ConvertDIPToScreenInPixels() are called on local
// points in the *mirroring* host's root window, not on points in the unified
// host's. That's why we use the GetRootTransformForLocalEventCoordinates()
// defined above, which only scales those local points to the right size, and
// leaves the translation to be done by the MirroringScreenPositionClient
// functions.
GetRootTransformForLocalEventCoordinates().TransformPoint(&point_3f);
*point = gfx::ToFlooredPoint(point_3f.AsPointF());
}
void AshWindowTreeHostMirroringUnified::ConvertPixelsToDIP(
gfx::Point* point) const {
auto point_3f = gfx::Point3F(gfx::PointF(*point));
GetInverseRootTransformForLocalEventCoordinates().TransformPoint(&point_3f);
*point = gfx::ToFlooredPoint(point_3f.AsPointF());
}
void AshWindowTreeHostMirroringUnified::PrepareForShutdown() {
is_shutting_down_ = true;
AshWindowTreeHostPlatform::PrepareForShutdown();
}
void AshWindowTreeHostMirroringUnified::OnMouseEnter() {
// No logical display change in unified desktop mode,so do nothing.
}
} // namespace ash