summaryrefslogtreecommitdiff
path: root/xkb
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2011-02-10 15:11:34 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2011-02-14 09:12:59 +1000
commit47d1d2fed656c3a3b2600491078da90962c46934 (patch)
treeb5f97ed2f4ef5b977ca539f116fd0f8b233fd2b8 /xkb
parent787ba25a8a3af52b38448a1a6f8c9704ea8b7905 (diff)
xkb: split out keymap compilation.
Refactoring for simpler double-use in the next patch. No functional changes. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
Diffstat (limited to 'xkb')
-rw-r--r--xkb/ddxLoad.c55
1 files changed, 39 insertions, 16 deletions
diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c
index 51b577725..b968c4360 100644
--- a/xkb/ddxLoad.c
+++ b/xkb/ddxLoad.c
@@ -425,35 +425,58 @@ XkbRF_RulesPtr rules;
return complete;
}
-XkbDescPtr
-XkbCompileKeymap(DeviceIntPtr dev, XkbRMLVOSet *rmlvo)
+static Bool
+XkbRMLVOtoKcCGST(DeviceIntPtr dev, XkbRMLVOSet *rmlvo, XkbComponentNamesPtr kccgst)
{
- XkbComponentNamesRec kccgst;
XkbRF_VarDefsRec mlvo;
- XkbDescPtr xkb;
- char name[PATH_MAX];
-
- if (!dev || !rmlvo) {
- LogMessage(X_ERROR, "XKB: No device or RMLVO specified\n");
- return NULL;
- }
mlvo.model = rmlvo->model;
mlvo.layout = rmlvo->layout;
mlvo.variant = rmlvo->variant;
mlvo.options = rmlvo->options;
- /* XDNFR already logs for us. */
- if (!XkbDDXNamesFromRules(dev, rmlvo->rules, &mlvo, &kccgst))
+ return XkbDDXNamesFromRules(dev, rmlvo->rules, &mlvo, kccgst);
+}
+
+/**
+ * Compile the given RMLVO keymap and return it. Returns the XkbDescPtr on
+ * success or NULL on failure. If the components compiled are not a superset
+ * or equal to need, the compiliation is treated as failure.
+ */
+static XkbDescPtr
+XkbCompileKeymapForDevice(DeviceIntPtr dev, XkbRMLVOSet *rmlvo, int need)
+{
+ XkbDescPtr xkb;
+ unsigned int provided;
+ XkbComponentNamesRec kccgst;
+ char name[PATH_MAX];
+
+ if (!XkbRMLVOtoKcCGST(dev, rmlvo, &kccgst))
return NULL;
- /* XDLKBN too, but it might return 0 as well as allocating. */
- if (!XkbDDXLoadKeymapByNames(dev, &kccgst, XkmAllIndicesMask, 0, &xkb, name,
- PATH_MAX)) {
- if (xkb)
+ provided = XkbDDXLoadKeymapByNames(dev, &kccgst, XkmAllIndicesMask, need,
+ &xkb, name, PATH_MAX);
+ if ((need & provided) != need) {
+ if (xkb) {
XkbFreeKeyboard(xkb, 0, TRUE);
+ xkb = NULL;
+ }
+ }
+
+ return xkb;
+}
+
+XkbDescPtr
+XkbCompileKeymap(DeviceIntPtr dev, XkbRMLVOSet *rmlvo)
+{
+ XkbDescPtr xkb;
+
+ if (!dev || !rmlvo) {
+ LogMessage(X_ERROR, "XKB: No device or RMLVO specified\n");
return NULL;
}
+ xkb = XkbCompileKeymapForDevice(dev, rmlvo, 0);
+
return xkb;
}