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

Side by Side Diff: ash/wm/ash_native_cursor_manager.cc

Issue 258893002: app_shell: Add support for mouse cursors. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: move an include Created 6 years, 8 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 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 "ash/wm/ash_native_cursor_manager.h" 5 #include "ash/wm/ash_native_cursor_manager.h"
6 6
7 #include "ash/display/cursor_window_controller.h" 7 #include "ash/display/cursor_window_controller.h"
8 #include "ash/display/display_controller.h" 8 #include "ash/display/display_controller.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/wm/image_cursors.h"
11 #include "base/logging.h" 10 #include "base/logging.h"
12 #include "ui/aura/env.h" 11 #include "ui/aura/env.h"
13 #include "ui/aura/window_event_dispatcher.h" 12 #include "ui/aura/window_event_dispatcher.h"
14 #include "ui/aura/window_tree_host.h" 13 #include "ui/aura/window_tree_host.h"
15 #include "ui/base/cursor/cursor.h" 14 #include "ui/base/cursor/cursor.h"
15 #include "ui/base/cursor/image_cursors.h"
16 16
17 namespace ash { 17 namespace ash {
18 namespace { 18 namespace {
19 19
20 void SetCursorOnAllRootWindows(gfx::NativeCursor cursor) { 20 void SetCursorOnAllRootWindows(gfx::NativeCursor cursor) {
21 aura::Window::Windows root_windows = 21 aura::Window::Windows root_windows =
22 Shell::GetInstance()->GetAllRootWindows(); 22 Shell::GetInstance()->GetAllRootWindows();
23 for (aura::Window::Windows::iterator iter = root_windows.begin(); 23 for (aura::Window::Windows::iterator iter = root_windows.begin();
24 iter != root_windows.end(); ++iter) 24 iter != root_windows.end(); ++iter)
25 (*iter)->GetHost()->SetCursor(cursor); 25 (*iter)->GetHost()->SetCursor(cursor);
(...skipping 21 matching lines...) Expand all
47 for (aura::Window::Windows::iterator iter = root_windows.begin(); 47 for (aura::Window::Windows::iterator iter = root_windows.begin();
48 iter != root_windows.end(); ++iter) 48 iter != root_windows.end(); ++iter)
49 (*iter)->GetHost()->dispatcher()->OnMouseEventsEnableStateChanged(enabled); 49 (*iter)->GetHost()->dispatcher()->OnMouseEventsEnableStateChanged(enabled);
50 // Mirror window never process events. 50 // Mirror window never process events.
51 } 51 }
52 52
53 } // namespace 53 } // namespace
54 54
55 AshNativeCursorManager::AshNativeCursorManager() 55 AshNativeCursorManager::AshNativeCursorManager()
56 : native_cursor_enabled_(true), 56 : native_cursor_enabled_(true),
57 image_cursors_(new ImageCursors) { 57 image_cursors_(new ui::ImageCursors) {
58 } 58 }
59 59
60 AshNativeCursorManager::~AshNativeCursorManager() { 60 AshNativeCursorManager::~AshNativeCursorManager() {
61 } 61 }
62 62
63 63
64 void AshNativeCursorManager::SetNativeCursorEnabled(bool enabled) { 64 void AshNativeCursorManager::SetNativeCursorEnabled(bool enabled) {
65 native_cursor_enabled_ = enabled; 65 native_cursor_enabled_ = enabled;
66 66
67 ::wm::CursorManager* cursor_manager = 67 ::wm::CursorManager* cursor_manager =
68 Shell::GetInstance()->cursor_manager(); 68 Shell::GetInstance()->cursor_manager();
69 SetCursor(cursor_manager->GetCursor(), cursor_manager); 69 SetCursor(cursor_manager->GetCursor(), cursor_manager);
70 } 70 }
71 71
72 void AshNativeCursorManager::SetDisplay( 72 void AshNativeCursorManager::SetDisplay(
73 const gfx::Display& display, 73 const gfx::Display& display,
74 ::wm::NativeCursorManagerDelegate* delegate) { 74 ::wm::NativeCursorManagerDelegate* delegate) {
75 if (image_cursors_->SetDisplay(display)) 75 DCHECK(display.is_valid());
76 // Use the platform's device scale factor instead of the display's, which
77 // might have been adjusted for the UI scale.
78 const float scale_factor = Shell::GetInstance()->display_manager()->
79 GetDisplayInfo(display.id()).device_scale_factor();
80 if (image_cursors_->SetDisplay(display, scale_factor))
76 SetCursor(delegate->GetCursor(), delegate); 81 SetCursor(delegate->GetCursor(), delegate);
77 #if defined(OS_CHROMEOS) 82 #if defined(OS_CHROMEOS)
78 Shell::GetInstance()->display_controller()->cursor_window_controller()-> 83 Shell::GetInstance()->display_controller()->cursor_window_controller()->
79 SetDisplay(display); 84 SetDisplay(display);
80 #endif 85 #endif
81 } 86 }
82 87
83 void AshNativeCursorManager::SetCursor( 88 void AshNativeCursorManager::SetCursor(
84 gfx::NativeCursor cursor, 89 gfx::NativeCursor cursor,
85 ::wm::NativeCursorManagerDelegate* delegate) { 90 ::wm::NativeCursorManagerDelegate* delegate) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 disabled_cursor_location_); 150 disabled_cursor_location_);
146 } else { 151 } else {
147 disabled_cursor_location_ = aura::Env::GetInstance()->last_mouse_location(); 152 disabled_cursor_location_ = aura::Env::GetInstance()->last_mouse_location();
148 } 153 }
149 154
150 SetVisibility(delegate->IsCursorVisible(), delegate); 155 SetVisibility(delegate->IsCursorVisible(), delegate);
151 NotifyMouseEventsEnableStateChange(enabled); 156 NotifyMouseEventsEnableStateChange(enabled);
152 } 157 }
153 158
154 } // namespace ash 159 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698