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

Unified 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 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
new file mode 100644
index 0000000000000000000000000000000000000000..8482feb81c71d0f7b61958f51e444d4724f51025
--- /dev/null
+++ b/ui/views/widget/desktop_aura/desktop_native_cursor_manager.cc
@@ -0,0 +1,69 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h"
+
+#include "ui/aura/root_window.h"
+#include "ui/base/cursor/cursor_loader.h"
+
+namespace views {
+
+DesktopNativeCursorManager::DesktopNativeCursorManager(
+ aura::RootWindow* window)
+ : root_window_(window),
+ cursor_loader_(ui::CursorLoader::Create()) {
+}
+
+DesktopNativeCursorManager::~DesktopNativeCursorManager() {
+}
+
+void DesktopNativeCursorManager::SetDeviceScaleFactor(
+ float device_scale_factor,
+ views::corewm::NativeCursorManagerDelegate* delegate) {
+ cursor_loader_->UnloadAll();
+ cursor_loader_->set_device_scale_factor(device_scale_factor);
+ SetCursor(delegate->GetCurrentCursor(), delegate);
+}
+
+void DesktopNativeCursorManager::SetCursor(
+ gfx::NativeCursor cursor,
+ views::corewm::NativeCursorManagerDelegate* delegate) {
+ gfx::NativeCursor new_cursor = cursor;
+ cursor_loader_->SetPlatformCursor(&new_cursor);
+ delegate->CommitCursor(new_cursor);
+
+ if (delegate->GetCurrentVisibility())
+ root_window_->SetCursor(new_cursor);
+}
+
+void DesktopNativeCursorManager::SetVisibility(
+ bool visible,
+ views::corewm::NativeCursorManagerDelegate* delegate) {
+ delegate->CommitVisibility(visible);
+
+ if (visible) {
+ SetCursor(delegate->GetCurrentCursor(), delegate);
+ } else {
+ gfx::NativeCursor invisible_cursor(ui::kCursorNone);
+ cursor_loader_->SetPlatformCursor(&invisible_cursor);
+ root_window_->SetCursor(invisible_cursor);
+ }
+
+ root_window_->OnCursorVisibilityChanged(visible);
+}
+
+void DesktopNativeCursorManager::SetMouseEventsEnabled(
+ bool enabled,
+ views::corewm::NativeCursorManagerDelegate* delegate) {
+ delegate->CommitMouseEventsEnabled(enabled);
+
+ // 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);
+
+ root_window_->OnMouseEventsEnableStateChanged(enabled);
+}
+
+} // namespace views

Powered by Google App Engine
This is Rietveld 408576698