summaryrefslogtreecommitdiff
path: root/chromium/services/ui/ws/event_matcher.h
blob: f40fee28d51217024f5aa95df701c71bb08a99a0 (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
50
51
52
53
54
55
56
// Copyright 2016 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 SERVICES_UI_WS_EVENT_MATCHER_H_
#define SERVICES_UI_WS_EVENT_MATCHER_H_

#include <stdint.h>

#include "base/macros.h"
#include "services/ui/public/interfaces/event_matcher.mojom.h"
#include "ui/events/event.h"
#include "ui/events/mojo/event_constants.mojom.h"
#include "ui/events/mojo/keyboard_codes.mojom.h"
#include "ui/gfx/geometry/rect_f.h"

namespace ui {
namespace ws {

// Wraps a mojom::EventMatcher and allows events to be tested against it.
class EventMatcher {
 public:
  explicit EventMatcher(const mojom::EventMatcher& matcher);
  ~EventMatcher();

  bool MatchesEvent(const ui::Event& event) const;

  bool Equals(const EventMatcher& other) const;

 private:
  enum MatchFields {
    NONE = 0,
    TYPE = 1 << 0,
    FLAGS = 1 << 1,
    KEYBOARD_CODE = 1 << 2,
    POINTER_KIND = 1 << 3,
    POINTER_LOCATION = 1 << 4,
  };

  uint32_t fields_to_match_;
  ui::EventType event_type_;
  // Bitfields of kEventFlag* and kMouseEventFlag* values in
  // input_event_constants.mojom.
  int event_flags_;
  int ignore_event_flags_;
  uint16_t keyboard_code_;
  ui::EventPointerType pointer_type_;
  gfx::RectF pointer_region_;

  DISALLOW_COPY_AND_ASSIGN(EventMatcher);
};

}  // namespace ws
}  // namespace ui

#endif  // SERVICES_UI_WS_EVENT_MATCHER_H_