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

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

Issue 2618143002: cros: Remove some OS platform ifdefs from ash (Closed)
Patch Set: rebase Created 3 years, 11 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
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/window_tree_host_manager.h" 8 #include "ash/display/window_tree_host_manager.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 #include "ui/base/layout.h"
17 17
18 namespace ash { 18 namespace ash {
19 namespace { 19 namespace {
20 20
21 void SetCursorOnAllRootWindows(gfx::NativeCursor cursor) { 21 void SetCursorOnAllRootWindows(gfx::NativeCursor cursor) {
22 aura::Window::Windows root_windows = 22 aura::Window::Windows root_windows =
23 Shell::GetInstance()->GetAllRootWindows(); 23 Shell::GetInstance()->GetAllRootWindows();
24 for (aura::Window::Windows::iterator iter = root_windows.begin(); 24 for (aura::Window::Windows::iterator iter = root_windows.begin();
25 iter != root_windows.end(); ++iter) 25 iter != root_windows.end(); ++iter)
26 (*iter)->GetHost()->SetCursor(cursor); 26 (*iter)->GetHost()->SetCursor(cursor);
27 #if defined(OS_CHROMEOS) 27
28 Shell::GetInstance() 28 Shell::GetInstance()
29 ->window_tree_host_manager() 29 ->window_tree_host_manager()
30 ->cursor_window_controller() 30 ->cursor_window_controller()
31 ->SetCursor(cursor); 31 ->SetCursor(cursor);
32 #endif
33 } 32 }
34 33
35 void NotifyCursorVisibilityChange(bool visible) { 34 void NotifyCursorVisibilityChange(bool visible) {
36 aura::Window::Windows root_windows = 35 aura::Window::Windows root_windows =
37 Shell::GetInstance()->GetAllRootWindows(); 36 Shell::GetInstance()->GetAllRootWindows();
38 for (aura::Window::Windows::iterator iter = root_windows.begin(); 37 for (aura::Window::Windows::iterator iter = root_windows.begin();
39 iter != root_windows.end(); ++iter) 38 iter != root_windows.end(); ++iter)
40 (*iter)->GetHost()->OnCursorVisibilityChanged(visible); 39 (*iter)->GetHost()->OnCursorVisibilityChanged(visible);
41 #if defined(OS_CHROMEOS) 40
42 Shell::GetInstance() 41 Shell::GetInstance()
43 ->window_tree_host_manager() 42 ->window_tree_host_manager()
44 ->cursor_window_controller() 43 ->cursor_window_controller()
45 ->SetVisibility(visible); 44 ->SetVisibility(visible);
46 #endif
47 } 45 }
48 46
49 void NotifyMouseEventsEnableStateChange(bool enabled) { 47 void NotifyMouseEventsEnableStateChange(bool enabled) {
50 aura::Window::Windows root_windows = 48 aura::Window::Windows root_windows =
51 Shell::GetInstance()->GetAllRootWindows(); 49 Shell::GetInstance()->GetAllRootWindows();
52 for (aura::Window::Windows::iterator iter = root_windows.begin(); 50 for (aura::Window::Windows::iterator iter = root_windows.begin();
53 iter != root_windows.end(); ++iter) 51 iter != root_windows.end(); ++iter)
54 (*iter)->GetHost()->dispatcher()->OnMouseEventsEnableStateChanged(enabled); 52 (*iter)->GetHost()->dispatcher()->OnMouseEventsEnableStateChanged(enabled);
55 // Mirror window never process events. 53 // Mirror window never process events.
56 } 54 }
(...skipping 15 matching lines...) Expand all
72 void AshNativeCursorManager::SetDisplay( 70 void AshNativeCursorManager::SetDisplay(
73 const display::Display& display, 71 const display::Display& display,
74 ::wm::NativeCursorManagerDelegate* delegate) { 72 ::wm::NativeCursorManagerDelegate* delegate) {
75 DCHECK(display.is_valid()); 73 DCHECK(display.is_valid());
76 // Use the platform's device scale factor instead of the display's, which 74 // Use the platform's device scale factor instead of the display's, which
77 // might have been adjusted for the UI scale. 75 // might have been adjusted for the UI scale.
78 const float original_scale = Shell::GetInstance() 76 const float original_scale = Shell::GetInstance()
79 ->display_manager() 77 ->display_manager()
80 ->GetDisplayInfo(display.id()) 78 ->GetDisplayInfo(display.id())
81 .device_scale_factor(); 79 .device_scale_factor();
82 #if defined(OS_CHROMEOS)
83 // And use the nearest resource scale factor. 80 // And use the nearest resource scale factor.
84 const float cursor_scale = 81 const float cursor_scale =
85 ui::GetScaleForScaleFactor(ui::GetSupportedScaleFactor(original_scale)); 82 ui::GetScaleForScaleFactor(ui::GetSupportedScaleFactor(original_scale));
86 #else 83
87 // TODO(oshima): crbug.com/143619
88 const float cursor_scale = original_scale;
89 #endif
90 if (image_cursors_->SetDisplay(display, cursor_scale)) 84 if (image_cursors_->SetDisplay(display, cursor_scale))
91 SetCursor(delegate->GetCursor(), delegate); 85 SetCursor(delegate->GetCursor(), delegate);
92 #if defined(OS_CHROMEOS) 86
93 Shell::GetInstance() 87 Shell::GetInstance()
94 ->window_tree_host_manager() 88 ->window_tree_host_manager()
95 ->cursor_window_controller() 89 ->cursor_window_controller()
96 ->SetDisplay(display); 90 ->SetDisplay(display);
97 #endif
98 } 91 }
99 92
100 void AshNativeCursorManager::SetCursor( 93 void AshNativeCursorManager::SetCursor(
101 gfx::NativeCursor cursor, 94 gfx::NativeCursor cursor,
102 ::wm::NativeCursorManagerDelegate* delegate) { 95 ::wm::NativeCursorManagerDelegate* delegate) {
103 if (native_cursor_enabled_) { 96 if (native_cursor_enabled_) {
104 image_cursors_->SetPlatformCursor(&cursor); 97 image_cursors_->SetPlatformCursor(&cursor);
105 } else { 98 } else {
106 gfx::NativeCursor invisible_cursor(ui::kCursorNone); 99 gfx::NativeCursor invisible_cursor(ui::kCursorNone);
107 image_cursors_->SetPlatformCursor(&invisible_cursor); 100 image_cursors_->SetPlatformCursor(&invisible_cursor);
(...skipping 16 matching lines...) Expand all
124 void AshNativeCursorManager::SetCursorSet( 117 void AshNativeCursorManager::SetCursorSet(
125 ui::CursorSetType cursor_set, 118 ui::CursorSetType cursor_set,
126 ::wm::NativeCursorManagerDelegate* delegate) { 119 ::wm::NativeCursorManagerDelegate* delegate) {
127 image_cursors_->SetCursorSet(cursor_set); 120 image_cursors_->SetCursorSet(cursor_set);
128 delegate->CommitCursorSet(cursor_set); 121 delegate->CommitCursorSet(cursor_set);
129 122
130 // Sets the cursor to reflect the scale change immediately. 123 // Sets the cursor to reflect the scale change immediately.
131 if (delegate->IsCursorVisible()) 124 if (delegate->IsCursorVisible())
132 SetCursor(delegate->GetCursor(), delegate); 125 SetCursor(delegate->GetCursor(), delegate);
133 126
134 #if defined(OS_CHROMEOS)
135 Shell::GetInstance() 127 Shell::GetInstance()
136 ->window_tree_host_manager() 128 ->window_tree_host_manager()
137 ->cursor_window_controller() 129 ->cursor_window_controller()
138 ->SetCursorSet(cursor_set); 130 ->SetCursorSet(cursor_set);
139 #endif
140 } 131 }
141 132
142 void AshNativeCursorManager::SetVisibility( 133 void AshNativeCursorManager::SetVisibility(
143 bool visible, 134 bool visible,
144 ::wm::NativeCursorManagerDelegate* delegate) { 135 ::wm::NativeCursorManagerDelegate* delegate) {
145 delegate->CommitVisibility(visible); 136 delegate->CommitVisibility(visible);
146 137
147 if (visible) { 138 if (visible) {
148 SetCursor(delegate->GetCursor(), delegate); 139 SetCursor(delegate->GetCursor(), delegate);
149 } else { 140 } else {
(...skipping 15 matching lines...) Expand all
165 disabled_cursor_location_); 156 disabled_cursor_location_);
166 } else { 157 } else {
167 disabled_cursor_location_ = aura::Env::GetInstance()->last_mouse_location(); 158 disabled_cursor_location_ = aura::Env::GetInstance()->last_mouse_location();
168 } 159 }
169 160
170 SetVisibility(delegate->IsCursorVisible(), delegate); 161 SetVisibility(delegate->IsCursorVisible(), delegate);
171 NotifyMouseEventsEnableStateChange(enabled); 162 NotifyMouseEventsEnableStateChange(enabled);
172 } 163 }
173 164
174 } // namespace ash 165 } // namespace ash
OLDNEW
« no previous file with comments | « ash/utility/screenshot_controller_unittest.cc ('k') | ash/wm/immersive_fullscreen_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698