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

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: . 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
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..9658e612a3abfd5a0f0ab6dff10d10ac1c0d5242 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::SetMousePointerDisplayLocationAndId(
+ 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) {
@@ -304,7 +307,7 @@ void EventDispatcher::ProcessEvent(const ui::Event& event,
}
DCHECK(event.IsPointerEvent());
- ProcessPointerEvent(*event.AsPointerEvent());
+ ProcessPointerEvent(*event.AsPointerEvent(), display_id);
return;
}
@@ -345,13 +348,16 @@ void EventDispatcher::ProcessKeyEvent(const ui::KeyEvent& event,
EventDispatcherDelegate::AcceleratorPhase::POST);
}
-void EventDispatcher::ProcessPointerEvent(const ui::PointerEvent& event) {
+void EventDispatcher::ProcessPointerEvent(const ui::PointerEvent& event,
+ const int64_t display_id) {
DCHECK(event.IsPointerEvent());
+ event_display_id_ = display_id;
const bool is_mouse_event = event.IsMousePointerEvent();
if (is_mouse_event) {
mouse_pointer_last_location_ = event.root_location();
- delegate_->OnMouseCursorLocationChanged(event.root_location());
+ mouse_pointer_display_id_ = display_id;
+ delegate_->OnMouseCursorLocationChanged(event.root_location(), display_id);
}
// Release capture on pointer up. For mouse we only release if there are
@@ -399,7 +405,8 @@ 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);
+ capture_window = delegate_->GetRootWindowContaining(
+ &event_location, &event_display_id_);
}
delegate_->SetNativeCapture(capture_window);
}
@@ -481,8 +488,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();
@@ -581,12 +589,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();
}

Powered by Google App Engine
This is Rietveld 408576698