Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(328)

Unified Diff: ash/mus/accelerators/accelerator_ids.h

Issue 2171973003: Separates out accelerator handling in windowmanager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/mus/accelerators/accelerator_handler.h ('k') | ash/mus/accelerators/accelerator_registrar_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/mus/accelerators/accelerator_ids.h
diff --git a/ash/mus/accelerators/accelerator_ids.h b/ash/mus/accelerators/accelerator_ids.h
new file mode 100644
index 0000000000000000000000000000000000000000..7d9465a5dc5ffff0a50758a35e58cb05b1379753
--- /dev/null
+++ b/ash/mus/accelerators/accelerator_ids.h
@@ -0,0 +1,32 @@
+// 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 ASH_MUS_ACCELERATORS_ACCELERATOR_IDS_H_
+#define ASH_MUS_ACCELERATORS_ACCELERATOR_IDS_H_
+
+namespace ash {
+namespace mus {
+
+// Accelerator ids consist of two parts:
+// . Upper 16 bits identifies source (namespace part).
+// . Lower 16 supplied from client (local part).
+constexpr uint16_t kLocalIdMask = 0xFFFF;
+
+inline uint32_t ComputeAcceleratorId(uint16_t accelerator_namespace,
+ uint16_t local_id) {
+ return (accelerator_namespace << 16) | local_id;
+}
+
+inline uint16_t GetAcceleratorLocalId(uint32_t accelerator_id) {
+ return static_cast<uint16_t>(accelerator_id & kLocalIdMask);
+}
+
+inline uint16_t GetAcceleratorNamespaceId(uint32_t accelerator_id) {
+ return static_cast<uint16_t>((accelerator_id >> 16) & kLocalIdMask);
+}
+
+} // namespace mus
+} // namespace ash
+
+#endif // ASH_MUS_ACCELERATORS_ACCELERATOR_IDS_H_
« no previous file with comments | « ash/mus/accelerators/accelerator_handler.h ('k') | ash/mus/accelerators/accelerator_registrar_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698