platform_event_dispatcher.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2014 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 UI_EVENTS_PLATFORM_PLATFORM_EVENT_DISPATCHER_H_
  5. #define UI_EVENTS_PLATFORM_PLATFORM_EVENT_DISPATCHER_H_
  6. #include <stdint.h>
  7. #include "ui/events/events_export.h"
  8. #include "ui/events/platform_event.h"
  9. namespace ui {
  10. // See documentation for |PlatformEventDispatcher::DispatchEvent()| for
  11. // explanation of the meaning of the flags.
  12. enum PostDispatchAction {
  13. POST_DISPATCH_NONE = 0x0,
  14. POST_DISPATCH_PERFORM_DEFAULT = 0x1,
  15. POST_DISPATCH_STOP_PROPAGATION = 0x2,
  16. };
  17. // PlatformEventDispatcher receives events from a PlatformEventSource and
  18. // dispatches them.
  19. class EVENTS_EXPORT PlatformEventDispatcher {
  20. public:
  21. // Returns whether this dispatcher wants to dispatch |event|.
  22. virtual bool CanDispatchEvent(const PlatformEvent& event) = 0;
  23. // Dispatches |event|. If this is not the default dispatcher, then the
  24. // dispatcher can request that the default dispatcher gets a chance to
  25. // dispatch the event by setting POST_DISPATCH_PERFORM_DEFAULT to the return
  26. // value. If the dispatcher has processed the event, and no other dispatcher
  27. // should be allowed to dispatch the event, then the dispatcher should set
  28. // POST_DISPATCH_STOP_PROPAGATION flag on the return value.
  29. virtual uint32_t DispatchEvent(const PlatformEvent& event) = 0;
  30. protected:
  31. virtual ~PlatformEventDispatcher() {}
  32. };
  33. } // namespace ui
  34. #endif // UI_EVENTS_PLATFORM_PLATFORM_EVENT_DISPATCHER_H_