XKB: Actually explain keymap failures
When something went wrong building a keymap, try to explain to the user what it actually was, instead of the dreaded 'Failed to load XKB keymap' catch-all.
This commit is contained in:
parent
641a5f955b
commit
cf20df39cc
|
@ -274,7 +274,7 @@ char tmpname[PATH_MAX];
|
|||
return True;
|
||||
}
|
||||
else
|
||||
DebugF("Error compiling keymap (%s)\n",keymap);
|
||||
LogMessage(X_ERROR, "Error compiling keymap (%s)\n", keymap);
|
||||
#ifdef WIN32
|
||||
/* remove the temporary file */
|
||||
unlink(tmpname);
|
||||
|
@ -282,9 +282,9 @@ char tmpname[PATH_MAX];
|
|||
}
|
||||
else {
|
||||
#ifndef WIN32
|
||||
DebugF("Could not invoke keymap compiler\n");
|
||||
LogMessage(X_ERROR, "XKB: Could not invoke xkbcomp\n");
|
||||
#else
|
||||
DebugF("Could not open file %s\n", tmpname);
|
||||
LogMessage(X_ERROR, "Could not open file %s\n", tmpname);
|
||||
#endif
|
||||
}
|
||||
if (nameRtrn)
|
||||
|
@ -350,11 +350,13 @@ unsigned missing;
|
|||
if ((names->keycodes==NULL)&&(names->types==NULL)&&
|
||||
(names->compat==NULL)&&(names->symbols==NULL)&&
|
||||
(names->geometry==NULL)) {
|
||||
LogMessage(X_ERROR, "XKB: No components provided for device %s\n",
|
||||
keybd->name);
|
||||
return 0;
|
||||
}
|
||||
else if (!XkbDDXCompileKeymapByNames(xkb,names,want,need,
|
||||
nameRtrn,nameRtrnLen)){
|
||||
DebugF("Couldn't compile keymap file\n");
|
||||
LogMessage(X_ERROR, "XKB: Couldn't compile keymap\n");
|
||||
return 0;
|
||||
}
|
||||
file= XkbDDXOpenConfigFile(nameRtrn,fileName,PATH_MAX);
|
||||
|
@ -369,7 +371,7 @@ unsigned missing;
|
|||
(void) unlink (fileName);
|
||||
return 0;
|
||||
}
|
||||
else if (xkbDebugFlags) {
|
||||
else {
|
||||
DebugF("Loaded XKB keymap %s, defined=0x%x\n",fileName,(*xkbRtrn)->defined);
|
||||
}
|
||||
fclose(file);
|
||||
|
@ -390,32 +392,40 @@ XkbRF_RulesPtr rules;
|
|||
|
||||
if (!rules_name)
|
||||
return False;
|
||||
if (XkbBaseDirectory==NULL) {
|
||||
if (strlen(rules_name)+7 > PATH_MAX)
|
||||
return False;
|
||||
sprintf(buf,"rules/%s",rules_name);
|
||||
|
||||
if (strlen(XkbBaseDirectory) + strlen(rules_name) + 8 > PATH_MAX) {
|
||||
LogMessage(X_ERROR, "XKB: Rules name is too long\n");
|
||||
return False;
|
||||
}
|
||||
else {
|
||||
if (strlen(XkbBaseDirectory)+strlen(rules_name)+8 > PATH_MAX)
|
||||
return False;
|
||||
sprintf(buf,"%s/rules/%s",XkbBaseDirectory,rules_name);
|
||||
}
|
||||
if ((file= fopen(buf,"r"))==NULL)
|
||||
sprintf(buf,"%s/rules/%s", XkbBaseDirectory, rules_name);
|
||||
|
||||
file = fopen(buf, "r");
|
||||
if (!file) {
|
||||
LogMessage(X_ERROR, "XKB: Couldn't open rules file %s\n", file);
|
||||
return False;
|
||||
if ((rules= XkbRF_Create(0,0))==NULL) {
|
||||
}
|
||||
|
||||
rules = XkbRF_Create(0, 0);
|
||||
if (!rules) {
|
||||
LogMessage(X_ERROR, "XKB: Couldn't create rules struct\n");
|
||||
fclose(file);
|
||||
return False;
|
||||
}
|
||||
if (!XkbRF_LoadRules(file,rules)) {
|
||||
|
||||
if (!XkbRF_LoadRules(file, rules)) {
|
||||
LogMessage(X_ERROR, "XKB: Couldn't parse rules file %s\n", rules_name);
|
||||
fclose(file);
|
||||
XkbRF_Free(rules,True);
|
||||
return False;
|
||||
}
|
||||
bzero((char *)names,sizeof(XkbComponentNamesRec));
|
||||
complete= XkbRF_GetComponents(rules,defs,names);
|
||||
|
||||
memset(names, 0, sizeof(*names));
|
||||
complete = XkbRF_GetComponents(rules,defs,names);
|
||||
fclose(file);
|
||||
XkbRF_Free(rules,True);
|
||||
XkbRF_Free(rules, True);
|
||||
|
||||
if (!complete)
|
||||
LogMessage(X_ERROR, "XKB: Rules returned no components\n");
|
||||
|
||||
return complete;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user