Commit 2578f5c9 authored by Ryan Daum's avatar Ryan Daum Committed by Commit Bot

[chromecast] Magnifier behavior fixes.

  - Issue 'tap' gesture events while panning or zooming, to avoid idle
    screen during interaction.
  - Properly disable magnification when magnification gesture is
    turned off.

Bug: internal b/112615721
Bug: internal b/112612596
Test: manual
Change-Id: If6ec273ddab0f70d0c56743e38c0c40b49a579c4
Reviewed-on: https://chromium-review.googlesource.com/1175854Reviewed-by: default avatarAlex Sakhartchouk <alexst@chromium.org>
Reviewed-by: default avatarRandy Rossi <rmrossi@chromium.org>
Commit-Queue: Ryan Daum <rdaum@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583333}
parent 56e148bd
......@@ -28,12 +28,12 @@ AccessibilityManager::AccessibilityManager(
std::make_unique<AccessibilityFocusRingController>(root_window);
touch_exploration_manager_ = std::make_unique<TouchExplorationManager>(
root_window, activation_client,
accessibility_focus_ring_controller_.get(),
&accessibility_sound_proxy_,
accessibility_focus_ring_controller_.get(), &accessibility_sound_proxy_,
window_manager->GetGestureHandler());
triple_tap_detector_ = std::make_unique<TripleTapDetector>(root_window, this);
magnification_controller_ =
std::make_unique<FullscreenMagnificationController>(root_window);
std::make_unique<FullscreenMagnificationController>(
root_window, window_manager->GetGestureHandler());
}
AccessibilityManager::~AccessibilityManager() {}
......@@ -87,8 +87,16 @@ aura::WindowTreeHost* AccessibilityManager::window_tree_host() const {
return window_tree_host_;
}
void AccessibilityManager::SetMagnificationGestureEnabled(bool enabled) {
triple_tap_detector_->set_enabled(enabled);
void AccessibilityManager::SetMagnificationGestureEnabled(
bool gesture_enabled) {
triple_tap_detector_->set_enabled(gesture_enabled);
// If the gesture is not enabled, make sure that magnification is turned off,
// in case we're already in magnification. Otherwise the user will be stuck in
// magnifier and unable to get out.
if (!gesture_enabled) {
magnification_controller_->SetEnabled(false);
}
}
bool AccessibilityManager::IsMagnificationGestureEnabled() const {
......
......@@ -5,6 +5,7 @@
#include "chromecast/graphics/accessibility/fullscreen_magnification_controller.h"
#include "base/numerics/ranges.h"
#include "chromecast/graphics/cast_gesture_handler.h"
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_tree_host.h"
......@@ -75,9 +76,11 @@ class FullscreenMagnificationController::GestureProviderClient
};
FullscreenMagnificationController::FullscreenMagnificationController(
aura::Window* root_window)
aura::Window* root_window,
CastGestureHandler* cast_gesture_handler)
: root_window_(root_window),
magnification_scale_(kDefaultMagnificationScale) {
magnification_scale_(kDefaultMagnificationScale),
cast_gesture_handler_(cast_gesture_handler) {
DCHECK(root_window);
root_window->GetHost()->GetEventSource()->AddEventRewriter(this);
......@@ -341,6 +344,10 @@ bool FullscreenMagnificationController::ProcessGestures() {
(gesture_center.y() - magnification_origin_.y()));
RedrawDIP(origin, scale);
// Invoke the tap gesture so we don't go idle in the UI while zooming.
cast_gesture_handler_->HandleTapGesture(
gfx::ToFlooredPoint(gesture_center));
} else if (gesture->type() == ui::ET_GESTURE_SCROLL_BEGIN) {
original_magnification_origin_ = magnification_origin_;
......@@ -371,6 +378,9 @@ bool FullscreenMagnificationController::ProcessGestures() {
}
}
RedrawDIP(gfx::PointF(new_x, new_y), magnification_scale_);
// Invoke the tap gesture so we don't go idle in the UI whiole dragging.
cast_gesture_handler_->HandleTapGesture(gfx::Point(new_x, new_y));
}
}
......
......@@ -23,11 +23,15 @@ class GestureProviderAura;
namespace chromecast {
class CastGestureHandler;
class FullscreenMagnificationController : public MagnificationController,
public ui::EventRewriter,
public ui::GestureConsumer {
public:
explicit FullscreenMagnificationController(aura::Window* root_window);
explicit FullscreenMagnificationController(
aura::Window* root_window,
CastGestureHandler* cast_gesture_handler);
~FullscreenMagnificationController() override;
void SetEnabled(bool enabled) override;
......@@ -95,6 +99,8 @@ class FullscreenMagnificationController : public MagnificationController,
// events are cancelled, i.e. size of this map can be different from number of
// touches on the screen. Key is pointer id.
std::map<int32_t, std::unique_ptr<ui::TouchEvent>> press_event_map_;
CastGestureHandler* cast_gesture_handler_;
};
} // namespace chromecast
......
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