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; ...@@ -61,8 +61,8 @@ constexpr int kDefaultAnimationDurationInMs = 100;
constexpr gfx::Tween::Type kCenterCaretAnimationTweenType = gfx::Tween::LINEAR; constexpr gfx::Tween::Type kCenterCaretAnimationTweenType = gfx::Tween::LINEAR;
// The delay of the timer for moving magnifier window for centering the text // The delay of the timer for moving magnifier window for centering the text
// input focus. // input focus. Keep under one frame length (~16ms at 60hz).
constexpr int kMoveMagnifierDelayInMs = 10; constexpr int kMoveMagnifierDelayInMs = 15;
// Threshold of panning. If the cursor moves to within pixels (in DIP) of // Threshold of panning. If the cursor moves to within pixels (in DIP) of
// |kCursorPanningMargin| from the edge, the view-port moves. // |kCursorPanningMargin| from the edge, the view-port moves.
......
...@@ -30,7 +30,14 @@ ...@@ -30,7 +30,14 @@
namespace chromeos { namespace chromeos {
namespace { 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; MagnificationManager* g_magnification_manager = nullptr;
} // namespace } // namespace
// static // static
...@@ -121,6 +128,10 @@ void MagnificationManager::HandleMoveMagnifierToRectIfEnabled( ...@@ -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, void MagnificationManager::OnViewEvent(views::View* view,
ax::mojom::Event event_type) { ax::mojom::Event event_type) {
if (!fullscreen_magnifier_enabled_ && !IsDockedMagnifierEnabled()) if (!fullscreen_magnifier_enabled_ && !IsDockedMagnifierEnabled())
...@@ -334,6 +345,12 @@ void MagnificationManager::HandleFocusChanged(const gfx::Rect& bounds_in_screen, ...@@ -334,6 +345,12 @@ void MagnificationManager::HandleFocusChanged(const gfx::Rect& bounds_in_screen,
if (bounds_in_screen.IsEmpty()) if (bounds_in_screen.IsEmpty())
return; 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. // Fullscreen magnifier and docked magnifier are mutually exclusive.
if (fullscreen_magnifier_enabled_) { if (fullscreen_magnifier_enabled_) {
ash::Shell::Get()->magnification_controller()->HandleFocusedNodeChanged( ash::Shell::Get()->magnification_controller()->HandleFocusedNodeChanged(
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "components/user_manager/user_manager.h" #include "components/user_manager/user_manager.h"
#include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_registrar.h"
#include "ui/events/event_handler.h"
#include "ui/views/accessibility/ax_event_observer.h" #include "ui/views/accessibility/ax_event_observer.h"
class PrefChangeRegistrar; class PrefChangeRegistrar;
...@@ -35,6 +36,7 @@ class MagnificationManager ...@@ -35,6 +36,7 @@ class MagnificationManager
: public content::NotificationObserver, : public content::NotificationObserver,
public user_manager::UserManager::UserSessionStateObserver, public user_manager::UserManager::UserSessionStateObserver,
public ProfileObserver, public ProfileObserver,
public ui::EventHandler,
public views::AXEventObserver { public views::AXEventObserver {
public: public:
// Creates an instance of MagnificationManager. This should be called once. // Creates an instance of MagnificationManager. This should be called once.
...@@ -74,6 +76,9 @@ class MagnificationManager ...@@ -74,6 +76,9 @@ class MagnificationManager
// ProfileObserver: // ProfileObserver:
void OnProfileWillBeDestroyed(Profile* profile) override; void OnProfileWillBeDestroyed(Profile* profile) override;
// ui::EventHandler overrides:
void OnMouseEvent(ui::MouseEvent* event) override;
// views::AXEventObserver: // views::AXEventObserver:
void OnViewEvent(views::View* view, ax::mojom::Event event_type) override; void OnViewEvent(views::View* view, ax::mojom::Event event_type) override;
...@@ -109,6 +114,10 @@ class MagnificationManager ...@@ -109,6 +114,10 @@ class MagnificationManager
Profile* profile_ = nullptr; Profile* profile_ = nullptr;
ScopedObserver<Profile, ProfileObserver> profile_observer_{this}; 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 fullscreen_magnifier_enabled_ = false;
bool keep_focus_centered_ = false; bool keep_focus_centered_ = false;
double scale_ = 0.0; double scale_ = 0.0;
......
...@@ -1049,6 +1049,10 @@ void ChromeBrowserMainPartsChromeos::PostBrowserStart() { ...@@ -1049,6 +1049,10 @@ void ChromeBrowserMainPartsChromeos::PostBrowserStart() {
if (system::InputDeviceSettings::Get()->ForceKeyboardDrivenUINavigation()) if (system::InputDeviceSettings::Get()->ForceKeyboardDrivenUINavigation())
event_rewriter_controller->SetKeyboardDrivenEventRewriterEnabled(true); 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 // In classic ash must occur after ash::Shell is initialized. Triggers a
// fetch of the initial CrosSettings DeviceRebootOnShutdown policy. // fetch of the initial CrosSettings DeviceRebootOnShutdown policy.
shutdown_policy_forwarder_ = std::make_unique<ShutdownPolicyForwarder>(); shutdown_policy_forwarder_ = std::make_unique<ShutdownPolicyForwarder>();
...@@ -1116,6 +1120,8 @@ void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() { ...@@ -1116,6 +1120,8 @@ void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() {
assistant_state_client_.reset(); assistant_state_client_.reset();
ash::Shell::Get()->RemovePreTargetHandler(MagnificationManager::Get());
// Unregister CrosSettings observers before CrosSettings is destroyed. // Unregister CrosSettings observers before CrosSettings is destroyed.
shutdown_policy_forwarder_.reset(); 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