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

Side by Side Diff: ash/display/cursor_window_controller.cc

Issue 980453002: ash::CursorWindowController: handle ui::kCursorNone (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Need to check |cursor_window_| Created 5 years, 9 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 | « ash/display/cursor_window_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/display/cursor_window_controller.h" 5 #include "ash/display/cursor_window_controller.h"
6 6
7 #include "ash/display/display_controller.h" 7 #include "ash/display/display_controller.h"
8 #include "ash/display/mirror_window_controller.h" 8 #include "ash/display/mirror_window_controller.h"
9 #include "ash/root_window_controller.h" 9 #include "ash/root_window_controller.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 gfx::ImageSkia cursor_image_; 86 gfx::ImageSkia cursor_image_;
87 gfx::Size size_; 87 gfx::Size size_;
88 88
89 DISALLOW_COPY_AND_ASSIGN(CursorWindowDelegate); 89 DISALLOW_COPY_AND_ASSIGN(CursorWindowDelegate);
90 }; 90 };
91 91
92 CursorWindowController::CursorWindowController() 92 CursorWindowController::CursorWindowController()
93 : is_cursor_compositing_enabled_(false), 93 : is_cursor_compositing_enabled_(false),
94 container_(NULL), 94 container_(NULL),
95 cursor_type_(ui::kCursorNone), 95 cursor_type_(ui::kCursorNone),
96 visible_(true),
96 cursor_set_(ui::CURSOR_SET_NORMAL), 97 cursor_set_(ui::CURSOR_SET_NORMAL),
97 cursor_rotation_(gfx::Display::ROTATE_0), 98 cursor_rotation_(gfx::Display::ROTATE_0),
98 delegate_(new CursorWindowDelegate()) { 99 delegate_(new CursorWindowDelegate()) {
99 } 100 }
100 101
101 CursorWindowController::~CursorWindowController() { 102 CursorWindowController::~CursorWindowController() {
102 SetContainer(NULL); 103 SetContainer(NULL);
103 } 104 }
104 105
105 void CursorWindowController::SetCursorCompositingEnabled(bool enabled) { 106 void CursorWindowController::SetCursorCompositingEnabled(bool enabled) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 cursor_window_->SetBounds(bounds); 163 cursor_window_->SetBounds(bounds);
163 } 164 }
164 165
165 void CursorWindowController::SetCursor(gfx::NativeCursor cursor) { 166 void CursorWindowController::SetCursor(gfx::NativeCursor cursor) {
166 if (cursor_type_ == cursor.native_type() && 167 if (cursor_type_ == cursor.native_type() &&
167 cursor_rotation_ == display_.rotation()) 168 cursor_rotation_ == display_.rotation())
168 return; 169 return;
169 cursor_type_ = cursor.native_type(); 170 cursor_type_ = cursor.native_type();
170 cursor_rotation_ = display_.rotation(); 171 cursor_rotation_ = display_.rotation();
171 UpdateCursorImage(); 172 UpdateCursorImage();
173 UpdateCursorVisibility();
172 } 174 }
173 175
174 void CursorWindowController::SetCursorSet(ui::CursorSetType cursor_set) { 176 void CursorWindowController::SetCursorSet(ui::CursorSetType cursor_set) {
175 cursor_set_ = cursor_set; 177 cursor_set_ = cursor_set;
176 UpdateCursorImage(); 178 UpdateCursorImage();
177 } 179 }
178 180
179 void CursorWindowController::SetVisibility(bool visible) { 181 void CursorWindowController::SetVisibility(bool visible) {
180 if (!cursor_window_) 182 if (!cursor_window_)
181 return; 183 return;
182 if (visible) 184 visible_ = visible;
183 cursor_window_->Show(); 185 UpdateCursorVisibility();
184 else
185 cursor_window_->Hide();
186 } 186 }
187 187
188 void CursorWindowController::SetContainer(aura::Window* container) { 188 void CursorWindowController::SetContainer(aura::Window* container) {
189 if (container_ == container) 189 if (container_ == container)
190 return; 190 return;
191 container_ = container; 191 container_ = container;
192 if (!container) { 192 if (!container) {
193 cursor_window_.reset(); 193 cursor_window_.reset();
194 return; 194 return;
195 } 195 }
196 196
197 // Reusing the window does not work when the display is disconnected. 197 // Reusing the window does not work when the display is disconnected.
198 // Just creates a new one instead. crbug.com/384218. 198 // Just creates a new one instead. crbug.com/384218.
199 cursor_window_.reset(new aura::Window(delegate_.get())); 199 cursor_window_.reset(new aura::Window(delegate_.get()));
200 cursor_window_->SetTransparent(true); 200 cursor_window_->SetTransparent(true);
201 cursor_window_->Init(aura::WINDOW_LAYER_TEXTURED); 201 cursor_window_->Init(aura::WINDOW_LAYER_TEXTURED);
202 cursor_window_->set_ignore_events(true); 202 cursor_window_->set_ignore_events(true);
203 cursor_window_->set_owned_by_parent(false); 203 cursor_window_->set_owned_by_parent(false);
204 UpdateCursorImage(); 204 UpdateCursorImage();
205 205
206 container->AddChild(cursor_window_.get()); 206 container->AddChild(cursor_window_.get());
207 cursor_window_->Show(); 207 UpdateCursorVisibility();
208 SetBoundsInScreen(container->bounds()); 208 SetBoundsInScreen(container->bounds());
209 } 209 }
210 210
211 void CursorWindowController::SetBoundsInScreen(const gfx::Rect& bounds) { 211 void CursorWindowController::SetBoundsInScreen(const gfx::Rect& bounds) {
212 bounds_in_screen_ = bounds; 212 bounds_in_screen_ = bounds;
213 UpdateLocation(); 213 UpdateLocation();
214 } 214 }
215 215
216 void CursorWindowController::UpdateCursorImage() { 216 void CursorWindowController::UpdateCursorImage() {
217 int resource_id; 217 int resource_id;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 } 258 }
259 delegate_->SetCursorImage(rotated, display_); 259 delegate_->SetCursorImage(rotated, display_);
260 if (cursor_window_) { 260 if (cursor_window_) {
261 cursor_window_->SetBounds(gfx::Rect(delegate_->size())); 261 cursor_window_->SetBounds(gfx::Rect(delegate_->size()));
262 cursor_window_->SchedulePaintInRect( 262 cursor_window_->SchedulePaintInRect(
263 gfx::Rect(cursor_window_->bounds().size())); 263 gfx::Rect(cursor_window_->bounds().size()));
264 UpdateLocation(); 264 UpdateLocation();
265 } 265 }
266 } 266 }
267 267
268 void CursorWindowController::UpdateCursorVisibility() {
269 if (!cursor_window_)
270 return;
271 bool visible = (visible_ && cursor_type_ != ui::kCursorNone);
272 if (visible)
273 cursor_window_->Show();
274 else
275 cursor_window_->Hide();
276 }
277
268 } // namespace ash 278 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/cursor_window_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698