drag_drop_capture_delegate.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Copyright (c) 2021 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. #ifndef ASH_DRAG_DROP_DRAG_DROP_CAPTURE_DELEGATE_H_
  5. #define ASH_DRAG_DROP_DRAG_DROP_CAPTURE_DELEGATE_H_
  6. #include "ash/ash_export.h"
  7. #include "base/bind.h"
  8. #include "ui/events/gestures/gesture_types.h"
  9. namespace aura {
  10. class Window;
  11. }
  12. namespace ui {
  13. class LocatedEvent;
  14. }
  15. namespace ash {
  16. class DragDropTracker;
  17. class ASH_EXPORT DragDropCaptureDelegate {
  18. public:
  19. using CancelDragDropCallback = base::RepeatingCallback<void(void)>;
  20. DragDropCaptureDelegate();
  21. DragDropCaptureDelegate(const DragDropCaptureDelegate&) = delete;
  22. DragDropCaptureDelegate& operator=(const DragDropCaptureDelegate&) = delete;
  23. virtual ~DragDropCaptureDelegate();
  24. // Conditionally takes capture of top level touch events, returning whether
  25. // this was successful.
  26. bool TakeCapture(aura::Window* root_window,
  27. aura::Window* source_window,
  28. CancelDragDropCallback callback,
  29. ui::TransferTouchesBehavior behavior);
  30. // Converts an event target that was dispatched against a capture window to
  31. // once that can be processed by the drag and drop controller.
  32. //
  33. // This should only be called on events if TakeCapture returned true at the
  34. // start of a drag and drop session.
  35. aura::Window* GetTarget(const ui::LocatedEvent& event);
  36. // Converts an event that was dispatched against a capture window to once
  37. // that can be processed by the drag and drop controller, using the target
  38. // returned via GetTarget.
  39. //
  40. // This should only be called on events if TakeCapture returned true at the
  41. // start of a drag and drop session.
  42. std::unique_ptr<ui::LocatedEvent> ConvertEvent(aura::Window* target,
  43. const ui::LocatedEvent& event);
  44. // Return the capture window used if TakeCapture returns true.
  45. aura::Window* capture_window();
  46. private:
  47. std::unique_ptr<DragDropTracker> drag_drop_tracker_;
  48. };
  49. void DispatchGestureEndToWindow(aura::Window* window);
  50. } // namespace ash
  51. #endif // ASH_DRAG_DROP_DRAG_DROP_CAPTURE_DELEGATE_H_