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

Side by Side Diff: components/exo/pointer.cc

Issue 2355953003: exo: Fix crash in SetCursor (Closed)
Patch Set: Created 4 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 | 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/exo/pointer.h" 5 #include "components/exo/pointer.h"
6 6
7 #include "ash/common/shell_window_ids.h" 7 #include "ash/common/shell_window_ids.h"
8 #include "ash/display/display_manager.h" 8 #include "ash/display/display_manager.h"
9 #include "components/exo/pointer_delegate.h" 9 #include "components/exo/pointer_delegate.h"
10 #include "components/exo/pointer_stylus_delegate.h" 10 #include "components/exo/pointer_stylus_delegate.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 auto* helper = WMHelper::GetInstance(); 65 auto* helper = WMHelper::GetInstance();
66 helper->RemoveCursorObserver(this); 66 helper->RemoveCursorObserver(this);
67 helper->RemovePreTargetHandler(this); 67 helper->RemovePreTargetHandler(this);
68 } 68 }
69 69
70 void Pointer::SetCursor(Surface* surface, const gfx::Point& hotspot) { 70 void Pointer::SetCursor(Surface* surface, const gfx::Point& hotspot) {
71 // Early out if the pointer doesn't have a surface in focus. 71 // Early out if the pointer doesn't have a surface in focus.
72 if (!focus_) 72 if (!focus_)
73 return; 73 return;
74 74
75 if (!widget_)
76 CreatePointerWidget();
77
75 // If surface is different than the current pointer surface then remove the 78 // If surface is different than the current pointer surface then remove the
76 // current surface and add the new surface. 79 // current surface and add the new surface.
77 if (surface != surface_) { 80 if (surface != surface_) {
78 if (surface && surface->HasSurfaceDelegate()) { 81 if (surface && surface->HasSurfaceDelegate()) {
79 DLOG(ERROR) << "Surface has already been assigned a role"; 82 DLOG(ERROR) << "Surface has already been assigned a role";
80 return; 83 return;
81 } 84 }
82 if (surface_) { 85 if (surface_) {
83 widget_->GetNativeWindow()->RemoveChild(surface_->window()); 86 widget_->GetNativeWindow()->RemoveChild(surface_->window());
84 surface_->window()->Hide(); 87 surface_->window()->Hide();
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 365
363 if (ui_scale != cursor_scale_) { 366 if (ui_scale != cursor_scale_) {
364 gfx::Transform transform; 367 gfx::Transform transform;
365 transform.Scale(ui_scale, ui_scale); 368 transform.Scale(ui_scale, ui_scale);
366 widget_->GetNativeWindow()->SetTransform(transform); 369 widget_->GetNativeWindow()->SetTransform(transform);
367 cursor_scale_ = ui_scale; 370 cursor_scale_ = ui_scale;
368 } 371 }
369 } 372 }
370 373
371 } // namespace exo 374 } // namespace exo
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698