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

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

Issue 111043002: Cursor state should be global for desktop Aura (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Don't copy set of root windows before iterating Created 7 years 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h" 5 #include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h"
6 6
7 #include "ui/aura/root_window.h" 7 #include "ui/aura/root_window.h"
8 #include "ui/base/cursor/cursor_loader.h" 8 #include "ui/base/cursor/cursor_loader.h"
9 #include "ui/views/widget/desktop_aura/desktop_cursor_loader_updater.h" 9 #include "ui/views/widget/desktop_aura/desktop_cursor_loader_updater.h"
10 10
11 namespace views { 11 namespace views {
12 12
13 DesktopNativeCursorManager::DesktopNativeCursorManager( 13 DesktopNativeCursorManager::DesktopNativeCursorManager(
14 aura::RootWindow* window,
15 scoped_ptr<DesktopCursorLoaderUpdater> cursor_loader_updater) 14 scoped_ptr<DesktopCursorLoaderUpdater> cursor_loader_updater)
16 : root_window_(window), 15 : cursor_loader_updater_(cursor_loader_updater.Pass()),
17 cursor_loader_updater_(cursor_loader_updater.Pass()),
18 cursor_loader_(ui::CursorLoader::Create()) { 16 cursor_loader_(ui::CursorLoader::Create()) {
19 if (cursor_loader_updater_.get()) 17 if (cursor_loader_updater_.get())
20 cursor_loader_updater_->OnCreate(root_window_, cursor_loader_.get()); 18 cursor_loader_updater_->OnCreate(1.0f, cursor_loader_.get());
21 } 19 }
22 20
23 DesktopNativeCursorManager::~DesktopNativeCursorManager() { 21 DesktopNativeCursorManager::~DesktopNativeCursorManager() {
24 } 22 }
25 23
26 gfx::NativeCursor DesktopNativeCursorManager::GetInitializedCursor(int type) { 24 gfx::NativeCursor DesktopNativeCursorManager::GetInitializedCursor(int type) {
27 gfx::NativeCursor cursor(type); 25 gfx::NativeCursor cursor(type);
28 cursor_loader_->SetPlatformCursor(&cursor); 26 cursor_loader_->SetPlatformCursor(&cursor);
29 return cursor; 27 return cursor;
30 } 28 }
31 29
30 void DesktopNativeCursorManager::AddRootWindow(aura::RootWindow* root_window) {
31 root_windows_.insert(root_window);
32 }
33
34 void DesktopNativeCursorManager::RemoveRootWindow(
35 aura::RootWindow* root_window) {
36 root_windows_.erase(root_window);
37 }
38
32 void DesktopNativeCursorManager::SetDisplay( 39 void DesktopNativeCursorManager::SetDisplay(
33 const gfx::Display& display, 40 const gfx::Display& display,
34 views::corewm::NativeCursorManagerDelegate* delegate) { 41 views::corewm::NativeCursorManagerDelegate* delegate) {
35 cursor_loader_->UnloadAll(); 42 cursor_loader_->UnloadAll();
36 cursor_loader_->set_display(display); 43 cursor_loader_->set_display(display);
37 44
38 if (cursor_loader_updater_.get()) 45 if (cursor_loader_updater_.get())
39 cursor_loader_updater_->OnDisplayUpdated(display, cursor_loader_.get()); 46 cursor_loader_updater_->OnDisplayUpdated(display, cursor_loader_.get());
40 47
41 SetCursor(delegate->GetCursor(), delegate); 48 SetCursor(delegate->GetCursor(), delegate);
42 } 49 }
43 50
44 void DesktopNativeCursorManager::SetCursor( 51 void DesktopNativeCursorManager::SetCursor(
45 gfx::NativeCursor cursor, 52 gfx::NativeCursor cursor,
46 views::corewm::NativeCursorManagerDelegate* delegate) { 53 views::corewm::NativeCursorManagerDelegate* delegate) {
47 gfx::NativeCursor new_cursor = cursor; 54 gfx::NativeCursor new_cursor = cursor;
48 cursor_loader_->SetPlatformCursor(&new_cursor); 55 cursor_loader_->SetPlatformCursor(&new_cursor);
49 delegate->CommitCursor(new_cursor); 56 delegate->CommitCursor(new_cursor);
50 57
51 if (delegate->IsCursorVisible()) 58 if (delegate->IsCursorVisible()) {
52 root_window_->SetCursor(new_cursor); 59 for (RootWindows::const_iterator i = root_windows_.begin();
60 i != root_windows_.end();
61 ++i) {
62 (*i)->SetCursor(new_cursor);
63 }
64 }
53 } 65 }
54 66
55 void DesktopNativeCursorManager::SetVisibility( 67 void DesktopNativeCursorManager::SetVisibility(
56 bool visible, 68 bool visible,
57 views::corewm::NativeCursorManagerDelegate* delegate) { 69 views::corewm::NativeCursorManagerDelegate* delegate) {
58 delegate->CommitVisibility(visible); 70 delegate->CommitVisibility(visible);
59 71
60 if (visible) { 72 if (visible) {
61 SetCursor(delegate->GetCursor(), delegate); 73 SetCursor(delegate->GetCursor(), delegate);
62 } else { 74 } else {
63 gfx::NativeCursor invisible_cursor(ui::kCursorNone); 75 gfx::NativeCursor invisible_cursor(ui::kCursorNone);
64 cursor_loader_->SetPlatformCursor(&invisible_cursor); 76 cursor_loader_->SetPlatformCursor(&invisible_cursor);
65 root_window_->SetCursor(invisible_cursor); 77 for (RootWindows::const_iterator i = root_windows_.begin();
78 i != root_windows_.end();
79 ++i) {
80 (*i)->SetCursor(invisible_cursor);
81 }
66 } 82 }
67 83
68 root_window_->OnCursorVisibilityChanged(visible); 84 for (RootWindows::const_iterator i = root_windows_.begin();
85 i != root_windows_.end();
86 ++i) {
87 (*i)->OnCursorVisibilityChanged(visible);
88 }
69 } 89 }
70 90
71 void DesktopNativeCursorManager::SetCursorSet( 91 void DesktopNativeCursorManager::SetCursorSet(
72 ui::CursorSetType cursor_set, 92 ui::CursorSetType cursor_set,
73 views::corewm::NativeCursorManagerDelegate* delegate) { 93 views::corewm::NativeCursorManagerDelegate* delegate) {
74 NOTIMPLEMENTED(); 94 NOTIMPLEMENTED();
75 } 95 }
76 96
77 void DesktopNativeCursorManager::SetScale( 97 void DesktopNativeCursorManager::SetScale(
78 float scale, 98 float scale,
79 views::corewm::NativeCursorManagerDelegate* delegate) { 99 views::corewm::NativeCursorManagerDelegate* delegate) {
80 NOTIMPLEMENTED(); 100 NOTIMPLEMENTED();
81 } 101 }
82 102
83 void DesktopNativeCursorManager::SetMouseEventsEnabled( 103 void DesktopNativeCursorManager::SetMouseEventsEnabled(
84 bool enabled, 104 bool enabled,
85 views::corewm::NativeCursorManagerDelegate* delegate) { 105 views::corewm::NativeCursorManagerDelegate* delegate) {
86 delegate->CommitMouseEventsEnabled(enabled); 106 delegate->CommitMouseEventsEnabled(enabled);
87 107
88 // TODO(erg): In the ash version, we set the last mouse location on Env. I'm 108 // TODO(erg): In the ash version, we set the last mouse location on Env. I'm
89 // not sure this concept makes sense on the desktop. 109 // not sure this concept makes sense on the desktop.
90 110
91 SetVisibility(delegate->IsCursorVisible(), delegate); 111 SetVisibility(delegate->IsCursorVisible(), delegate);
92 112
93 root_window_->OnMouseEventsEnableStateChanged(enabled); 113 for (RootWindows::const_iterator i = root_windows_.begin();
114 i != root_windows_.end();
115 ++i) {
116 (*i)->OnMouseEventsEnableStateChanged(enabled);
117 }
94 } 118 }
95 119
96 } // namespace views 120 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698