[PATCH v2 4/5] xkb: add KeymapOrDefault
Peter Hutterer
peter.hutterer at who-t.net
Wed Mar 12 19:56:58 PDT 2014
From: Kristian Høgsberg <krh at bitplanet.net>
Helper function to return a default map if the keymap compilation failed.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
xkb/ddxLoad.c | 40 ++++++++++++++++++++++++----------------
1 file changed, 24 insertions(+), 16 deletions(-)
diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c
index 0361b9b..76bf09c 100644
--- a/xkb/ddxLoad.c
+++ b/xkb/ddxLoad.c
@@ -444,6 +444,29 @@ XkbCompileKeymapForDevice(DeviceIntPtr dev, XkbRMLVOSet * rmlvo, int need)
return xkb;
}
+static XkbDescPtr
+KeymapOrDefaults(DeviceIntPtr dev, XkbDescPtr xkb)
+{
+ XkbRMLVOSet dflts;
+
+ if (xkb)
+ return xkb;
+
+ /* we didn't get what we really needed. And that will likely leave
+ * us with a keyboard that doesn't work. Use the defaults instead */
+ LogMessage(X_ERROR, "XKB: Failed to load keymap. Loading default "
+ "keymap instead.\n");
+
+ XkbGetRulesDflts(&dflts);
+
+ xkb = XkbCompileKeymapForDevice(dev, &dflts, 0);
+
+ XkbFreeRMLVOSet(&dflts, FALSE);
+
+ return xkb;
+}
+
+
XkbDescPtr
XkbCompileKeymap(DeviceIntPtr dev, XkbRMLVOSet * rmlvo)
{
@@ -461,20 +484,5 @@ XkbCompileKeymap(DeviceIntPtr dev, XkbRMLVOSet * rmlvo)
xkb = XkbCompileKeymapForDevice(dev, rmlvo, need);
- if (!xkb) {
- XkbRMLVOSet dflts;
-
- /* we didn't get what we really needed. And that will likely leave
- * us with a keyboard that doesn't work. Use the defaults instead */
- LogMessage(X_ERROR, "XKB: Failed to load keymap. Loading default "
- "keymap instead.\n");
-
- XkbGetRulesDflts(&dflts);
-
- xkb = XkbCompileKeymapForDevice(dev, &dflts, 0);
-
- XkbFreeRMLVOSet(&dflts, FALSE);
- }
-
- return xkb;
+ return KeymapOrDefaults(dev, xkb);
}
--
1.8.5.3
More information about the xorg-devel
mailing list