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

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

Issue 562003002: Use the resource scale factor for cursor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cros only Created 6 years, 3 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
« no previous file with comments | « no previous file | ash/wm/ash_native_cursor_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/logging.h" 10 #include "base/logging.h"
11 #include "ui/aura/env.h" 11 #include "ui/aura/env.h"
12 #include "ui/aura/window_event_dispatcher.h" 12 #include "ui/aura/window_event_dispatcher.h"
13 #include "ui/aura/window_tree_host.h" 13 #include "ui/aura/window_tree_host.h"
14 #include "ui/base/cursor/cursor.h" 14 #include "ui/base/cursor/cursor.h"
15 #include "ui/base/cursor/image_cursors.h" 15 #include "ui/base/cursor/image_cursors.h"
16 #include "ui/base/layout.h"
16 17
17 namespace ash { 18 namespace ash {
18 namespace { 19 namespace {
19 20
20 void SetCursorOnAllRootWindows(gfx::NativeCursor cursor) { 21 void SetCursorOnAllRootWindows(gfx::NativeCursor cursor) {
21 aura::Window::Windows root_windows = 22 aura::Window::Windows root_windows =
22 Shell::GetInstance()->GetAllRootWindows(); 23 Shell::GetInstance()->GetAllRootWindows();
23 for (aura::Window::Windows::iterator iter = root_windows.begin(); 24 for (aura::Window::Windows::iterator iter = root_windows.begin();
24 iter != root_windows.end(); ++iter) 25 iter != root_windows.end(); ++iter)
25 (*iter)->GetHost()->SetCursor(cursor); 26 (*iter)->GetHost()->SetCursor(cursor);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 Shell::GetInstance()->cursor_manager(); 69 Shell::GetInstance()->cursor_manager();
69 SetCursor(cursor_manager->GetCursor(), cursor_manager); 70 SetCursor(cursor_manager->GetCursor(), cursor_manager);
70 } 71 }
71 72
72 void AshNativeCursorManager::SetDisplay( 73 void AshNativeCursorManager::SetDisplay(
73 const gfx::Display& display, 74 const gfx::Display& display,
74 ::wm::NativeCursorManagerDelegate* delegate) { 75 ::wm::NativeCursorManagerDelegate* delegate) {
75 DCHECK(display.is_valid()); 76 DCHECK(display.is_valid());
76 // Use the platform's device scale factor instead of the display's, which 77 // Use the platform's device scale factor instead of the display's, which
77 // might have been adjusted for the UI scale. 78 // might have been adjusted for the UI scale.
78 const float scale_factor = Shell::GetInstance()->display_manager()-> 79 const float original_scale = Shell::GetInstance()->display_manager()->
79 GetDisplayInfo(display.id()).device_scale_factor(); 80 GetDisplayInfo(display.id()).device_scale_factor();
80 if (image_cursors_->SetDisplay(display, scale_factor)) 81 #if defined(OS_CHROMEOS)
82 // And use the nearest resource scale factor.
83 const float cursor_scale = ui::GetScaleForScaleFactor(
84 ui::GetSupportedScaleFactor(original_scale));
85 #else
86 // TODO(oshima): crbug.com/143619
87 const float cursor_scale = original_scale;
88 #endif
89 if (image_cursors_->SetDisplay(display, cursor_scale))
81 SetCursor(delegate->GetCursor(), delegate); 90 SetCursor(delegate->GetCursor(), delegate);
82 #if defined(OS_CHROMEOS) 91 #if defined(OS_CHROMEOS)
83 Shell::GetInstance()->display_controller()->cursor_window_controller()-> 92 Shell::GetInstance()->display_controller()->cursor_window_controller()->
84 SetDisplay(display); 93 SetDisplay(display);
85 #endif 94 #endif
86 } 95 }
87 96
88 void AshNativeCursorManager::SetCursor( 97 void AshNativeCursorManager::SetCursor(
89 gfx::NativeCursor cursor, 98 gfx::NativeCursor cursor,
90 ::wm::NativeCursorManagerDelegate* delegate) { 99 ::wm::NativeCursorManagerDelegate* delegate) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 disabled_cursor_location_); 158 disabled_cursor_location_);
150 } else { 159 } else {
151 disabled_cursor_location_ = aura::Env::GetInstance()->last_mouse_location(); 160 disabled_cursor_location_ = aura::Env::GetInstance()->last_mouse_location();
152 } 161 }
153 162
154 SetVisibility(delegate->IsCursorVisible(), delegate); 163 SetVisibility(delegate->IsCursorVisible(), delegate);
155 NotifyMouseEventsEnableStateChange(enabled); 164 NotifyMouseEventsEnableStateChange(enabled);
156 } 165 }
157 166
158 } // namespace ash 167 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/wm/ash_native_cursor_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698