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

Unified 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: Test added 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 side-by-side diff with in-line comments
Download patch
Index: ui/views/widget/desktop_aura/desktop_native_cursor_manager.cc
diff --git a/ui/views/widget/desktop_aura/desktop_native_cursor_manager.cc b/ui/views/widget/desktop_aura/desktop_native_cursor_manager.cc
index eed97f32af54167d7e59bd1919331523bd15e62f..cc85b116f0d8eb0dfce04c30b0a40c91cf0a0cf7 100644
--- a/ui/views/widget/desktop_aura/desktop_native_cursor_manager.cc
+++ b/ui/views/widget/desktop_aura/desktop_native_cursor_manager.cc
@@ -11,13 +11,11 @@
namespace views {
DesktopNativeCursorManager::DesktopNativeCursorManager(
- aura::RootWindow* window,
scoped_ptr<DesktopCursorLoaderUpdater> cursor_loader_updater)
- : root_window_(window),
- cursor_loader_updater_(cursor_loader_updater.Pass()),
+ : cursor_loader_updater_(cursor_loader_updater.Pass()),
cursor_loader_(ui::CursorLoader::Create()) {
if (cursor_loader_updater_.get())
- cursor_loader_updater_->OnCreate(root_window_, cursor_loader_.get());
+ cursor_loader_updater_->OnCreate(1.0f, cursor_loader_.get());
}
DesktopNativeCursorManager::~DesktopNativeCursorManager() {
@@ -29,6 +27,15 @@ gfx::NativeCursor DesktopNativeCursorManager::GetInitializedCursor(int type) {
return cursor;
}
+void DesktopNativeCursorManager::AddRootWindow(aura::RootWindow* root_window) {
+ root_windows_.insert(root_window);
+}
+
+void DesktopNativeCursorManager::RemoveRootWindow(
+ aura::RootWindow* root_window) {
+ root_windows_.erase(root_window);
+}
+
void DesktopNativeCursorManager::SetDisplay(
const gfx::Display& display,
views::corewm::NativeCursorManagerDelegate* delegate) {
@@ -38,7 +45,7 @@ void DesktopNativeCursorManager::SetDisplay(
if (cursor_loader_updater_.get())
cursor_loader_updater_->OnDisplayUpdated(display, cursor_loader_.get());
- SetCursor(delegate->GetCurrentCursor(), delegate);
+ SetCursor(delegate->GetCursor(), delegate);
}
void DesktopNativeCursorManager::SetCursor(
@@ -48,8 +55,14 @@ void DesktopNativeCursorManager::SetCursor(
cursor_loader_->SetPlatformCursor(&new_cursor);
delegate->CommitCursor(new_cursor);
- if (delegate->GetCurrentVisibility())
- root_window_->SetCursor(new_cursor);
+ if (delegate->IsCursorVisible()) {
+ RootWindows root_windows(root_windows_);
+ for (RootWindows::const_iterator i = root_windows.begin();
+ i != root_windows.end();
+ ++i) {
+ (*i)->SetCursor(new_cursor);
+ }
+ }
}
void DesktopNativeCursorManager::SetVisibility(
@@ -58,14 +71,24 @@ void DesktopNativeCursorManager::SetVisibility(
delegate->CommitVisibility(visible);
if (visible) {
- SetCursor(delegate->GetCurrentCursor(), delegate);
+ SetCursor(delegate->GetCursor(), delegate);
} else {
gfx::NativeCursor invisible_cursor(ui::kCursorNone);
cursor_loader_->SetPlatformCursor(&invisible_cursor);
- root_window_->SetCursor(invisible_cursor);
+ RootWindows root_windows(root_windows_);
+ for (RootWindows::const_iterator i = root_windows.begin();
+ i != root_windows.end();
+ ++i) {
+ (*i)->SetCursor(invisible_cursor);
+ }
}
- root_window_->OnCursorVisibilityChanged(visible);
+ RootWindows root_windows(root_windows_);
+ for (RootWindows::const_iterator i = root_windows.begin();
+ i != root_windows.end();
+ ++i) {
+ (*i)->OnCursorVisibilityChanged(visible);
+ }
}
void DesktopNativeCursorManager::SetCursorSet(
@@ -88,9 +111,14 @@ void DesktopNativeCursorManager::SetMouseEventsEnabled(
// TODO(erg): In the ash version, we set the last mouse location on Env. I'm
// not sure this concept makes sense on the desktop.
- SetVisibility(delegate->GetCurrentVisibility(), delegate);
+ SetVisibility(delegate->IsCursorVisible(), delegate);
- root_window_->OnMouseEventsEnableStateChanged(enabled);
+ RootWindows root_windows(root_windows_);
+ for (RootWindows::const_iterator i = root_windows.begin();
+ i != root_windows.end();
+ ++i) {
+ (*i)->OnMouseEventsEnableStateChanged(enabled);
+ }
}
} // namespace views

Powered by Google App Engine
This is Rietveld 408576698