Roll src/third_party/WebKit 605a979:06cb9e9 (svn 202556:202558)
[chromium-blink-merge.git] / ui / events / base_event_utils.cc
blobffff0f1da12e42f4475ba7fcd36d22c80f50b82f
1 // Copyright 2015 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.
5 #include "ui/events/base_event_utils.h"
7 #include "base/atomic_sequence_num.h"
8 #include "base/logging.h"
9 #include "ui/events/event_constants.h"
11 namespace ui {
13 namespace {
15 #if defined(OS_CHROMEOS)
16 const int kSystemKeyModifierMask = EF_ALT_DOWN | EF_COMMAND_DOWN;
17 #else
18 const int kSystemKeyModifierMask = EF_ALT_DOWN;
19 #endif // defined(OS_CHROMEOS)
22 } // namespace
24 base::StaticAtomicSequenceNumber g_next_event_id;
26 uint32 GetNextTouchEventId() {
27 // Set the first touch event ID to 1 because we set id to 0 for other types
28 // of events.
29 uint32 id = g_next_event_id.GetNext();
30 if (id == 0)
31 id = g_next_event_id.GetNext();
32 DCHECK_NE(0U, id);
33 return id;
36 bool IsSystemKeyModifier(int flags) {
37 // AltGr modifier is used to type alternative keys on certain keyboard layouts
38 // so we don't consider keys with the AltGr modifier as a system key.
39 return (kSystemKeyModifierMask & flags) != 0 &&
40 (EF_ALTGR_DOWN & flags) == 0;
43 } // namespace ui