summaryrefslogtreecommitdiffstats
path: root/src/compositor/compositor_api/qwaylandkeyboard_p.h
diff options
context:
space:
mode:
authorGatis Paeglis <gatis.paeglis@qt.io>2018-12-14 12:14:42 +0100
committerGatis Paeglis <gatis.paeglis@qt.io>2019-04-16 09:18:41 +0000
commit60dc973ab2c9227e2b6161a8b61a8c129e8b8cbc (patch)
tree1772a6cc5dfc3426c36f9dcc63c461f1e9edf950 /src/compositor/compositor_api/qwaylandkeyboard_p.h
parent6eda0ca6aff3df020f71c74a3834f388cbdc685d (diff)
compositor: rework xkb context/keymap/state handling
- Use smart pointers from xkbcommon_support-private. - Avoid unnecessary strdup()/free() calls. - Don't recreate context. And move it into qwaylandcompositor so it can be shared between seats. It contains things like a logging level and include paths. Change-Id: Ibea29f2874cc147a8e08f15192831fa42ca58f48 Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Diffstat (limited to 'src/compositor/compositor_api/qwaylandkeyboard_p.h')
-rw-r--r--src/compositor/compositor_api/qwaylandkeyboard_p.h11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/compositor/compositor_api/qwaylandkeyboard_p.h b/src/compositor/compositor_api/qwaylandkeyboard_p.h
index 87e89e85e..c4d29c2d6 100644
--- a/src/compositor/compositor_api/qwaylandkeyboard_p.h
+++ b/src/compositor/compositor_api/qwaylandkeyboard_p.h
@@ -51,6 +51,7 @@
//
// We mean it.
//
+#include <QtWaylandCompositor/private/qwaylandcompositor_p.h>
#include <QtWaylandCompositor/private/qtwaylandcompositorglobal_p.h>
#include <QtWaylandCompositor/qwaylandseat.h>
@@ -64,6 +65,7 @@
#if QT_CONFIG(xkbcommon)
#include <xkbcommon/xkbcommon.h>
+#include <QtXkbCommonSupport/private/qxkbcommon_p.h>
#endif
@@ -87,7 +89,10 @@ public:
uint32_t mods_latched, uint32_t mods_locked, uint32_t group);
#if QT_CONFIG(xkbcommon)
- struct xkb_state *xkbState() const { return xkb_state; }
+ struct xkb_state *xkbState() const { return mXkbState.get(); }
+ struct xkb_context *xkbContext() const {
+ return QWaylandCompositorPrivate::get(seat->compositor())->xkbContext();
+ }
uint32_t xkbModsMask() const { return modsDepressed | modsLatched | modsLocked; }
void maybeUpdateXkbScanCodeTable();
#endif
@@ -107,7 +112,6 @@ protected:
private:
#if QT_CONFIG(xkbcommon)
- void initXKB();
void createXKBKeymap();
void createXKBState(xkb_keymap *keymap);
#endif
@@ -134,8 +138,7 @@ private:
char *keymap_area = nullptr;
using ScanCodeKey = std::pair<uint,int>; // group/layout and QtKey
QMap<ScanCodeKey, uint> scanCodesByQtKey;
- struct xkb_context *xkb_context = nullptr;
- struct xkb_state *xkb_state = nullptr;
+ QXkbCommon::ScopedXKBState mXkbState;
#endif
quint32 repeatRate = 40;