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

Side by Side Diff: services/ui/ws/event_dispatcher.cc

Issue 2680883002: Fixes bugs in cursor handling (Closed)
Patch Set: Created 3 years, 10 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 | « services/ui/ws/event_dispatcher.h ('k') | services/ui/ws/event_dispatcher_delegate.h » ('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 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 "services/ui/ws/event_dispatcher.h" 5 #include "services/ui/ws/event_dispatcher.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 delegate_->OnMouseCursorLocationChanged(screen_location); 86 delegate_->OnMouseCursorLocationChanged(screen_location);
87 } 87 }
88 88
89 ui::mojom::Cursor EventDispatcher::GetCurrentMouseCursor() const { 89 ui::mojom::Cursor EventDispatcher::GetCurrentMouseCursor() const {
90 if (drag_controller_) 90 if (drag_controller_)
91 return drag_controller_->current_cursor(); 91 return drag_controller_->current_cursor();
92 92
93 if (!mouse_cursor_source_window_) 93 if (!mouse_cursor_source_window_)
94 return ui::mojom::Cursor::POINTER; 94 return ui::mojom::Cursor::POINTER;
95 95
96 return mouse_cursor_in_non_client_area_ 96 if (mouse_cursor_in_non_client_area_)
97 ? mouse_cursor_source_window_->non_client_cursor() 97 return mouse_cursor_source_window_->non_client_cursor();
98 : mouse_cursor_source_window_->cursor(); 98
99 const ServerWindow* window = GetWindowForMouseCursor();
100 return window ? window->cursor() : ui::mojom::Cursor::POINTER;
99 } 101 }
100 102
101 bool EventDispatcher::SetCaptureWindow(ServerWindow* window, 103 bool EventDispatcher::SetCaptureWindow(ServerWindow* window,
102 ClientSpecificId client_id) { 104 ClientSpecificId client_id) {
103 if (!window) 105 if (!window)
104 client_id = kInvalidClientId; 106 client_id = kInvalidClientId;
105 107
106 if (window == capture_window_ && client_id == capture_window_client_id_) 108 if (window == capture_window_ && client_id == capture_window_client_id_)
107 return true; 109 return true;
108 110
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 } 193 }
192 194
193 void EventDispatcher::ReleaseCaptureBlockedByAnyModalWindow() { 195 void EventDispatcher::ReleaseCaptureBlockedByAnyModalWindow() {
194 if (!capture_window_) 196 if (!capture_window_)
195 return; 197 return;
196 198
197 if (modal_window_controller_.IsWindowBlocked(capture_window_)) 199 if (modal_window_controller_.IsWindowBlocked(capture_window_))
198 SetCaptureWindow(nullptr, kInvalidClientId); 200 SetCaptureWindow(nullptr, kInvalidClientId);
199 } 201 }
200 202
203 const ServerWindow* EventDispatcher::GetWindowForMouseCursor() const {
204 if (mouse_cursor_in_non_client_area_ || !mouse_cursor_source_window_)
205 return mouse_cursor_source_window_;
206
207 // Return the ancestor (starting at |mouse_cursor_source_window_|) whose
208 // client id differs. In other words, return the first window ancestor that is
209 // an embed root. This is done to match the behavior of aura, which sets the
210 // cursor on the root.
211 const ClientSpecificId target_client_id = delegate_->GetEventTargetClientId(
212 mouse_cursor_source_window_, mouse_cursor_in_non_client_area_);
213 const ServerWindow* window = mouse_cursor_source_window_;
214 while (window && window->id().client_id == target_client_id)
215 window = window->parent();
216 return window;
217 }
218
201 void EventDispatcher::UpdateNonClientAreaForCurrentWindow() { 219 void EventDispatcher::UpdateNonClientAreaForCurrentWindow() {
202 if (mouse_cursor_source_window_) { 220 if (mouse_cursor_source_window_) {
203 DeepestWindow deepest_window = 221 DeepestWindow deepest_window =
204 FindDeepestVisibleWindowForEvents(mouse_pointer_last_location_); 222 FindDeepestVisibleWindowForEvents(mouse_pointer_last_location_);
205 if (deepest_window.window == mouse_cursor_source_window_) { 223 if (deepest_window.window == mouse_cursor_source_window_) {
206 mouse_cursor_in_non_client_area_ = mouse_cursor_source_window_ 224 mouse_cursor_in_non_client_area_ = mouse_cursor_source_window_
207 ? deepest_window.in_non_client_area 225 ? deepest_window.in_non_client_area
208 : false; 226 : false;
209 } 227 }
210 } 228 }
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 if (mouse_cursor_source_window_ == window) 643 if (mouse_cursor_source_window_ == window)
626 mouse_cursor_source_window_ = nullptr; 644 mouse_cursor_source_window_ = nullptr;
627 } 645 }
628 646
629 void EventDispatcher::OnDragCursorUpdated() { 647 void EventDispatcher::OnDragCursorUpdated() {
630 delegate_->UpdateNativeCursorFromDispatcher(); 648 delegate_->UpdateNativeCursorFromDispatcher();
631 } 649 }
632 650
633 } // namespace ws 651 } // namespace ws
634 } // namespace ui 652 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/event_dispatcher.h ('k') | services/ui/ws/event_dispatcher_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698