xcb: update xkb_state mask as much as possible

Though we can get xcb_xkb_state_notify_event_t for the change, but
it looks like not enough, especially when a new usb barcode
scanner was used, it should be a slave keyboard, and Qt only uses
core_device_id for now. It should be enough to update xkb_state
mask when we get key event.

See also https://xkbcommon.org/doc/current/md_doc_quick_guide.html .

Fixes: QTBUG-95933
Pick-to: 6.4 6.3 6.2 5.15
Change-Id: Ie1e82c19edd777630c7f9057a3b2b8b7cad59e38
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Liang Qi 2022-05-03 20:54:19 +02:00
parent c2505751de
commit ef94aeef64

View File

@ -405,7 +405,7 @@ static xkb_layout_index_t lockedGroup(quint16 state)
void QXcbKeyboard::updateXKBStateFromCore(quint16 state)
{
if (m_config && !connection()->hasXKB()) {
if (m_config) {
struct xkb_state *xkbState = m_xkbState.get();
xkb_mod_mask_t modsDepressed = xkb_state_serialize_mods(xkbState, XKB_STATE_MODS_DEPRESSED);
xkb_mod_mask_t modsLatched = xkb_state_serialize_mods(xkbState, XKB_STATE_MODS_LATCHED);
@ -427,7 +427,7 @@ void QXcbKeyboard::updateXKBStateFromCore(quint16 state)
void QXcbKeyboard::updateXKBStateFromXI(void *modInfo, void *groupInfo)
{
if (m_config && !connection()->hasXKB()) {
if (m_config) {
auto *mods = static_cast<xcb_input_modifier_info_t *>(modInfo);
auto *group = static_cast<xcb_input_group_info_t *>(groupInfo);
const xkb_state_component changedComponents