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

Unified Diff: ui/views/widget/desktop_aura/desktop_native_cursor_manager.cc

Issue 100173003: Cursor state should be global among all root windows for desktop Aura (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make DesktopNativeCursorManager a WindowObserver 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..443ea428c57b79e695bd7d8ecb08d3224303f378 100644
--- a/ui/views/widget/desktop_aura/desktop_native_cursor_manager.cc
+++ b/ui/views/widget/desktop_aura/desktop_native_cursor_manager.cc
@@ -4,12 +4,17 @@
#include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h"
+#include "ui/aura/client/cursor_client.h"
#include "ui/aura/root_window.h"
+#include "ui/aura/window.h"
#include "ui/base/cursor/cursor_loader.h"
#include "ui/views/widget/desktop_aura/desktop_cursor_loader_updater.h"
namespace views {
+DesktopNativeCursorManager::RootWindows*
+ DesktopNativeCursorManager::root_windows_ = new std::set<aura::RootWindow*>;
+
DesktopNativeCursorManager::DesktopNativeCursorManager(
aura::RootWindow* window,
scoped_ptr<DesktopCursorLoaderUpdater> cursor_loader_updater)
@@ -18,9 +23,12 @@ DesktopNativeCursorManager::DesktopNativeCursorManager(
cursor_loader_(ui::CursorLoader::Create()) {
if (cursor_loader_updater_.get())
cursor_loader_updater_->OnCreate(root_window_, cursor_loader_.get());
+ window->window()->AddObserver(this);
+ root_windows_->insert(window);
}
DesktopNativeCursorManager::~DesktopNativeCursorManager() {
+ Shutdown();
}
gfx::NativeCursor DesktopNativeCursorManager::GetInitializedCursor(int type) {
@@ -29,6 +37,21 @@ gfx::NativeCursor DesktopNativeCursorManager::GetInitializedCursor(int type) {
return cursor;
}
+void DesktopNativeCursorManager::OnWindowDestroyed(aura::Window* window) {
+ DCHECK_EQ(window, root_window_->window());
+ Shutdown();
+}
+
+void DesktopNativeCursorManager::Shutdown() {
+ if (!root_window_)
+ return;
+
+ root_window_->window()->RemoveObserver(this);
+ root_windows_->erase(root_window_);
+ aura::client::SetCursorClient(root_window_->window(), NULL);
+ root_window_ = NULL;
+}
+
void DesktopNativeCursorManager::SetDisplay(
const gfx::Display& display,
views::corewm::NativeCursorManagerDelegate* delegate) {
@@ -48,8 +71,14 @@ void DesktopNativeCursorManager::SetCursor(
cursor_loader_->SetPlatformCursor(&new_cursor);
delegate->CommitCursor(new_cursor);
- if (delegate->GetCurrentVisibility())
- root_window_->SetCursor(new_cursor);
+ if (delegate->GetCurrentVisibility()) {
+ 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(
@@ -62,10 +91,20 @@ void DesktopNativeCursorManager::SetVisibility(
} 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(
@@ -90,7 +129,12 @@ void DesktopNativeCursorManager::SetMouseEventsEnabled(
SetVisibility(delegate->GetCurrentVisibility(), 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