forked from kiwibrowser/src
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmouse_location_manager.cc
46 lines (35 loc) · 1.54 KB
/
mouse_location_manager.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
// 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 "ui/aura/mouse_location_manager.h"
#include "ui/gfx/geometry/point.h"
namespace aura {
MouseLocationManager::MouseLocationManager() {}
MouseLocationManager::~MouseLocationManager() {}
void MouseLocationManager::SetMouseLocation(const gfx::Point& point_in_dip) {
current_mouse_location_ = static_cast<base::subtle::Atomic32>(
(point_in_dip.x() & 0xFFFF) << 16 | (point_in_dip.y() & 0xFFFF));
if (mouse_location_memory()) {
base::subtle::NoBarrier_Store(mouse_location_memory(),
current_mouse_location_);
}
}
mojo::ScopedSharedBufferHandle MouseLocationManager::GetMouseLocationMemory() {
if (!mouse_location_handle_.is_valid()) {
// Create our shared memory segment to share the mouse state with our
// window clients.
mouse_location_handle_ =
mojo::SharedBufferHandle::Create(sizeof(base::subtle::Atomic32));
if (!mouse_location_handle_.is_valid())
return mojo::ScopedSharedBufferHandle();
mouse_location_mapping_ =
mouse_location_handle_->Map(sizeof(base::subtle::Atomic32));
if (!mouse_location_mapping_)
return mojo::ScopedSharedBufferHandle();
base::subtle::NoBarrier_Store(mouse_location_memory(),
current_mouse_location_);
}
return mouse_location_handle_->Clone(
mojo::SharedBufferHandle::AccessMode::READ_ONLY);
}
} // namespace aura