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

Unified Diff: ash/wm/ash_native_cursor_manager.cc

Issue 2932563002: Implement cursor changing on Mushrome (Closed)
Patch Set: oshima patch take 2 Created 3 years, 6 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
« no previous file with comments | « ash/wm/ash_native_cursor_manager.h ('k') | ash/wm/ash_native_cursor_manager_interactive_uitest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/ash_native_cursor_manager.cc
diff --git a/ash/wm/ash_native_cursor_manager.cc b/ash/wm/ash_native_cursor_manager.cc
deleted file mode 100644
index 45a3ef82f59b4d8ffeabbd7e72ab466b331897da..0000000000000000000000000000000000000000
--- a/ash/wm/ash_native_cursor_manager.cc
+++ /dev/null
@@ -1,162 +0,0 @@
-// 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 "ash/wm/ash_native_cursor_manager.h"
-
-#include "ash/display/cursor_window_controller.h"
-#include "ash/display/window_tree_host_manager.h"
-#include "ash/shell.h"
-#include "base/logging.h"
-#include "ui/aura/env.h"
-#include "ui/aura/window_event_dispatcher.h"
-#include "ui/aura/window_tree_host.h"
-#include "ui/base/cursor/cursor.h"
-#include "ui/base/cursor/image_cursors.h"
-#include "ui/base/layout.h"
-
-namespace ash {
-namespace {
-
-void SetCursorOnAllRootWindows(gfx::NativeCursor cursor) {
- aura::Window::Windows root_windows = Shell::Get()->GetAllRootWindows();
- for (aura::Window::Windows::iterator iter = root_windows.begin();
- iter != root_windows.end(); ++iter)
- (*iter)->GetHost()->SetCursor(cursor);
-
- Shell::Get()
- ->window_tree_host_manager()
- ->cursor_window_controller()
- ->SetCursor(cursor);
-}
-
-void NotifyCursorVisibilityChange(bool visible) {
- aura::Window::Windows root_windows = Shell::Get()->GetAllRootWindows();
- for (aura::Window::Windows::iterator iter = root_windows.begin();
- iter != root_windows.end(); ++iter)
- (*iter)->GetHost()->OnCursorVisibilityChanged(visible);
-
- Shell::Get()
- ->window_tree_host_manager()
- ->cursor_window_controller()
- ->SetVisibility(visible);
-}
-
-void NotifyMouseEventsEnableStateChange(bool enabled) {
- aura::Window::Windows root_windows = Shell::Get()->GetAllRootWindows();
- for (aura::Window::Windows::iterator iter = root_windows.begin();
- iter != root_windows.end(); ++iter)
- (*iter)->GetHost()->dispatcher()->OnMouseEventsEnableStateChanged(enabled);
- // Mirror window never process events.
-}
-
-} // namespace
-
-AshNativeCursorManager::AshNativeCursorManager()
- : native_cursor_enabled_(true), image_cursors_(new ui::ImageCursors) {}
-
-AshNativeCursorManager::~AshNativeCursorManager() {}
-
-void AshNativeCursorManager::SetNativeCursorEnabled(bool enabled) {
- native_cursor_enabled_ = enabled;
-
- ::wm::CursorManager* cursor_manager = Shell::Get()->cursor_manager();
- SetCursor(cursor_manager->GetCursor(), cursor_manager);
-}
-
-void AshNativeCursorManager::SetDisplay(
- const display::Display& display,
- ::wm::NativeCursorManagerDelegate* delegate) {
- DCHECK(display.is_valid());
- // Use the platform's device scale factor instead of the display's, which
- // might have been adjusted for the UI scale.
- const float original_scale = Shell::Get()
- ->display_manager()
- ->GetDisplayInfo(display.id())
- .device_scale_factor();
- // And use the nearest resource scale factor.
- const float cursor_scale =
- ui::GetScaleForScaleFactor(ui::GetSupportedScaleFactor(original_scale));
-
- if (image_cursors_->SetDisplay(display, cursor_scale))
- SetCursor(delegate->GetCursor(), delegate);
-
- Shell::Get()
- ->window_tree_host_manager()
- ->cursor_window_controller()
- ->SetDisplay(display);
-}
-
-void AshNativeCursorManager::SetCursor(
- gfx::NativeCursor cursor,
- ::wm::NativeCursorManagerDelegate* delegate) {
- if (native_cursor_enabled_) {
- image_cursors_->SetPlatformCursor(&cursor);
- } else {
- gfx::NativeCursor invisible_cursor(ui::CursorType::kNone);
- image_cursors_->SetPlatformCursor(&invisible_cursor);
- if (cursor == ui::CursorType::kCustom) {
- // Fall back to the default pointer cursor for now. (crbug.com/476078)
- // TODO(oshima): support custom cursor.
- cursor = ui::CursorType::kPointer;
- } else {
- cursor.SetPlatformCursor(invisible_cursor.platform());
- }
- }
- cursor.set_device_scale_factor(image_cursors_->GetScale());
-
- delegate->CommitCursor(cursor);
-
- if (delegate->IsCursorVisible())
- SetCursorOnAllRootWindows(cursor);
-}
-
-void AshNativeCursorManager::SetCursorSet(
- ui::CursorSetType cursor_set,
- ::wm::NativeCursorManagerDelegate* delegate) {
- image_cursors_->SetCursorSet(cursor_set);
- delegate->CommitCursorSet(cursor_set);
-
- // Sets the cursor to reflect the scale change immediately.
- if (delegate->IsCursorVisible())
- SetCursor(delegate->GetCursor(), delegate);
-
- Shell::Get()
- ->window_tree_host_manager()
- ->cursor_window_controller()
- ->SetCursorSet(cursor_set);
-}
-
-void AshNativeCursorManager::SetVisibility(
- bool visible,
- ::wm::NativeCursorManagerDelegate* delegate) {
- delegate->CommitVisibility(visible);
-
- if (visible) {
- SetCursor(delegate->GetCursor(), delegate);
- } else {
- gfx::NativeCursor invisible_cursor(ui::CursorType::kNone);
- image_cursors_->SetPlatformCursor(&invisible_cursor);
- SetCursorOnAllRootWindows(invisible_cursor);
- }
-
- NotifyCursorVisibilityChange(visible);
-}
-
-void AshNativeCursorManager::SetMouseEventsEnabled(
- bool enabled,
- ::wm::NativeCursorManagerDelegate* delegate) {
- delegate->CommitMouseEventsEnabled(enabled);
-
- if (enabled) {
- aura::Env::GetInstance()->set_last_mouse_location(
- disabled_cursor_location_);
- } else {
- disabled_cursor_location_ = aura::Env::GetInstance()->last_mouse_location();
- }
-
- SetVisibility(delegate->IsCursorVisible(), delegate);
- NotifyMouseEventsEnableStateChange(enabled);
-}
-
-} // namespace ash
« no previous file with comments | « ash/wm/ash_native_cursor_manager.h ('k') | ash/wm/ash_native_cursor_manager_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698