summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraneejit1 <[email protected]>2020-07-03 01:39:21 +0000
committerSlávek Banko <[email protected]>2020-07-29 17:18:20 +0200
commitf81582deb338e236982cf536d691a80df2111a99 (patch)
tree3f8527d41e6810a275866478d10cdcf8bc6827ff
parent2d68c6e6474bf5c3ee4d0e988822331b1e9aee0d (diff)
downloadtdebase-f81582deb338e236982cf536d691a80df2111a99.tar.gz
tdebase-f81582deb338e236982cf536d691a80df2111a99.zip
Ask pkg-config/find_file where we can find the X11 Xkb rules directory and add some more candidate paths for xkbd to search
Signed-off-by: aneejit1 <[email protected]> (cherry picked from commit 3abd9e912c4b1ed6abd0ff1f440f2105fcbdf4a2)
-rw-r--r--ConfigureChecks.cmake95
-rw-r--r--config.h.cmake3
-rw-r--r--kxkb/x11helper.cpp27
3 files changed, 120 insertions, 5 deletions
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 84657ac1d..f56f00514 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -466,3 +466,98 @@ if( WITH_ELFICON )
endif( NOT "${LIBR_VERSION}" STREQUAL "0.6.0" )
set( HAVE_ELFICON 1 )
endif( )
+
+#
+# For kxkb, try to find the path to the Xkb rules files:
+#
+# 1: ask for the path from xkeyboard-config's pkg-config file
+# 2: ask for the path from xkbcomp's pkg-config file
+# 3: look under the "FILES" heading in the man page for setxkbmap
+# 4: take the prefix/libdir from xkbfile's pkg-config file and try the
+# "${prefix}/share/X11" and "${libdir}/X11" directories
+#
+# Alternatively, just take an overriding value from the command line.
+#
+
+if( BUILD_KXKB )
+
+ if( NOT X11_XKB_RULES_DIR )
+ pkg_search_module( XKB_CONFIG xkeyboard-config )
+ if( XKB_CONFIG_FOUND )
+ execute_process(
+ COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=xkb_base xkeyboard-config
+ OUTPUT_VARIABLE KB_RULES_DIR
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ if( NOT "${KB_RULES_DIR}" STREQUAL "" )
+ string(REGEX REPLACE "/xkb$" "/" X11_XKB_RULES_DIR "${KB_RULES_DIR}" )
+ endif( )
+ endif( )
+ endif( )
+
+ if( NOT X11_XKB_RULES_DIR )
+ pkg_search_module( XKBCOMP xkbcomp )
+ if( XKBCOMP_FOUND )
+ execute_process(
+ COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=xkbconfigdir xkbcomp
+ OUTPUT_VARIABLE KB_RULES_DIR
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ if( NOT "${KB_RULES_DIR}" STREQUAL "" )
+ string(REGEX REPLACE "/xkb$" "/" X11_XKB_RULES_DIR "${KB_RULES_DIR}" )
+ endif( )
+ endif( )
+ endif( )
+
+ if( NOT X11_XKB_RULES_DIR )
+ execute_process(
+ COMMAND man -P cat setxkbmap
+ OUTPUT_VARIABLE SETXKBMAP_OUTPUT
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_VARIABLE SETXKBMAP_OUTPUT
+ ERROR_STRIP_TRAILING_WHITESPACE
+ RESULT_VARIABLE SETXKBMAP_RC
+ )
+ if( "${SETXKBMAP_RC}" STREQUAL "0" AND
+ "${SETXKBMAP_OUTPUT}" MATCHES "\n.*FILES.*\n[^/]*(/[^\n]*/)xkb.*\n" )
+ if( EXISTS "${CMAKE_MATCH_1}xkb" )
+ set( X11_XKB_RULES_DIR "${CMAKE_MATCH_1}" )
+ endif( )
+ endif( )
+ endif( )
+
+ if( NOT X11_XKB_RULES_DIR )
+ execute_process(
+ COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=libdir xkbfile
+ OUTPUT_VARIABLE KB_RULES_LIBDIR
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ execute_process(
+ COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=prefix xkbfile
+ OUTPUT_VARIABLE KB_RULES_PREFIX
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ if( KB_RULES_LIBDIR AND KB_RULES_PREFIX )
+ find_file( RULES_FILE
+ NAMES xorg xfree86
+ PATHS "${KB_RULES_PREFIX}/share/X11"
+ "${KB_RULES_LIBDIR}/X11"
+ PATH_SUFFIXES xkb/rules
+ NO_DEFAULT_PATH
+ )
+ if( RULES_FILE )
+ string( REGEX REPLACE "/xkb/rules/(xorg|xfree86)$" "/" X11_XKB_RULES_DIR "${RULES_FILE}" )
+ endif( )
+ endif( )
+ endif( )
+
+ if( X11_XKB_RULES_DIR )
+ if( NOT "${X11_XKB_RULES_DIR}" MATCHES "/$" )
+ set( X11_XKB_RULES_DIR "${X11_XKB_RULES_DIR}/" )
+ endif( )
+ message( STATUS "Adding ${X11_XKB_RULES_DIR} to XKb rules directory search" )
+ else( )
+ message( STATUS "No additional XKb rules directory found" )
+ endif( )
+
+endif( )
diff --git a/config.h.cmake b/config.h.cmake
index 4a37ca8d8..0ff887988 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -215,6 +215,9 @@
// tdm, kxkb
#cmakedefine XLIBDIR "@XLIBDIR@"
+// kxkb
+#cmakedefine X11_XKB_RULES_DIR "@X11_XKB_RULES_DIR@"
+
// tdm, kcontrol
#cmakedefine WITH_XRANDR "@WITH_XRANDR@"
diff --git a/kxkb/x11helper.cpp b/kxkb/x11helper.cpp
index aa39845dd..1c8db4a4a 100644
--- a/kxkb/x11helper.cpp
+++ b/kxkb/x11helper.cpp
@@ -22,20 +22,37 @@
// Compiler will size array automatically.
static const char* X11DirList[] =
{
+#ifdef X11_XKB_RULES_DIR
+ X11_XKB_RULES_DIR,
+#endif
XLIBDIR,
"/usr/share/X11/",
- "/etc/X11/",
- "/usr/local/share/X11/",
+ "/usr/lib/X11/",
+ "/usr/lib64/X11/",
+ "/usr/X11/share/X11/",
+ "/usr/X11/lib/X11/",
+ "/usr/X11/lib64/X11/",
+ "/usr/X11R7/share/X11/",
+ "/usr/X11R7/lib/X11/",
+ "/usr/X11R7/lib64/X11/",
+ "/usr/X11R6/share/X11/",
"/usr/X11R6/lib/X11/",
"/usr/X11R6/lib64/X11/",
+ "/usr/local/X11/share/X11/",
+ "/usr/local/X11/lib/X11/",
+ "/usr/local/X11/lib64/X11/",
+ "/usr/local/X11R7/share/X11/",
+ "/usr/local/X11R7/lib/X11/",
+ "/usr/local/X11R7/lib64/X11/",
+ "/usr/local/X11R6/share/X11/",
"/usr/local/X11R6/lib/X11/",
"/usr/local/X11R6/lib64/X11/",
- "/usr/lib/X11/",
- "/usr/lib64/X11/",
+ "/usr/local/share/X11/",
"/usr/local/lib/X11/",
"/usr/local/lib64/X11/",
"/usr/pkg/share/X11/",
- "/usr/pkg/xorg/lib/X11/"
+ "/usr/pkg/xorg/lib/X11/",
+ "/etc/X11/"
};
// Compiler will size array automatically.