summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb/qxcbkeyboard.h
diff options
context:
space:
mode:
authorGatis Paeglis <gatis.paeglis@digia.com>2013-04-16 20:24:45 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-05-07 22:43:14 +0200
commit43578e1901ab56e6df3e58db21e3e52a28cd9eae (patch)
treecbf7fd9ecedf6f3dd221af7b9adef601a716b621 /src/plugins/platforms/xcb/qxcbkeyboard.h
parent260bfaf056c08330ec2ed292e8d9def550e662ec (diff)
Use X11 core protocol when xkb not available
To have a properly working key input in the xcb plugin in the case when xcb-xkb library is not available we can update the xkb_state struct with the keyboard state information available in the X11 core events. The current modifier state is reported to clients in a number of core protocol events and can be determined using the QueryPointer request. This is how it is done in Weston, Wayland's reference implementation. Note: In case the X server doesn't have a xkb support on it (which is very unlikely), then xkbcommon will only pick up the user's primary layout. The X server with the xkb support stuffs unused bits (13 and 14) of 'state' in the core events with the effective keyboard group, which we can use to determine layout changes. Change-Id: I9f1ef635109870e7412ef1157ca592f3c8f9271c Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbkeyboard.h')
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.h44
1 files changed, 38 insertions, 6 deletions
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.h b/src/plugins/platforms/xcb/qxcbkeyboard.h
index 9c278eeb8c..af6677c20f 100644
--- a/src/plugins/platforms/xcb/qxcbkeyboard.h
+++ b/src/plugins/platforms/xcb/qxcbkeyboard.h
@@ -44,6 +44,10 @@
#include "qxcbobject.h"
+#ifdef QT_NO_XKB
+#include <xcb/xcb_keysyms.h>
+#endif
+
#include <xkbcommon/xkbcommon.h>
#include <QEvent>
@@ -62,14 +66,21 @@ public:
void handleKeyPressEvent(QXcbWindowEventListener *eventListener, const xcb_key_press_event_t *event);
void handleKeyReleaseEvent(QXcbWindowEventListener *eventListener, const xcb_key_release_event_t *event);
- void handleMappingNotifyEvent(const xcb_xkb_map_notify_event_t *event);
+ void handleMappingNotifyEvent(const void *event);
Qt::KeyboardModifiers translateModifiers(int s) const;
- QList<int> possibleKeys(const QKeyEvent *e) const;
void updateKeymap();
- void updateXKBState(xcb_xkb_state_notify_event_t *state);
+ QList<int> possibleKeys(const QKeyEvent *e) const;
+
+#ifdef QT_NO_XKB
+ void updateXKBStateFromCore(quint16 state);
+ void updateXKBMods();
+ quint32 xkbModMask(quint16 state);
+#else
int coreDeviceId() { return core_device_id; }
+ void updateXKBState(xcb_xkb_state_notify_event_t *state);
+#endif
protected:
void handleKeyEvent(QWindow *window, QEvent::Type type, xcb_keycode_t code, quint16 state, xcb_timestamp_t time);
@@ -80,10 +91,16 @@ protected:
int keysymToQtKey(xcb_keysym_t keysym, Qt::KeyboardModifiers &modifiers, QString text) const;
void readXKBConfig(struct xkb_rule_names *names);
+
+#ifdef QT_NO_XKB
+ void updateModifiers();
+#else
void updateVModMapping();
void updateVModToRModMapping();
+#endif
private:
+ bool m_config;
xcb_keycode_t m_autorepeat_code;
struct xkb_context *xkb_context;
@@ -96,12 +113,27 @@ private:
uint meta;
};
- _mod_masks vmod_masks;
_mod_masks rmod_masks;
- int core_device_id;
+#ifdef QT_NO_XKB
+ xcb_key_symbols_t *m_key_symbols;
+
+ struct _xkb_mods {
+ xkb_mod_index_t shift;
+ xkb_mod_index_t lock;
+ xkb_mod_index_t control;
+ xkb_mod_index_t mod1;
+ xkb_mod_index_t mod2;
+ xkb_mod_index_t mod3;
+ xkb_mod_index_t mod4;
+ xkb_mod_index_t mod5;
+ };
- bool m_config;
+ _xkb_mods xkb_mods;
+#else
+ _mod_masks vmod_masks;
+ int core_device_id;
+#endif
};
QT_END_NAMESPACE