From c30a6232df03e1efbd9f3b226777b07e087a1122 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 12 Oct 2020 14:27:29 +0200 Subject: BASELINE: Update Chromium to 85.0.4183.140 Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057 Reviewed-by: Allan Sandfeld Jensen --- chromium/components/exo/shell_surface_util.cc | 58 +++++++++++++++++++++------ 1 file changed, 46 insertions(+), 12 deletions(-) (limited to 'chromium/components/exo/shell_surface_util.cc') diff --git a/chromium/components/exo/shell_surface_util.cc b/chromium/components/exo/shell_surface_util.cc index b53d60c62a2..a6a523d83e3 100644 --- a/chromium/components/exo/shell_surface_util.cc +++ b/chromium/components/exo/shell_surface_util.cc @@ -17,6 +17,7 @@ #include "ui/aura/client/capture_client.h" #include "ui/aura/window.h" #include "ui/aura/window_delegate.h" +#include "ui/aura/window_targeter.h" #include "ui/events/event.h" #include "ui/views/widget/widget.h" #include "ui/wm/core/window_util.h" @@ -57,6 +58,18 @@ bool ShouldHTComponentBlocked(int component) { } } +// Find the lowest targeter in the parent chain. +aura::WindowTargeter* FindTargeter(ui::EventTarget* target) { + do { + ui::EventTargeter* targeter = target->GetEventTargeter(); + if (targeter) + return static_cast(targeter); + target = target->GetParentTarget(); + } while (target); + + return nullptr; +} + } // namespace void SetShellApplicationId(aura::Window* window, @@ -130,13 +143,14 @@ ShellSurfaceBase* GetShellSurfaceBaseForWindow(aura::Window* window) { return static_cast(widget->widget_delegate()); } -Surface* GetTargetSurfaceForLocatedEvent(ui::LocatedEvent* event) { +Surface* GetTargetSurfaceForLocatedEvent( + const ui::LocatedEvent* original_event) { aura::Window* window = WMHelper::GetInstance()->GetCaptureClient()->GetCaptureWindow(); - gfx::PointF location_in_target_f = event->location_f(); - - if (!window) - return Surface::AsSurface(static_cast(event->target())); + if (!window) { + return Surface::AsSurface( + static_cast(original_event->target())); + } Surface* main_surface = GetShellMainSurface(window); // Skip if the event is captured by non exo windows. @@ -148,13 +162,33 @@ Surface* GetTargetSurfaceForLocatedEvent(ui::LocatedEvent* event) { if (!main_surface) return nullptr; } + DCHECK_EQ(window, static_cast(original_event->target())); - while (true) { - gfx::Point location_in_target = gfx::ToFlooredPoint(location_in_target_f); - aura::Window* focused = window->GetEventHandlerForPoint(location_in_target); + // Create a clone of the event as targeter may update it during the + // search. + auto cloned = ui::Event::Clone(*original_event); + ui::LocatedEvent* event = cloned->AsLocatedEvent(); - if (focused) - return Surface::AsSurface(focused); + while (true) { + gfx::PointF location_in_target_f = event->location_f(); + gfx::Point location_in_target = event->location(); + ui::EventTarget* event_target = window; + aura::WindowTargeter* targeter = FindTargeter(event_target); + DCHECK(targeter); + + aura::Window* focused = + static_cast(targeter->FindTargetForEvent(window, event)); + + if (focused) { + Surface* surface = Surface::AsSurface(focused); + if (focused != window) + return surface; + else if (surface && surface->HitTest(location_in_target)) { + // If the targeting fallback to the root (first) window, test the + // hit region again. + return surface; + } + } // If the event falls into the place where the window system should care // about (i.e. window caption), do not check the transient parent but just @@ -170,8 +204,8 @@ Surface* GetTargetSurfaceForLocatedEvent(ui::LocatedEvent* event) { if (!parent_window) return main_surface; - aura::Window::ConvertPointToTarget(window, parent_window, - &location_in_target_f); + event->set_location_f(location_in_target_f); + event_target->ConvertEventToTarget(parent_window, event); window = parent_window; } } -- cgit v1.2.1