Browse Source

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>
pull/158/head
aneejit1 5 months ago
parent
commit
3abd9e912c
3 changed files with 120 additions and 5 deletions
  1. +95
    -0
      ConfigureChecks.cmake
  2. +3
    -0
      config.h.cmake
  3. +22
    -5
      kxkb/x11helper.cpp

+ 95
- 0
ConfigureChecks.cmake View File

@@ -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( )

+ 3
- 0
config.h.cmake View File

@@ -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@"



+ 22
- 5
kxkb/x11helper.cpp View File

@@ -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.


Loading…
Cancel
Save