Skip to content

Commit

Permalink
Haptic feedback when dragging apps in launcher and shelf
Browse files Browse the repository at this point in the history
Starting drag in the app list and shelf now fires haptics (tick).
Adapts app list and shelf drag tests to also verify haptics are
triggered when the drag starts (when dragging items using a mouse
pointer).

To ease test setup, moves input controller that tracks fired haptics
from haptics_util_unittests to a designated file, so it can be reused
in other tests.

BUG=1312575

Change-Id: I947630cc47ff112699c0a95431e4cccd9b394ce9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3566798
Reviewed-by: Sammie Quon <sammiequon@chromium.org>
Reviewed-by: Ahmed Fakhry <afakhry@chromium.org>
Commit-Queue: Toni Barzic <tbarzic@chromium.org>
Cr-Commit-Position: refs/heads/main@{#989234}
  • Loading branch information
Toni Barzic authored and Chromium LUCI CQ committed Apr 6, 2022
1 parent b2483c0 commit e2083d7
Show file tree
Hide file tree
Showing 9 changed files with 538 additions and 136 deletions.
3 changes: 3 additions & 0 deletions ash/BUILD.gn
Expand Up @@ -3166,6 +3166,8 @@ static_library("test_support") {
"system/geolocation/test_geolocation_url_loader_factory.h",
"test/layer_animation_stopped_waiter.cc",
"test/layer_animation_stopped_waiter.h",
"utility/haptics_tracking_test_input_controller.cc",
"utility/haptics_tracking_test_input_controller.h",

# These headers declare functions that are implemented inside of //ash, so
# they cannot live in //ash/public/cpp/BUILD.gn.
Expand Down Expand Up @@ -3351,6 +3353,7 @@ static_library("test_support") {
"//ui/gl:test_support",
"//ui/message_center",
"//ui/message_center/public/cpp",
"//ui/ozone",
"//ui/platform_window/common",
"//ui/shell_dialogs",
"//ui/views",
Expand Down
1 change: 1 addition & 0 deletions ash/app_list/BUILD.gn
Expand Up @@ -207,6 +207,7 @@ source_set("app_list") {
"//ui/display",
"//ui/display/manager",
"//ui/events",
"//ui/events/devices",
"//ui/gfx",
"//ui/gfx/geometry",
"//ui/native_theme",
Expand Down
11 changes: 10 additions & 1 deletion ash/app_list/views/apps_grid_view.cc
Expand Up @@ -37,6 +37,7 @@
#include "ash/public/cpp/app_list/app_list_switches.h"
#include "ash/public/cpp/metrics_util.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/utility/haptics_util.h"
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/cxx17_backports.h"
Expand All @@ -54,6 +55,7 @@
#include "ui/compositor/layer.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/events/devices/haptic_touchpad_effects.h"
#include "ui/events/event.h"
#include "ui/gfx/animation/animation.h"
#include "ui/gfx/geometry/transform_util.h"
Expand Down Expand Up @@ -590,9 +592,16 @@ void AppsGridView::TryStartDragAndDropHostDrag(Pointer pointer) {

drag_pointer_ = pointer;

if (!dragging_for_reparent_item_)
if (!dragging_for_reparent_item_) {
StartDragAndDropHostDrag();

if (pointer == MOUSE) {
haptics_util::PlayHapticTouchpadEffect(
ui::HapticTouchpadEffect::kTick,
ui::HapticTouchpadEffectStrength::kMedium);
}
}

if (drag_start_callback_)
std::move(drag_start_callback_).Run();
}
Expand Down
135 changes: 128 additions & 7 deletions ash/app_list/views/apps_grid_view_unittest.cc

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions ash/shelf/shelf_view.cc
Expand Up @@ -38,6 +38,7 @@
#include "ash/strings/grit/ash_strings.h"
#include "ash/style/ash_color_provider.h"
#include "ash/system/status_area_widget.h"
#include "ash/utility/haptics_util.h"
#include "ash/wm/desks/desks_util.h"
#include "ash/wm/mru_window_tracker.h"
#include "ash/wm/tablet_mode/tablet_mode_controller.h"
Expand Down Expand Up @@ -68,6 +69,7 @@
#include "ui/compositor/scoped_animation_duration_scale_mode.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/display/scoped_display_for_new_windows.h"
#include "ui/events/devices/haptic_touchpad_effects.h"
#include "ui/events/event_utils.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/point.h"
Expand Down Expand Up @@ -1521,6 +1523,12 @@ void ShelfView::PrepareForDrag(Pointer pointer, const ui::LocatedEvent& event) {
root_window, drag_view_->GetImage(), screen_location, gfx::Vector2d(),
/*scale_factor=*/1.0f,
/*use_blurred_background=*/false);

if (pointer == MOUSE) {
haptics_util::PlayHapticTouchpadEffect(
ui::HapticTouchpadEffect::kTick,
ui::HapticTouchpadEffectStrength::kMedium);
}
}
}

Expand Down

0 comments on commit e2083d7

Please sign in to comment.