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

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

Issue 2295513002: exo: Hide cursor for direct input (Closed)
Patch Set: adding all the files does help. sometimes. 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 | « components/exo/pointer.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 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/display/display_info.h" 7 #include "ash/common/display/display_info.h"
8 #include "ash/common/shell_window_ids.h" 8 #include "ash/common/shell_window_ids.h"
9 #include "ash/display/display_manager.h" 9 #include "ash/display/display_manager.h"
10 #include "components/exo/pointer_delegate.h" 10 #include "components/exo/pointer_delegate.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // Update hotspot and show cursor surface if not already visible. 96 // Update hotspot and show cursor surface if not already visible.
97 hotspot_ = hotspot; 97 hotspot_ = hotspot;
98 if (surface_) { 98 if (surface_) {
99 surface_->window()->SetBounds( 99 surface_->window()->SetBounds(
100 gfx::Rect(gfx::Point() - hotspot_.OffsetFromOrigin(), 100 gfx::Rect(gfx::Point() - hotspot_.OffsetFromOrigin(),
101 surface_->window()->layer()->size())); 101 surface_->window()->layer()->size()));
102 if (!surface_->window()->IsVisible()) 102 if (!surface_->window()->IsVisible())
103 surface_->window()->Show(); 103 surface_->window()->Show();
104 104
105 // Show widget now that cursor has been defined. 105 // Show widget now that cursor has been defined.
106 if (!widget_->IsVisible()) 106 if (!widget_->IsVisible() && !is_direct_input_)
107 widget_->Show(); 107 widget_->Show();
108 } 108 }
109 109
110 // Register pointer as cursor provider now that the cursor for |focus_| has 110 // Register pointer as cursor provider now that the cursor for |focus_| has
111 // been defined. 111 // been defined.
112 focus_->RegisterCursorProvider(this); 112 focus_->RegisterCursorProvider(this);
113 113
114 // Update cursor in case the registration of pointer as cursor provider 114 // Update cursor in case the registration of pointer as cursor provider
115 // caused the cursor to change. 115 // caused the cursor to change.
116 aura::client::CursorClient* cursor_client = 116 aura::client::CursorClient* cursor_client =
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 break; 244 break;
245 case ui::ET_MOUSE_ENTERED: 245 case ui::ET_MOUSE_ENTERED:
246 case ui::ET_MOUSE_EXITED: 246 case ui::ET_MOUSE_EXITED:
247 case ui::ET_MOUSE_CAPTURE_CHANGED: 247 case ui::ET_MOUSE_CAPTURE_CHANGED:
248 break; 248 break;
249 default: 249 default:
250 NOTREACHED(); 250 NOTREACHED();
251 break; 251 break;
252 } 252 }
253 253
254 if (focus_ && (event->flags() & ui::EF_IS_SYNTHESIZED) == 0)
255 is_direct_input_ = (event->flags() & ui::EF_DIRECT_INPUT) != 0;
reveman 2016/08/30 00:40:49 should we really take "focus_" into account here?
denniskempin 2016/08/30 00:47:25 I removed the check for focus_, but we do need th
reveman 2016/08/30 00:49:43 Got it. Makes sense.
256
254 // Update cursor widget to reflect current focus and pointer location. 257 // Update cursor widget to reflect current focus and pointer location.
255 if (focus_) { 258 if (focus_ && !is_direct_input_) {
256 if (!widget_) 259 if (!widget_)
257 CreatePointerWidget(); 260 CreatePointerWidget();
258 261
259 // Update cursor location if mouse event caused it to change. 262 // Update cursor location if mouse event caused it to change.
260 gfx::Point mouse_location = aura::Env::GetInstance()->last_mouse_location(); 263 gfx::Point mouse_location = aura::Env::GetInstance()->last_mouse_location();
261 gfx::Rect bounds = widget_->GetWindowBoundsInScreen(); 264 gfx::Rect bounds = widget_->GetWindowBoundsInScreen();
262 if (mouse_location != bounds.origin()) { 265 if (mouse_location != bounds.origin()) {
263 bounds.set_origin(mouse_location); 266 bounds.set_origin(mouse_location);
264 widget_->SetBounds(bounds); 267 widget_->SetBounds(bounds);
265 } 268 }
269 if (!widget_->IsVisible())
270 widget_->Show();
reveman 2016/08/30 00:40:49 nit: move below UpdateCursorScale() as better to s
denniskempin 2016/08/30 00:47:25 Done.
266 271
267 UpdateCursorScale(); 272 UpdateCursorScale();
268 } else { 273 } else {
269 if (widget_ && widget_->IsVisible()) 274 if (widget_ && widget_->IsVisible())
270 widget_->Hide(); 275 widget_->Hide();
271 } 276 }
272 } 277 }
273 278
274 void Pointer::OnScrollEvent(ui::ScrollEvent* event) { 279 void Pointer::OnScrollEvent(ui::ScrollEvent* event) {
275 OnMouseEvent(event); 280 OnMouseEvent(event);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 357
353 if (ui_scale != cursor_scale_) { 358 if (ui_scale != cursor_scale_) {
354 gfx::Transform transform; 359 gfx::Transform transform;
355 transform.Scale(ui_scale, ui_scale); 360 transform.Scale(ui_scale, ui_scale);
356 widget_->GetNativeWindow()->SetTransform(transform); 361 widget_->GetNativeWindow()->SetTransform(transform);
357 cursor_scale_ = ui_scale; 362 cursor_scale_ = ui_scale;
358 } 363 }
359 } 364 }
360 365
361 } // namespace exo 366 } // namespace exo
OLDNEW
« no previous file with comments | « components/exo/pointer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698