summaryrefslogtreecommitdiffstats
path: root/ui/events/event_processor.h
blob: 8e6305148ba5d5dca5d8f3a1bdb03a6ac5a06038 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_EVENTS_EVENT_PROCESSOR_H_
#define UI_EVENTS_EVENT_PROCESSOR_H_

#include "ui/events/event_dispatcher.h"
#include "ui/events/event_source.h"

namespace ui {

// EventProcessor receives an event from an EventSource and dispatches it to a
// tree of EventTargets.
class EVENTS_EXPORT EventProcessor : public EventDispatcherDelegate {
 public:
  ~EventProcessor() override {}

  // Returns the root of the tree this event processor owns.
  virtual EventTarget* GetRootTarget() = 0;

  // Dispatches an event received from the EventSource to the tree of
  // EventTargets (whose root is returned by GetRootTarget()).  The co-ordinate
  // space of the source must be the same as the root target, except that the
  // target may have a high-dpi scale applied.
  // TODO(tdanderson|sadrul): This is only virtual for testing purposes. It
  //                          should not be virtual at all.
  virtual EventDispatchDetails OnEventFromSource(Event* event)
      WARN_UNUSED_RESULT;

 protected:
  // Invoked at the start of processing, before an EventTargeter is used to
  // find the target of the event. If processing should not take place, marks
  // |event| as handled. Otherwise updates |event| so that the targeter can
  // operate correctly (e.g., it can be used to update the location of the
  // event when dispatching from an EventSource in high-DPI) and updates any
  // members in the event processor as necessary.
  virtual void OnEventProcessingStarted(Event* event);

  // Invoked when the processing of |event| has finished (i.e., when no further
  // dispatching of |event| will be performed by this EventProcessor). Note
  // that the last target to which |event| was dispatched may have been
  // destroyed.
  virtual void OnEventProcessingFinished(Event* event);
};

}  // namespace ui

#endif  // UI_EVENTS_EVENT_PROCESSOR_H_