summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb
diff options
context:
space:
mode:
authorGatis Paeglis <gatis.paeglis@qt.io>2018-02-02 15:03:39 +0100
committerGatis Paeglis <gatis.paeglis@qt.io>2018-02-25 13:18:34 +0000
commit1a341d8333c95708759706aa78fbc7828d837bf2 (patch)
tree5a2be457a92c88aa8bb35c366e826ee26857cded /src/plugins/platforms/xcb
parent50865aeeefb41750fc9c1a0adc704fc879f0b63c (diff)
xcb: cleanup TODOs for KeyboardLayoutChange
Change-Id: I5d2207fdb21cbabb04460faf73c35275bc76b7b0 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/plugins/platforms/xcb')
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.cpp40
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.h1
2 files changed, 23 insertions, 18 deletions
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
index b267cc6dc1..b097ca7b45 100644
--- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
@@ -770,7 +770,7 @@ void QXcbKeyboard::updateKeymap()
void QXcbKeyboard::updateXKBState(xcb_xkb_state_notify_event_t *state)
{
if (m_config && connection()->hasXKB()) {
- const xkb_state_component newState
+ const xkb_state_component changedComponents
= xkb_state_update_mask(m_xkbState.get(),
state->baseMods,
state->latchedMods,
@@ -779,9 +779,7 @@ void QXcbKeyboard::updateXKBState(xcb_xkb_state_notify_event_t *state)
state->latchedGroup,
state->lockedGroup);
- if ((newState & XKB_STATE_LAYOUT_EFFECTIVE) == XKB_STATE_LAYOUT_EFFECTIVE) {
- //qWarning("TODO: Support KeyboardLayoutChange on QPA (QTBUG-27681)");
- }
+ handleStateChanges(changedComponents);
}
}
#endif
@@ -809,9 +807,7 @@ void QXcbKeyboard::updateXKBStateFromCore(quint16 state)
xkb_state_component changedComponents = xkb_state_update_mask(
xkbState, depressed, latched, locked, 0, 0, lockedGroup(state));
- if ((changedComponents & XKB_STATE_LAYOUT_EFFECTIVE) == XKB_STATE_LAYOUT_EFFECTIVE) {
- //qWarning("TODO: Support KeyboardLayoutChange on QPA (QTBUG-27681)");
- }
+ handleStateChanges(changedComponents);
}
}
@@ -821,21 +817,29 @@ void QXcbKeyboard::updateXKBStateFromXI(void *modInfo, void *groupInfo)
if (m_config && !connection()->hasXKB()) {
xXIModifierInfo *mods = static_cast<xXIModifierInfo *>(modInfo);
xXIGroupInfo *group = static_cast<xXIGroupInfo *>(groupInfo);
- const xkb_state_component newState = xkb_state_update_mask(m_xkbState.get(),
- mods->base_mods,
- mods->latched_mods,
- mods->locked_mods,
- group->base_group,
- group->latched_group,
- group->locked_group);
-
- if ((newState & XKB_STATE_LAYOUT_EFFECTIVE) == XKB_STATE_LAYOUT_EFFECTIVE) {
- //qWarning("TODO: Support KeyboardLayoutChange on QPA (QTBUG-27681)");
- }
+ const xkb_state_component changedComponents
+ = xkb_state_update_mask(m_xkbState.get(),
+ mods->base_mods,
+ mods->latched_mods,
+ mods->locked_mods,
+ group->base_group,
+ group->latched_group,
+ group->locked_group);
+
+ handleStateChanges(changedComponents);
}
}
#endif
+void QXcbKeyboard::handleStateChanges(xkb_state_component changedComponents)
+{
+ // Note: Ubuntu (with Unity) always creates a new keymap when layout is changed
+ // via system settings, which means that the layout change would not be detected
+ // by this code. That can be solved by emitting KeyboardLayoutChange also from updateKeymap().
+ if ((changedComponents & XKB_STATE_LAYOUT_EFFECTIVE) == XKB_STATE_LAYOUT_EFFECTIVE)
+ qCDebug(lcQpaKeyboard, "TODO: Support KeyboardLayoutChange on QPA (QTBUG-27681)");
+}
+
xkb_mod_mask_t QXcbKeyboard::xkbModMask(quint16 state)
{
xkb_mod_mask_t xkb_mask = 0;
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.h b/src/plugins/platforms/xcb/qxcbkeyboard.h
index a7ab88b9d9..eab917e5b4 100644
--- a/src/plugins/platforms/xcb/qxcbkeyboard.h
+++ b/src/plugins/platforms/xcb/qxcbkeyboard.h
@@ -82,6 +82,7 @@ public:
int coreDeviceId() const { return core_device_id; }
void updateXKBState(xcb_xkb_state_notify_event_t *state);
#endif
+ void handleStateChanges(xkb_state_component changedComponents);
protected:
void handleKeyEvent(xcb_window_t sourceWindow, QEvent::Type type, xcb_keycode_t code,