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

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

Issue 2778943005: Keep root_location to be in pixels and display coordinates in WS. (Closed)
Patch Set: const Created 3 years, 7 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 83e8b37f26e8aafdacbec4f0fc45566195c18068..bcea3cf9e2b60ec67f8292d0d08cd3467d6344f0 100644
--- a/services/ui/ws/event_dispatcher.cc
+++ b/services/ui/ws/event_dispatcher.cc
@@ -76,15 +76,17 @@ void EventDispatcher::Reset() {
mouse_button_down_ = false;
}
-void EventDispatcher::SetMousePointerScreenLocation(
- const gfx::Point& screen_location) {
+void EventDispatcher::SetMousePointerDisplayLocation(
+ const gfx::Point& display_location,
+ const int64_t display_id) {
DCHECK(pointer_targets_.empty());
- mouse_pointer_last_location_ = screen_location;
+ mouse_pointer_last_location_ = display_location;
+ mouse_pointer_display_id_ = display_id;
UpdateCursorProviderByLastKnownLocation();
// Write our initial location back to our shared screen coordinate. This
// shouldn't cause problems because we already read the cursor before we
// process any events in views during window construction.
- delegate_->OnMouseCursorLocationChanged(screen_location);
+ delegate_->OnMouseCursorLocationChanged(display_location, display_id);
}
ui::CursorData EventDispatcher::GetCurrentMouseCursor() const {
@@ -219,8 +221,8 @@ const ServerWindow* EventDispatcher::GetWindowForMouseCursor() const {
void EventDispatcher::UpdateNonClientAreaForCurrentWindow() {
if (mouse_cursor_source_window_) {
- DeepestWindow deepest_window =
- FindDeepestVisibleWindowForEvents(mouse_pointer_last_location_);
+ DeepestWindow deepest_window = FindDeepestVisibleWindowForEvents(
+ &mouse_pointer_last_location_, &mouse_pointer_display_id_);
if (deepest_window.window == mouse_cursor_source_window_) {
mouse_cursor_in_non_client_area_ = mouse_cursor_source_window_
? deepest_window.in_non_client_area
@@ -231,14 +233,14 @@ void EventDispatcher::UpdateNonClientAreaForCurrentWindow() {
void EventDispatcher::UpdateCursorProviderByLastKnownLocation() {
if (!mouse_button_down_) {
- DeepestWindow deepest_window =
- FindDeepestVisibleWindowForEvents(mouse_pointer_last_location_);
+ DeepestWindow deepest_window = FindDeepestVisibleWindowForEvents(
+ &mouse_pointer_last_location_, &mouse_pointer_display_id_);
SetMouseCursorSourceWindow(deepest_window.window);
if (mouse_cursor_source_window_) {
mouse_cursor_in_non_client_area_ = deepest_window.in_non_client_area;
} else {
- gfx::Point location = mouse_pointer_last_location_;
- SetMouseCursorSourceWindow(delegate_->GetRootWindowContaining(&location));
+ SetMouseCursorSourceWindow(delegate_->GetRootWindowContaining(
+ &mouse_pointer_last_location_, &mouse_pointer_display_id_));
mouse_cursor_in_non_client_area_ = true;
}
}
@@ -273,6 +275,7 @@ void EventDispatcher::RemoveAccelerator(uint32_t id) {
}
void EventDispatcher::ProcessEvent(const ui::Event& event,
+ const int64_t display_id,
AcceleratorMatchPhase match_phase) {
#if !defined(NDEBUG)
if (match_phase == AcceleratorMatchPhase::POST_ONLY) {
@@ -287,6 +290,7 @@ void EventDispatcher::ProcessEvent(const ui::Event& event,
previous_event_ = Event::Clone(event);
previous_accelerator_match_phase_ = match_phase;
#endif
+ event_display_id_ = display_id;
if (event.IsKeyEvent()) {
const ui::KeyEvent* key_event = event.AsKeyEvent();
if (!key_event->is_char() && match_phase == AcceleratorMatchPhase::ANY) {
@@ -294,7 +298,7 @@ void EventDispatcher::ProcessEvent(const ui::Event& event,
FindAccelerator(*key_event, ui::mojom::AcceleratorPhase::PRE_TARGET);
if (pre_target) {
delegate_->OnAccelerator(
- pre_target->id(), event,
+ pre_target->id(), event_display_id_, event,
EventDispatcherDelegate::AcceleratorPhase::PRE);
return;
}
@@ -329,19 +333,19 @@ void EventDispatcher::ProcessKeyEvent(const ui::KeyEvent& event,
return;
}
ServerWindow* focused_window =
- delegate_->GetFocusedWindowForEventDispatcher();
+ delegate_->GetFocusedWindowForEventDispatcher(event_display_id_);
if (focused_window) {
// Assume key events are for the client area.
const bool in_nonclient_area = false;
const ClientSpecificId client_id =
delegate_->GetEventTargetClientId(focused_window, in_nonclient_area);
- delegate_->DispatchInputEventToWindow(focused_window, client_id, event,
- post_target);
+ delegate_->DispatchInputEventToWindow(
+ focused_window, client_id, event_display_id_, event, post_target);
return;
}
- delegate_->OnEventTargetNotFound(event);
+ delegate_->OnEventTargetNotFound(event, event_display_id_);
if (post_target)
- delegate_->OnAccelerator(post_target->id(), event,
+ delegate_->OnAccelerator(post_target->id(), event_display_id_, event,
EventDispatcherDelegate::AcceleratorPhase::POST);
}
@@ -351,7 +355,9 @@ void EventDispatcher::ProcessPointerEvent(const ui::PointerEvent& event) {
if (is_mouse_event) {
mouse_pointer_last_location_ = event.root_location();
- delegate_->OnMouseCursorLocationChanged(event.root_location());
+ mouse_pointer_display_id_ = event_display_id_;
+ delegate_->OnMouseCursorLocationChanged(event.root_location(),
+ event_display_id_);
}
// Release capture on pointer up. For mouse we only release if there are
@@ -399,7 +405,9 @@ void EventDispatcher::ProcessPointerEvent(const ui::PointerEvent& event) {
ServerWindow* capture_window = pointer_target.window;
if (!capture_window) {
gfx::Point event_location = event.root_location();
- capture_window = delegate_->GetRootWindowContaining(&event_location);
+ int64_t event_display_id = event_display_id_;
+ capture_window = delegate_->GetRootWindowContaining(
+ &event_location, &event_display_id);
}
delegate_->SetNativeCapture(capture_window);
}
@@ -481,8 +489,9 @@ void EventDispatcher::UpdateTargetForPointer(int32_t pointer_id,
EventDispatcher::PointerTarget EventDispatcher::PointerTargetForEvent(
const ui::LocatedEvent& event) {
PointerTarget pointer_target;
- DeepestWindow deepest_window =
- FindDeepestVisibleWindowForEvents(event.root_location());
+ gfx::Point event_root_location(event.root_location());
+ DeepestWindow deepest_window = FindDeepestVisibleWindowForEvents(
+ &event_root_location, &event_display_id_);
pointer_target.window =
modal_window_controller_.GetTargetForWindow(deepest_window.window);
pointer_target.is_mouse_event = event.IsMousePointerEvent();
@@ -504,7 +513,7 @@ bool EventDispatcher::AreAnyPointersDown() const {
void EventDispatcher::DispatchToPointerTarget(const PointerTarget& target,
const ui::LocatedEvent& event) {
if (!target.window) {
- delegate_->OnEventTargetNotFound(event);
+ delegate_->OnEventTargetNotFound(event, event_display_id_);
return;
}
@@ -526,7 +535,8 @@ void EventDispatcher::DispatchToClient(ServerWindow* window,
clone->AsLocatedEvent()->set_location(location);
// TODO(jonross): add post-target accelerator support once accelerators
// support pointer events.
- delegate_->DispatchInputEventToWindow(window, client_id, *clone, nullptr);
+ delegate_->DispatchInputEventToWindow(window, client_id, event_display_id_,
+ *clone, nullptr);
}
void EventDispatcher::CancelPointerEventsToTarget(ServerWindow* window) {
@@ -581,12 +591,10 @@ Accelerator* EventDispatcher::FindAccelerator(
}
DeepestWindow EventDispatcher::FindDeepestVisibleWindowForEvents(
- const gfx::Point& location) {
- gfx::Point relative_location(location);
- // For the case of no root.
- ServerWindow* root = delegate_->GetRootWindowContaining(&relative_location);
- return root ? ui::ws::FindDeepestVisibleWindowForEvents(root,
- relative_location)
+ gfx::Point* location,
+ int64_t* display_id) {
+ ServerWindow* root = delegate_->GetRootWindowContaining(location, display_id);
+ return root ? ui::ws::FindDeepestVisibleWindowForEvents(root, *location)
: DeepestWindow();
}
« 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