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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/ws/event_dispatcher.cc
diff --git a/services/ui/ws/event_dispatcher.cc b/services/ui/ws/event_dispatcher.cc
index f045ac63d74f2a3b13cfccdd42539eda91bdafc6..24314f9aed707e000f1353ee5e1aab6281278df7 100644
--- a/services/ui/ws/event_dispatcher.cc
+++ b/services/ui/ws/event_dispatcher.cc
@@ -93,9 +93,11 @@ ui::mojom::Cursor EventDispatcher::GetCurrentMouseCursor() const {
if (!mouse_cursor_source_window_)
return ui::mojom::Cursor::POINTER;
- return mouse_cursor_in_non_client_area_
- ? mouse_cursor_source_window_->non_client_cursor()
- : mouse_cursor_source_window_->cursor();
+ if (mouse_cursor_in_non_client_area_)
+ return mouse_cursor_source_window_->non_client_cursor();
+
+ const ServerWindow* window = GetWindowForMouseCursor();
+ return window ? window->cursor() : ui::mojom::Cursor::POINTER;
}
bool EventDispatcher::SetCaptureWindow(ServerWindow* window,
@@ -198,6 +200,22 @@ void EventDispatcher::ReleaseCaptureBlockedByAnyModalWindow() {
SetCaptureWindow(nullptr, kInvalidClientId);
}
+const ServerWindow* EventDispatcher::GetWindowForMouseCursor() const {
+ if (mouse_cursor_in_non_client_area_ || !mouse_cursor_source_window_)
+ return mouse_cursor_source_window_;
+
+ // Return the ancestor (starting at |mouse_cursor_source_window_|) whose
+ // client id differs. In other words, return the first window ancestor that is
+ // an embed root. This is done to match the behavior of aura, which sets the
+ // cursor on the root.
+ const ClientSpecificId target_client_id = delegate_->GetEventTargetClientId(
+ mouse_cursor_source_window_, mouse_cursor_in_non_client_area_);
+ const ServerWindow* window = mouse_cursor_source_window_;
+ while (window && window->id().client_id == target_client_id)
+ window = window->parent();
+ return window;
+}
+
void EventDispatcher::UpdateNonClientAreaForCurrentWindow() {
if (mouse_cursor_source_window_) {
DeepestWindow deepest_window =
« 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