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

Side by Side 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, 10 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 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.
4
5 #include "ui/ozone/platform/wayland/wayland_xkb_keyboard_layout_engine.h"
6
7 #include "ui/events/event_constants.h"
8
9 namespace ui {
10
11 WaylandXkbKeyboardLayoutEngine::WaylandXkbKeyboardLayoutEngine(
12 const XkbKeyCodeConverter& converter)
13 : XkbKeyboardLayoutEngine(converter) {}
14
15 void WaylandXkbKeyboardLayoutEngine::SetKeymap(xkb_keymap* keymap) {
16 XkbKeyboardLayoutEngine::SetKeymap(keymap);
17
18 xkb_mod_indexes_.control =
19 xkb_keymap_mod_get_index(keymap, XKB_MOD_NAME_CTRL);
20 xkb_mod_indexes_.alt = xkb_keymap_mod_get_index(keymap, XKB_MOD_NAME_ALT);
21 xkb_mod_indexes_.shift = xkb_keymap_mod_get_index(keymap, XKB_MOD_NAME_SHIFT);
22 }
23
24 int WaylandXkbKeyboardLayoutEngine::UpdateModifiers(uint32_t depressed_mods,
25 uint32_t latched_mods,
26 uint32_t locked_mods,
27 uint32_t group) {
28 xkb_state_update_mask(xkb_state_.get(), depressed_mods, latched_mods,
29 locked_mods, 0, 0, group);
30
31 int modifiers = 0;
32 auto component = static_cast<xkb_state_component>(XKB_STATE_MODS_DEPRESSED |
33 XKB_STATE_MODS_LATCHED);
34 if (xkb_state_mod_index_is_active(xkb_state_.get(), xkb_mod_indexes_.control,
35 component))
36 modifiers |= EF_CONTROL_DOWN;
37 if (xkb_state_mod_index_is_active(xkb_state_.get(), xkb_mod_indexes_.alt,
38 component))
39 modifiers |= EF_ALT_DOWN;
40 if (xkb_state_mod_index_is_active(xkb_state_.get(), xkb_mod_indexes_.shift,
41 component))
42 modifiers |= EF_SHIFT_DOWN;
43
44 return modifiers;
45 }
46
47 } // namespace ui
OLDNEW
« 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