summaryrefslogtreecommitdiff
path: root/chromium/services/ui/ws/accelerator.cc
blob: ede15dd901326b95e2251b3f05a7c84c009e7760 (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
// 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.

#include "services/ui/ws/accelerator.h"

namespace ui {
namespace ws {

Accelerator::Accelerator(uint32_t id, const mojom::EventMatcher& matcher)
    : id_(id),
      accelerator_phase_(matcher.accelerator_phase),
      event_matcher_(matcher),
      weak_factory_(this) {}

Accelerator::~Accelerator() {}

bool Accelerator::MatchesEvent(const ui::Event& event,
                               const ui::mojom::AcceleratorPhase phase) const {
  if (accelerator_phase_ != phase)
    return false;
  if (!event_matcher_.MatchesEvent(event))
    return false;
  return true;
}

bool Accelerator::EqualEventMatcher(const Accelerator* other) const {
  return accelerator_phase_ == other->accelerator_phase_ &&
         event_matcher_.Equals(other->event_matcher_);
}

}  // namespace ws
}  // namespace ui