Commit 7e39525e authored by Sara Kato's avatar Sara Kato Committed by Commit Bot

Do not dispatch mouse events to ChromeVox when ARC++ window is active

Mouse events should not be forwarded to ChromeVox,if called from ARC++.
This is what leads to "jumpy" and unexpected focus behaviour, as
described in the bug.

This CL checks if an arc window is active, and does this by adding an
activation observer to wm_helper.

TEST=manual (follow repro steps in bug, and observed expected behaviour)
BUG=b:141597151

Change-Id: I3d1da3801c1b826164e73a97fd639523b21202ea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1905038
Commit-Queue: Sara Kato <sarakato@chromium.org>
Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Reviewed-by: default avatarSara Kato <sarakato@chromium.org>
Cr-Commit-Position: refs/heads/master@{#718923}
parent f86c18ea
......@@ -8,6 +8,8 @@
#include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
#include "chrome/browser/chromeos/accessibility/event_handler_common.h"
#include "chrome/browser/ui/aura/accessibility/automation_manager_aura.h"
#include "components/arc/arc_util.h"
#include "components/exo/wm_helper.h"
#include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/service_manager_connection.h"
......@@ -17,9 +19,16 @@
#include "ui/events/event.h"
SpokenFeedbackEventRewriterDelegate::SpokenFeedbackEventRewriterDelegate() {
// If WMHelper doesn't exist, do nothing. This occurs in tests.
if (exo::WMHelper::HasInstance())
exo::WMHelper::GetInstance()->AddActivationObserver(this);
}
SpokenFeedbackEventRewriterDelegate::~SpokenFeedbackEventRewriterDelegate() {
// If WMHelper is already destroyed, do nothing.
// TODO(crbug.com/748380): Fix shutdown order.
if (exo::WMHelper::HasInstance())
exo::WMHelper::GetInstance()->RemoveActivationObserver(this);
}
void SpokenFeedbackEventRewriterDelegate::DispatchKeyEventToChromeVox(
......@@ -38,8 +47,21 @@ void SpokenFeedbackEventRewriterDelegate::DispatchKeyEventToChromeVox(
chromeos::ForwardKeyToExtension(*(event->AsKeyEvent()), host);
}
void SpokenFeedbackEventRewriterDelegate::OnWindowActivated(
ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) {
if (gained_active == lost_active)
return;
is_arc_window_active_ = arc::IsArcAppWindow(gained_active);
}
void SpokenFeedbackEventRewriterDelegate::DispatchMouseEventToChromeVox(
std::unique_ptr<ui::Event> event) {
if (is_arc_window_active_)
return;
if (event->type() == ui::ET_MOUSE_MOVED) {
AutomationManagerAura::GetInstance()->HandleEvent(
ax::mojom::Event::kMouseMoved);
......
......@@ -10,13 +10,15 @@
#include "ash/public/cpp/spoken_feedback_event_rewriter_delegate.h"
#include "base/macros.h"
#include "content/public/browser/web_contents_delegate.h"
#include "ui/wm/public/activation_change_observer.h"
// Passes key events from Ash's EventRewriter to the ChromeVox extension code.
// Reports ChromeVox's unhandled key events back to Ash for continued dispatch.
// TODO(http://crbug.com/839541): Avoid reposting unhandled events.
class SpokenFeedbackEventRewriterDelegate
: public ash::SpokenFeedbackEventRewriterDelegate,
public content::WebContentsDelegate {
public content::WebContentsDelegate,
public wm::ActivationChangeObserver {
public:
SpokenFeedbackEventRewriterDelegate();
~SpokenFeedbackEventRewriterDelegate() override;
......@@ -35,6 +37,13 @@ class SpokenFeedbackEventRewriterDelegate
content::WebContents* source,
const content::NativeWebKeyboardEvent& event) override;
// wm::ActivationChangeObserver overrides.
void OnWindowActivated(ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) override;
bool is_arc_window_active_ = false;
DISALLOW_COPY_AND_ASSIGN(SpokenFeedbackEventRewriterDelegate);
};
......
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