event_observer.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  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 UI_EVENTS_EVENT_OBSERVER_H_
  5. #define UI_EVENTS_EVENT_OBSERVER_H_
  6. #include "ui/events/events_export.h"
  7. namespace ui {
  8. class Event;
  9. // EventObservers are notified of events but are unable to modify the events or
  10. // mark them as handled before they are dispatched to EventHandlers.
  11. //
  12. // Window service clients may use this interface for observation of events that
  13. // target the window manager or other clients. Clients should limit the types
  14. // and duration of observation, as there is a system-wide perf/battery penalty,
  15. // especially for frequently occurring events, like mouse moves. Events with
  16. // targets outside of the client's scope will have a null target.
  17. class EVENTS_EXPORT EventObserver {
  18. public:
  19. // Called for all events matching the requested event types.
  20. // The root location of located events is always in screen coordinates.
  21. virtual void OnEvent(const Event& event) = 0;
  22. protected:
  23. virtual ~EventObserver() {}
  24. };
  25. } // namespace ui
  26. #endif // UI_EVENTS_EVENT_OBSERVER_H_