summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraneejit1 <aneejit1@gmail.com>2020-07-03 01:39:21 +0000
committeraneejit1 <aneejit1@gmail.com>2020-07-27 19:23:47 +0000
commit3abd9e912c4b1ed6abd0ff1f440f2105fcbdf4a2 (patch)
tree080b117d07b3743ef96bc65ace9578e8fde7faef
parent0436adf8bda6ce7b78622cac802611e568b4b22e (diff)
downloadtdebase-3abd9e912c4b1ed6abd0ff1f440f2105fcbdf4a2.tar.gz
tdebase-3abd9e912c4b1ed6abd0ff1f440f2105fcbdf4a2.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 <aneejit1@gmail.com>
-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 64908c9da..dc07f39fc 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -479,3 +479,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 daf86f64d..9c2fe0797 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -218,6 +218,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.