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

Unified Diff: ui/ozone/platform/wayland/wayland_xkb_keyboard_layout_engine.cc

Issue 2639053002: [ozone/wayland] Implement basic keyboard handling support (Closed)
Patch Set: addressed kpschoedel's review Created 3 years, 11 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 | « ui/ozone/platform/wayland/wayland_xkb_keyboard_layout_engine.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/ozone/platform/wayland/wayland_xkb_keyboard_layout_engine.cc
diff --git a/ui/ozone/platform/wayland/wayland_xkb_keyboard_layout_engine.cc b/ui/ozone/platform/wayland/wayland_xkb_keyboard_layout_engine.cc
new file mode 100644
index 0000000000000000000000000000000000000000..79532d9afd16a1dd93dbf9dc6000086b647c70ee
--- /dev/null
+++ b/ui/ozone/platform/wayland/wayland_xkb_keyboard_layout_engine.cc
@@ -0,0 +1,47 @@
+// Copyright 2017 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 "ui/ozone/platform/wayland/wayland_xkb_keyboard_layout_engine.h"
+
+#include "ui/events/event_constants.h"
+
+namespace ui {
+
+WaylandXkbKeyboardLayoutEngine::WaylandXkbKeyboardLayoutEngine(
+ const XkbKeyCodeConverter& converter)
+ : XkbKeyboardLayoutEngine(converter) {}
+
+void WaylandXkbKeyboardLayoutEngine::SetKeymap(xkb_keymap* keymap) {
+ XkbKeyboardLayoutEngine::SetKeymap(keymap);
+
+ xkb_mod_indexes_.control =
+ xkb_keymap_mod_get_index(keymap, XKB_MOD_NAME_CTRL);
+ xkb_mod_indexes_.alt = xkb_keymap_mod_get_index(keymap, XKB_MOD_NAME_ALT);
+ xkb_mod_indexes_.shift = xkb_keymap_mod_get_index(keymap, XKB_MOD_NAME_SHIFT);
+}
+
+int WaylandXkbKeyboardLayoutEngine::UpdateModifiers(uint32_t depressed_mods,
+ uint32_t latched_mods,
+ uint32_t locked_mods,
+ uint32_t group) {
+ xkb_state_update_mask(xkb_state_.get(), depressed_mods, latched_mods,
+ locked_mods, 0, 0, group);
+
+ int modifiers = 0;
+ auto component = static_cast<xkb_state_component>(XKB_STATE_MODS_DEPRESSED |
+ XKB_STATE_MODS_LATCHED);
+ if (xkb_state_mod_index_is_active(xkb_state_.get(), xkb_mod_indexes_.control,
+ component))
+ modifiers |= EF_CONTROL_DOWN;
+ if (xkb_state_mod_index_is_active(xkb_state_.get(), xkb_mod_indexes_.alt,
+ component))
+ modifiers |= EF_ALT_DOWN;
+ if (xkb_state_mod_index_is_active(xkb_state_.get(), xkb_mod_indexes_.shift,
+ component))
+ modifiers |= EF_SHIFT_DOWN;
+
+ return modifiers;
+}
+
+} // namespace ui
« no previous file with comments | « ui/ozone/platform/wayland/wayland_xkb_keyboard_layout_engine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698