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

Unified Diff: services/ui/ws/event_dispatcher.cc

Issue 2884463002: Make event-targeting asynchronous in window server. (Closed)
Patch Set: rebase Created 3 years, 6 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
Index: services/ui/ws/event_dispatcher.cc
diff --git a/services/ui/ws/event_dispatcher.cc b/services/ui/ws/event_dispatcher.cc
index 8be65049bb4e1bfab45fad7d2c50210667c347bc..0e7eb274bafcbd330bc4584f6defb2e9e31327a6 100644
--- a/services/ui/ws/event_dispatcher.cc
+++ b/services/ui/ws/event_dispatcher.cc
@@ -79,7 +79,7 @@ void EventDispatcher::Reset() {
void EventDispatcher::SetMousePointerDisplayLocation(
const gfx::Point& display_location,
- const int64_t display_id) {
+ int64_t display_id) {
DCHECK(pointer_targets_.empty());
SetMousePointerLocation(display_location, display_id);
UpdateCursorProviderByLastKnownLocation();
@@ -221,34 +221,21 @@ const ServerWindow* EventDispatcher::GetWindowForMouseCursor() const {
void EventDispatcher::UpdateNonClientAreaForCurrentWindow() {
if (mouse_cursor_source_window_) {
- LocationTarget location_target = event_targeter_->FindTargetForLocation(
- mouse_pointer_last_location_, mouse_pointer_display_id_);
- if (location_target.deepest_window.window == mouse_cursor_source_window_) {
- mouse_cursor_in_non_client_area_ =
- mouse_cursor_source_window_
- ? location_target.deepest_window.in_non_client_area
- : false;
- }
- SetMousePointerLocation(location_target.location_in_root,
- location_target.display_id);
+ event_targeter_->FindTargetForLocation(
+ mouse_pointer_last_location_, mouse_pointer_display_id_,
+ base::BindOnce(
+ &EventDispatcher::UpdateNonClientAreaForCurrentWindowOnFoundWindow,
+ base::Unretained(this)));
}
}
void EventDispatcher::UpdateCursorProviderByLastKnownLocation() {
if (!mouse_button_down_) {
- LocationTarget location_target = event_targeter_->FindTargetForLocation(
- mouse_pointer_last_location_, mouse_pointer_display_id_);
- SetMouseCursorSourceWindow(location_target.deepest_window.window);
- if (mouse_cursor_source_window_) {
- mouse_cursor_in_non_client_area_ =
- location_target.deepest_window.in_non_client_area;
- } else {
- SetMouseCursorSourceWindow(delegate_->GetRootWindowContaining(
- &mouse_pointer_last_location_, &mouse_pointer_display_id_));
- mouse_cursor_in_non_client_area_ = true;
- }
- SetMousePointerLocation(location_target.location_in_root,
- location_target.display_id);
+ event_targeter_->FindTargetForLocation(
+ mouse_pointer_last_location_, mouse_pointer_display_id_,
+ base::BindOnce(&EventDispatcher::
+ UpdateCursorProviderByLastKnownLocationOnFoundWindow,
+ base::Unretained(this)));
}
}
@@ -280,8 +267,12 @@ void EventDispatcher::RemoveAccelerator(uint32_t id) {
accelerators_.erase(it);
}
+bool EventDispatcher::IsProcessingEvent() {
+ return event_targeter_->IsHitTestInFlight();
+}
+
void EventDispatcher::ProcessEvent(const ui::Event& event,
- const int64_t display_id,
+ int64_t display_id,
AcceleratorMatchPhase match_phase) {
#if !defined(NDEBUG)
if (match_phase == AcceleratorMatchPhase::POST_ONLY) {
@@ -314,8 +305,10 @@ void EventDispatcher::ProcessEvent(const ui::Event& event,
}
DCHECK(event.IsPointerEvent());
- ProcessPointerEvent(*event.AsPointerEvent());
- return;
+ event_targeter_->FindTargetForLocation(
+ (event.AsPointerEvent())->root_location(), event_display_id_,
sky 2017/06/07 17:05:07 Looks like you have unnecessary () around event.As
riajiang 2017/06/07 18:15:04 Done.
+ base::BindOnce(&EventDispatcher::ProcessPointerEventOnFoundTarget,
+ base::Unretained(this), *event.AsPointerEvent()));
}
ServerWindow* EventDispatcher::GetRootWindowContaining(
@@ -324,6 +317,10 @@ ServerWindow* EventDispatcher::GetRootWindowContaining(
return delegate_->GetRootWindowContaining(location_in_display, display_id);
}
+void EventDispatcher::ProcessNextEventFromQueue() {
+ delegate_->ProcessNextEventFromQueue();
+}
+
void EventDispatcher::SetMouseCursorSourceWindow(ServerWindow* window) {
if (mouse_cursor_source_window_ == window)
return;
@@ -368,12 +365,10 @@ void EventDispatcher::ProcessKeyEvent(const ui::KeyEvent& event,
EventDispatcherDelegate::AcceleratorPhase::POST);
}
-void EventDispatcher::ProcessPointerEvent(const ui::PointerEvent& event) {
- DCHECK(event.IsPointerEvent());
-
+void EventDispatcher::ProcessPointerEventOnFoundTarget(
+ const ui::PointerEvent& event,
+ const LocationTarget& location_target) {
PointerTarget pointer_target;
- LocationTarget location_target = event_targeter_->FindTargetForLocation(
- event.root_location(), event_display_id_);
pointer_target.window = modal_window_controller_.GetTargetForWindow(
location_target.deepest_window.window);
pointer_target.is_mouse_event = event.IsMousePointerEvent();
@@ -462,7 +457,7 @@ void EventDispatcher::ProcessPointerEvent(const ui::PointerEvent& event) {
// before we perform dispatch because the Delegate is going to read this
// information from us.
if (is_pointer_going_up && is_mouse_event)
- UpdateCursorProviderByLastKnownLocation();
+ UpdateCursorProviderByLastKnownLocationOnFoundWindow(location_target);
DispatchToPointerTarget(pointer_targets_[pointer_id],
*cloned_event->AsPointerEvent());
@@ -477,6 +472,41 @@ void EventDispatcher::ProcessPointerEvent(const ui::PointerEvent& event) {
}
}
+void EventDispatcher::UpdateNonClientAreaForCurrentWindowOnFoundWindow(
+ const LocationTarget& location_target) {
+ if (!mouse_cursor_source_window_)
+ return;
+
+ if (location_target.deepest_window.window == mouse_cursor_source_window_) {
+ mouse_cursor_in_non_client_area_ =
+ mouse_cursor_source_window_
+ ? location_target.deepest_window.in_non_client_area
+ : false;
+ }
+ SetMousePointerLocation(location_target.location_in_root,
+ location_target.display_id);
+ delegate_->UpdateNativeCursorFromDispatcher();
+}
+
+void EventDispatcher::UpdateCursorProviderByLastKnownLocationOnFoundWindow(
+ const LocationTarget& location_target) {
+ if (mouse_button_down_)
+ return;
+
+ SetMouseCursorSourceWindow(location_target.deepest_window.window);
+ if (mouse_cursor_source_window_) {
+ mouse_cursor_in_non_client_area_ =
+ location_target.deepest_window.in_non_client_area;
+ } else {
+ SetMouseCursorSourceWindow(delegate_->GetRootWindowContaining(
+ &mouse_pointer_last_location_, &mouse_pointer_display_id_));
+ mouse_cursor_in_non_client_area_ = true;
+ }
+ SetMousePointerLocation(location_target.location_in_root,
+ location_target.display_id);
+ delegate_->UpdateNativeCursorFromDispatcher();
+}
+
void EventDispatcher::StartTrackingPointer(
int32_t pointer_id,
const PointerTarget& pointer_target) {

Powered by Google App Engine
This is Rietveld 408576698