wayland_pointer_delegate.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright 2018 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 COMPONENTS_EXO_WAYLAND_WAYLAND_POINTER_DELEGATE_H_
  5. #define COMPONENTS_EXO_WAYLAND_WAYLAND_POINTER_DELEGATE_H_
  6. #include "components/exo/pointer_delegate.h"
  7. #include "components/exo/wayland/wayland_input_delegate.h"
  8. struct wl_client;
  9. struct wl_resource;
  10. namespace exo {
  11. namespace wayland {
  12. class SerialTracker;
  13. // Pointer delegate class that accepts events for surfaces owned by the same
  14. // client as a pointer resource.
  15. class WaylandPointerDelegate : public WaylandInputDelegate,
  16. public PointerDelegate {
  17. public:
  18. explicit WaylandPointerDelegate(wl_resource* pointer_resource,
  19. SerialTracker* serial_tracker);
  20. WaylandPointerDelegate(const WaylandPointerDelegate&) = delete;
  21. WaylandPointerDelegate& operator=(const WaylandPointerDelegate&) = delete;
  22. // Overridden from PointerDelegate:
  23. void OnPointerDestroying(Pointer* pointer) override;
  24. bool CanAcceptPointerEventsForSurface(Surface* surface) const override;
  25. void OnPointerEnter(Surface* surface,
  26. const gfx::PointF& location,
  27. int button_flags) override;
  28. void OnPointerLeave(Surface* surface) override;
  29. void OnPointerMotion(base::TimeTicks time_stamp,
  30. const gfx::PointF& location) override;
  31. void OnPointerButton(base::TimeTicks time_stamp,
  32. int button_flags,
  33. bool pressed) override;
  34. void OnPointerScroll(base::TimeTicks time_stamp,
  35. const gfx::Vector2dF& offset,
  36. bool discrete) override;
  37. void OnPointerScrollStop(base::TimeTicks time_stamp) override;
  38. void OnPointerFrame() override;
  39. private:
  40. // The client who own this pointer instance.
  41. wl_client* client() const;
  42. // The pointer resource associated with the pointer.
  43. wl_resource* const pointer_resource_;
  44. // Owned by Server, which always outlives this delegate.
  45. SerialTracker* const serial_tracker_;
  46. };
  47. } // namespace wayland
  48. } // namespace exo
  49. #endif // COMPONENTS_EXO_WAYLAND_WAYLAND_POINTER_DELEGATE_H_