1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/events/ozone/chromeos/cursor_controller.h"
11 void TransformCursorMove(gfx::Display::Rotation rotation
,
13 gfx::Vector2dF
* delta
) {
18 case gfx::Display::ROTATE_90
:
22 case gfx::Display::ROTATE_180
:
26 case gfx::Display::ROTATE_270
:
30 default: // gfx::Display::ROTATE_0
36 delta
->set_x(dx
* scale
);
37 delta
->set_y(dy
* scale
);
43 CursorController
* CursorController::GetInstance() {
44 return Singleton
<CursorController
>::get();
47 void CursorController::SetCursorConfigForWindow(gfx::AcceleratedWidget widget
,
48 gfx::Display::Rotation rotation
,
50 base::AutoLock
lock(window_to_cursor_configuration_map_lock_
);
51 PerWindowCursorConfiguration config
= {rotation
, scale
};
52 window_to_cursor_configuration_map_
[widget
] = config
;
55 void CursorController::ClearCursorConfigForWindow(
56 gfx::AcceleratedWidget widget
) {
57 window_to_cursor_configuration_map_
.erase(widget
);
60 void CursorController::ApplyCursorConfigForWindow(gfx::AcceleratedWidget widget
,
61 gfx::Vector2dF
* delta
) const {
62 base::AutoLock
lock(window_to_cursor_configuration_map_lock_
);
63 auto it
= window_to_cursor_configuration_map_
.find(widget
);
64 if (it
!= window_to_cursor_configuration_map_
.end())
65 TransformCursorMove(it
->second
.rotation
, it
->second
.scale
, delta
);
68 CursorController::CursorController() {
71 CursorController::~CursorController() {