kcontrol: simplify XKB rules finding logic, based on review 124215

This commit is contained in:
Ivailo Monev 2015-07-11 21:27:27 +03:00
parent 9a3e68ae58
commit 53d96e96bb
3 changed files with 5 additions and 23 deletions

View file

@ -52,6 +52,7 @@ get_filename_component(proto_xbindir "${some_x_program}" PATH)
get_filename_component(XBINDIR "${proto_xbindir}" ABSOLUTE)
get_filename_component(xrootdir "${XBINDIR}" PATH)
set(XLIBDIR "${xrootdir}/lib/X11")
set(XKBDIR "${xrootdir}/share/X11")
check_function_exists(getpassphrase HAVE_GETPASSPHRASE)
check_function_exists(vsyslog HAVE_VSYSLOG)

View file

@ -143,6 +143,9 @@
/* X libraries directory */
#cmakedefine XLIBDIR "${XLIBDIR}"
/* xkb resources directory */
#cmakedefine XKBDIR "${XKBDIR}"
/* Number of bits in a file offset, on hosts where this is settable. */
#define _FILE_OFFSET_BITS 64

View file

@ -151,29 +151,7 @@ static QString findXkbRulesFile()
QString rulesName = Rules::getRulesName();
if ( ! rulesName.isNull() ) {
QString xkbParentDir;
QString base(XLIBDIR);
if( base.count('/') >= 3 ) {
// .../usr/lib/X11 -> /usr/share/X11/xkb vs .../usr/X11/lib -> /usr/X11/share/X11/xkb
QString delta = base.endsWith("X11") ? "/../../share/X11" : "/../share/X11";
QDir baseDir(base + delta);
if( baseDir.exists() ) {
xkbParentDir = baseDir.absolutePath();
}
else {
QDir baseDir(base + "/X11"); // .../usr/X11/lib/X11/xkb (old XFree)
if( baseDir.exists() ) {
xkbParentDir = baseDir.absolutePath();
}
}
}
if( xkbParentDir.isEmpty() ) {
xkbParentDir = "/usr/share/X11";
}
rulesFile = QString("%1/xkb/rules/%2.xml").arg(xkbParentDir, rulesName);
rulesFile = QString("%1/xkb/rules/%2.xml").arg(XKBDIR, rulesName);
}
return rulesFile;