Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Side by Side Diff: ui/views/widget/desktop_aura/desktop_native_cursor_manager.cc

Issue 12263050: Rework ash::CursorManager into a corewm object, to share code with desktop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to ToT Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 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.
4
5 #include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h"
6
7 #include "ui/aura/root_window.h"
8 #include "ui/base/cursor/cursor_loader.h"
9
10 namespace views {
11
12 DesktopNativeCursorManager::DesktopNativeCursorManager(
13 aura::RootWindow* window)
14 : root_window_(window),
15 cursor_loader_(ui::CursorLoader::Create()) {
16 }
17
18 DesktopNativeCursorManager::~DesktopNativeCursorManager() {
19 }
20
21 void DesktopNativeCursorManager::SetDeviceScaleFactor(
22 float device_scale_factor,
23 views::corewm::NativeCursorManagerDelegate* delegate) {
24 cursor_loader_->UnloadAll();
25 cursor_loader_->set_device_scale_factor(device_scale_factor);
26 SetCursor(delegate->GetCurrentCursor(), delegate);
27 }
28
29 void DesktopNativeCursorManager::SetCursor(
30 gfx::NativeCursor cursor,
31 views::corewm::NativeCursorManagerDelegate* delegate) {
32 gfx::NativeCursor new_cursor = cursor;
33 cursor_loader_->SetPlatformCursor(&new_cursor);
34 delegate->CommitCursor(new_cursor);
35
36 if (delegate->GetCurrentVisibility())
37 root_window_->SetCursor(new_cursor);
38 }
39
40 void DesktopNativeCursorManager::SetVisibility(
41 bool visible,
42 views::corewm::NativeCursorManagerDelegate* delegate) {
43 delegate->CommitVisibility(visible);
44
45 if (visible) {
46 SetCursor(delegate->GetCurrentCursor(), delegate);
47 } else {
48 gfx::NativeCursor invisible_cursor(ui::kCursorNone);
49 cursor_loader_->SetPlatformCursor(&invisible_cursor);
50 root_window_->SetCursor(invisible_cursor);
51 }
52
53 root_window_->OnCursorVisibilityChanged(visible);
54 }
55
56 void DesktopNativeCursorManager::SetMouseEventsEnabled(
57 bool enabled,
58 views::corewm::NativeCursorManagerDelegate* delegate) {
59 delegate->CommitMouseEventsEnabled(enabled);
60
61 // TODO(erg): In the ash version, we set the last mouse location on Env. I'm
62 // not sure this concept makes sense on the desktop.
63
64 SetVisibility(delegate->GetCurrentVisibility(), delegate);
65
66 root_window_->OnMouseEventsEnableStateChanged(enabled);
67 }
68
69 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698