Commit 1f1c745d authored by Josiah K's avatar Josiah K Committed by Commit Bot

Fix shaking movement while navigating the Chrome menu in docked magnifier

Fixed: 1111074
AX-Relnotes: Fix shaking movement while navigating the Chrome menu in docked magnifier
Change-Id: Icdae63357af284fcce68f4a5d73c26fac7f6628a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2418012
Commit-Queue: Josiah Krutz <josiahk@google.com>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812950}
parent ff585652
......@@ -61,8 +61,8 @@ constexpr int kDefaultAnimationDurationInMs = 100;
constexpr gfx::Tween::Type kCenterCaretAnimationTweenType = gfx::Tween::LINEAR;
// The delay of the timer for moving magnifier window for centering the text
// input focus.
constexpr int kMoveMagnifierDelayInMs = 10;
// input focus. Keep under one frame length (~16ms at 60hz).
constexpr int kMoveMagnifierDelayInMs = 15;
// Threshold of panning. If the cursor moves to within pixels (in DIP) of
// |kCursorPanningMargin| from the edge, the view-port moves.
......
......@@ -30,7 +30,14 @@
namespace chromeos {
namespace {
// The duration of time to ignore focus changes after the last mouse event.
// Keep under one frame length (~16ms at 60hz).
constexpr base::TimeDelta kTimeIgnoreFocusChangeAfterMouseEvent =
base::TimeDelta::FromMilliseconds(15);
MagnificationManager* g_magnification_manager = nullptr;
} // namespace
// static
......@@ -121,6 +128,10 @@ void MagnificationManager::HandleMoveMagnifierToRectIfEnabled(
}
}
void MagnificationManager::OnMouseEvent(ui::MouseEvent* event) {
last_mouse_event_ = base::TimeTicks::Now();
}
void MagnificationManager::OnViewEvent(views::View* view,
ax::mojom::Event event_type) {
if (!fullscreen_magnifier_enabled_ && !IsDockedMagnifierEnabled())
......@@ -334,6 +345,12 @@ void MagnificationManager::HandleFocusChanged(const gfx::Rect& bounds_in_screen,
if (bounds_in_screen.IsEmpty())
return;
// Ignore focus changes while mouse activity is occurring.
if (base::TimeTicks::Now() - last_mouse_event_ <
kTimeIgnoreFocusChangeAfterMouseEvent) {
return;
}
// Fullscreen magnifier and docked magnifier are mutually exclusive.
if (fullscreen_magnifier_enabled_) {
ash::Shell::Get()->magnification_controller()->HandleFocusedNodeChanged(
......
......@@ -13,6 +13,7 @@
#include "components/user_manager/user_manager.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "ui/events/event_handler.h"
#include "ui/views/accessibility/ax_event_observer.h"
class PrefChangeRegistrar;
......@@ -35,6 +36,7 @@ class MagnificationManager
: public content::NotificationObserver,
public user_manager::UserManager::UserSessionStateObserver,
public ProfileObserver,
public ui::EventHandler,
public views::AXEventObserver {
public:
// Creates an instance of MagnificationManager. This should be called once.
......@@ -74,6 +76,9 @@ class MagnificationManager
// ProfileObserver:
void OnProfileWillBeDestroyed(Profile* profile) override;
// ui::EventHandler overrides:
void OnMouseEvent(ui::MouseEvent* event) override;
// views::AXEventObserver:
void OnViewEvent(views::View* view, ax::mojom::Event event_type) override;
......@@ -109,6 +114,10 @@ class MagnificationManager
Profile* profile_ = nullptr;
ScopedObserver<Profile, ProfileObserver> profile_observer_{this};
// Last mouse event time - used for ignoring focus changes for a few
// milliseconds after the last mouse event.
base::TimeTicks last_mouse_event_;
bool fullscreen_magnifier_enabled_ = false;
bool keep_focus_centered_ = false;
double scale_ = 0.0;
......
......@@ -1049,6 +1049,10 @@ void ChromeBrowserMainPartsChromeos::PostBrowserStart() {
if (system::InputDeviceSettings::Get()->ForceKeyboardDrivenUINavigation())
event_rewriter_controller->SetKeyboardDrivenEventRewriterEnabled(true);
// Add MagnificationManager as a pretarget handler after ash:Shell is
// initialized.
ash::Shell::Get()->AddPreTargetHandler(MagnificationManager::Get());
// In classic ash must occur after ash::Shell is initialized. Triggers a
// fetch of the initial CrosSettings DeviceRebootOnShutdown policy.
shutdown_policy_forwarder_ = std::make_unique<ShutdownPolicyForwarder>();
......@@ -1116,6 +1120,8 @@ void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() {
assistant_state_client_.reset();
ash::Shell::Get()->RemovePreTargetHandler(MagnificationManager::Get());
// Unregister CrosSettings observers before CrosSettings is destroyed.
shutdown_policy_forwarder_.reset();
......
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