Commit cb9a1d01 authored by Kristian H. Kristensen's avatar Kristian H. Kristensen Committed by Peter Hutterer

xkb: factor out xkb loading to LoadXkm

Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Kristian H. Kristensen's avatarKristian Høgsberg <krh@bitplanet.net>
parent 4391cf27
......@@ -291,6 +291,35 @@ XkbDDXOpenConfigFile(const char *mapName, char *fileNameRtrn, int fileNameRtrnLe
return file;
}
static unsigned
LoadXKM(unsigned want, unsigned need, const char *keymap, XkbDescPtr *xkbRtrn)
{
FILE *file;
char fileName[PATH_MAX];
unsigned missing;
file = XkbDDXOpenConfigFile(keymap, fileName, PATH_MAX);
if (file == NULL) {
LogMessage(X_ERROR, "Couldn't open compiled keymap file %s\n",
fileName);
return 0;
}
missing = XkmReadFile(file, need, want, xkbRtrn);
if (*xkbRtrn == NULL) {
LogMessage(X_ERROR, "Error loading keymap %s\n", fileName);
fclose(file);
(void) unlink(fileName);
return 0;
}
else {
DebugF("Loaded XKB keymap %s, defined=0x%x\n", fileName,
(*xkbRtrn)->defined);
}
fclose(file);
(void) unlink(fileName);
return (need | want) & (~missing);
}
unsigned
XkbDDXLoadKeymapByNames(DeviceIntPtr keybd,
XkbComponentNamesPtr names,
......@@ -299,9 +328,6 @@ XkbDDXLoadKeymapByNames(DeviceIntPtr keybd,
XkbDescPtr *xkbRtrn, char *nameRtrn, int nameRtrnLen)
{
XkbDescPtr xkb;
FILE *file;
char fileName[PATH_MAX];
unsigned missing;
*xkbRtrn = NULL;
if ((keybd == NULL) || (keybd->key == NULL) ||
......@@ -321,26 +347,8 @@ XkbDDXLoadKeymapByNames(DeviceIntPtr keybd,
LogMessage(X_ERROR, "XKB: Couldn't compile keymap\n");
return 0;
}
file = XkbDDXOpenConfigFile(nameRtrn, fileName, PATH_MAX);
if (file == NULL) {
LogMessage(X_ERROR, "Couldn't open compiled keymap file %s\n",
fileName);
return 0;
}
missing = XkmReadFile(file, need, want, xkbRtrn);
if (*xkbRtrn == NULL) {
LogMessage(X_ERROR, "Error loading keymap %s\n", fileName);
fclose(file);
(void) unlink(fileName);
return 0;
}
else {
DebugF("Loaded XKB keymap %s, defined=0x%x\n", fileName,
(*xkbRtrn)->defined);
}
fclose(file);
(void) unlink(fileName);
return (need | want) & (~missing);
return LoadXKM(want, need, nameRtrn, xkbRtrn);
}
Bool
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment