keyboard_event_handler.cc 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright 2017 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/keyboard/ui/keyboard_event_handler.h"
  5. #include "ash/keyboard/ui/keyboard_ui_controller.h"
  6. #include "ui/events/event.h"
  7. #include "ui/gfx/geometry/vector2d.h"
  8. namespace keyboard {
  9. void KeyboardEventHandler::OnGestureEvent(ui::GestureEvent* event) {
  10. switch (event->type()) {
  11. case ui::ET_GESTURE_PINCH_BEGIN:
  12. case ui::ET_GESTURE_PINCH_END:
  13. case ui::ET_GESTURE_PINCH_UPDATE:
  14. event->StopPropagation();
  15. break;
  16. default:
  17. auto* controller = KeyboardUIController::Get();
  18. if (controller->IsEnabled() && controller->HandleGestureEvent(*event))
  19. event->SetHandled();
  20. break;
  21. }
  22. }
  23. void KeyboardEventHandler::OnMouseEvent(ui::MouseEvent* event) {
  24. ProcessPointerEvent(event);
  25. }
  26. void KeyboardEventHandler::OnTouchEvent(ui::TouchEvent* event) {
  27. ProcessPointerEvent(event);
  28. }
  29. void KeyboardEventHandler::ProcessPointerEvent(ui::LocatedEvent* event) {
  30. auto* controller = KeyboardUIController::Get();
  31. if (controller->IsEnabled() && controller->HandlePointerEvent(*event))
  32. event->SetHandled();
  33. }
  34. } // namespace keyboard