diff options
author | Gatis Paeglis <gatis.paeglis@qt.io> | 2018-02-02 14:38:37 +0100 |
---|---|---|
committer | Gatis Paeglis <gatis.paeglis@qt.io> | 2018-02-25 13:18:27 +0000 |
commit | 50865aeeefb41750fc9c1a0adc704fc879f0b63c (patch) | |
tree | eaa5c0e283da5006bbe5a83bd39ccc937c468fce /src/plugins/platforms/xcb | |
parent | 6c88dc0c16545a06d57c7d3ee0b56aba14ddaefc (diff) |
xcb: minor refactoring in QXcbKeyboard::checkForLatinLayout()
We don't need xkb state APIs to check for keys on first level.
Change-Id: I728e6bfe09bce127ad8eae78ecee7cefd620f52e
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
Diffstat (limited to 'src/plugins/platforms/xcb')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbkeyboard.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp index f24d2f6f6d..b267cc6dc1 100644 --- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp +++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp @@ -883,14 +883,14 @@ void QXcbKeyboard::checkForLatinLayout() const const xcb_keycode_t minKeycode = xkb_keymap_min_keycode(m_xkbKeymap.get()); const xcb_keycode_t maxKeycode = xkb_keymap_max_keycode(m_xkbKeymap.get()); - ScopedXKBState state(xkb_state_new(m_xkbKeymap.get())); + const xkb_keysym_t *keysyms = nullptr; + int nrLatinKeys = 0; for (xkb_layout_index_t layout = 0; layout < layoutCount; ++layout) { - xkb_state_update_mask(state.get(), 0, 0, 0, 0, 0, layout); for (xcb_keycode_t code = minKeycode; code < maxKeycode; ++code) { - xkb_keysym_t sym = xkb_state_key_get_one_sym(state.get(), code); - // if layout can produce any of these latin letters (chosen - // arbitrarily) then it must be a latin key based layout - if (sym == XKB_KEY_q || sym == XKB_KEY_a || sym == XKB_KEY_e) + xkb_keymap_key_get_syms_by_level(m_xkbKeymap.get(), code, layout, 0, &keysyms); + if (keysyms && isLatin(keysyms[0])) + nrLatinKeys++; + if (nrLatinKeys > 10) // arbitrarily chosen threshold return; } } |