system_gesture_event_filter.cc 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "ash/wm/system_gesture_event_filter.h"
  5. #include "ash/wm/gestures/wm_gesture_handler.h"
  6. #include "base/metrics/user_metrics.h"
  7. #include "ui/aura/window.h"
  8. #include "ui/base/pointer/pointer_device.h"
  9. #include "ui/events/event.h"
  10. #include "ui/events/types/event_type.h"
  11. namespace ash {
  12. SystemGestureEventFilter::SystemGestureEventFilter()
  13. : wm_gesture_handler_(std::make_unique<WmGestureHandler>()) {}
  14. SystemGestureEventFilter::~SystemGestureEventFilter() = default;
  15. void SystemGestureEventFilter::OnMouseEvent(ui::MouseEvent* event) {
  16. if (event->type() == ui::ET_MOUSE_PRESSED &&
  17. ui::GetTouchScreensAvailability() ==
  18. ui::TouchScreensAvailability::ENABLED) {
  19. base::RecordAction(base::UserMetricsAction("Mouse_Down"));
  20. }
  21. }
  22. void SystemGestureEventFilter::OnScrollEvent(ui::ScrollEvent* event) {
  23. if (wm_gesture_handler_ && wm_gesture_handler_->ProcessScrollEvent(*event))
  24. event->StopPropagation();
  25. }
  26. } // namespace ash