Commit 10327b48 authored by Mike Wasserman's avatar Mike Wasserman Committed by Commit Bot

mus: Make UserActivityDetector not observe PlatformEventSource directly.

ash::Shell's UserActivityForwarder notifies UserActivityDetector in Mus.
Observing PlatformEventSource directly is redundant and causes problems.

Reprocessing native events with adjusted locations breaks double clicks.
This patch prevents UserActivityDetector from reprocessing those events.

Bug: 825695
Change-Id: Iefe4af55eedf8efc7515664b2f0cc46abe273866
Reviewed-on: https://chromium-review.googlesource.com/981492
Commit-Queue: Michael Wasserman <msw@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546037}
parent 7c289942
......@@ -1017,8 +1017,12 @@ void Shell::Init(ui::ContextFactory* context_factory,
// The order in which event filters are added is significant.
// ui::UserActivityDetector passes events to observers, so let them get
// rewritten first.
user_activity_detector_.reset(new ui::UserActivityDetector);
// rewritten first. The detector observses the platform event source directly
// in the Classic configuration, but in Mus and Mash configurations, the
// detector instead relies on reports of events from the Window Server.
const bool observe_event_source = config == Config::CLASSIC;
user_activity_detector_ =
std::make_unique<ui::UserActivityDetector>(observe_event_source);
overlay_filter_.reset(new OverlayEventFilter);
AddPreTargetHandler(overlay_filter_.get());
......
......@@ -198,8 +198,9 @@ void ChromeBrowserMainExtraPartsAsh::PreProfileInit() {
immersive_handler_factory_ = std::make_unique<ImmersiveHandlerFactoryMus>();
// Enterprise support in the browser can monitor user activity. Connect to
// the UI service to monitor activity. The ash process has its own monitor.
user_activity_detector_ = std::make_unique<ui::UserActivityDetector>();
// the UI service to monitor activity, as this detector cannot observe the
// platform event source directly. The ash process has its own detector.
user_activity_detector_ = std::make_unique<ui::UserActivityDetector>(false);
ui::mojom::UserActivityMonitorPtr user_activity_monitor;
content::ServiceManagerConnection::GetForProcess()
->GetConnector()
......
......@@ -47,13 +47,13 @@ const int UserActivityDetector::kNotifyIntervalMs = 200;
// and we'll ignore legitimate activity.
const int UserActivityDetector::kDisplayPowerChangeIgnoreMouseMs = 1000;
UserActivityDetector::UserActivityDetector() {
UserActivityDetector::UserActivityDetector(bool observe_event_source) {
CHECK(!g_instance);
g_instance = this;
PlatformEventSource* platform_event_source =
PlatformEventSource::GetInstance();
if (platform_event_source)
if (platform_event_source && observe_event_source)
platform_event_source->AddPlatformEventObserver(this);
}
......
......@@ -27,7 +27,10 @@ class UI_BASE_EXPORT UserActivityDetector : public PlatformEventObserver {
// is received that displays' power states are being changed.
static const int kDisplayPowerChangeIgnoreMouseMs;
UserActivityDetector();
// If |observe_event_source| is true, this detector observes platform events
// directly from the PlatformEventSource. Otherwise, this instance relies on
// reports of events through |HandleExternalUserActivity|.
explicit UserActivityDetector(bool observe_event_source = true);
~UserActivityDetector() override;
// Returns the UserActivityDetector instance if one was created.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment