summaryrefslogtreecommitdiff
path: root/xkb/ddxLoad.c
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2014-03-12 17:20:17 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2014-03-17 15:10:47 +1000
commit8b6c79e19cfabd9f343884ddd91a738720c94583 (patch)
tree9dd5c409c8bd418e2b906653a666e650549db965 /xkb/ddxLoad.c
parentcb9a1d01468732196fd25c6422991e784639ffce (diff)
xkb: add KeymapOrDefault
Helper function to return a default map if the keymap compilation failed. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
Diffstat (limited to 'xkb/ddxLoad.c')
-rw-r--r--xkb/ddxLoad.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c
index 0361b9be5..76bf09ca7 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);
}