build: Require xkbcommon 1.10+

This commit is contained in:
sithlord48
2025-11-21 16:06:30 -05:00
parent 7b614215a1
commit b32a2d36d4
3 changed files with 1 additions and 24 deletions

View File

@@ -149,7 +149,7 @@ macro(configure_unix_libs)
include(FindPkgConfig)
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_check_modules(LIBXKBCOMMON REQUIRED xkbcommon)
pkg_check_modules(LIBXKBCOMMON REQUIRED xkbcommon>=1.10)
pkg_check_modules(GLIB2 REQUIRED glib-2.0)
find_library(LIBM m)
include_directories(${LIBXKBCOMMON_INCLUDE_DIRS} ${GLIB2_INCLUDE_DIRS}

View File

@@ -174,9 +174,6 @@ if(UNIX)
find_library(COCOA_LIBRARY Cocoa)
target_link_libraries(platform ${COCOA_LIBRARY})
else()
if(${LIBXKBCOMMON_VERSION} VERSION_GREATER_EQUAL "1.10")
target_compile_definitions(platform PRIVATE HAVE_XKB_KEYMAP_MOD_GET_MASK=1)
endif()
target_compile_definitions(platform PUBLIC WINAPI_LIBEI WINAPI_LIBPORTAL)
target_include_directories(platform PUBLIC ${LIBEI_INCLUDE_DIRS} ${LIBPORTAL_INCLUDE_DIRS})
target_link_libraries(

View File

@@ -120,14 +120,9 @@ std::uint32_t EiKeyState::convertModMask(xkb_mod_mask_t xkbModMaskIn) const
for (xkb_mod_index_t xkbModIdx = 0; xkbModIdx < xkb_keymap_num_mods(m_xkbKeymap); xkbModIdx++) {
const char *name = xkb_keymap_mod_get_name(m_xkbKeymap, xkbModIdx);
#ifdef HAVE_XKB_KEYMAP_MOD_GET_MASK
// Available since xkbcommon v1.10
// Note: xkb_keymap_mod_get_mask2 was added in v1.11 which accepts xkb_mod_index_t.
const auto xkbModMask = xkb_keymap_mod_get_mask(m_xkbKeymap, name);
#else
// HACK: in older xkbcommon we need to create the mask manually from the index.
const xkb_mod_mask_t xkbModMask = (1 << xkbModIdx);
#endif
// Skip modifiers that have no XKB mask (not mapped to any real modifier)
// or are inactive. Without the xkbModMask == 0 check, modifiers with mask 0
@@ -135,21 +130,6 @@ std::uint32_t EiKeyState::convertModMask(xkb_mod_mask_t xkbModMaskIn) const
if (xkbModMask == 0 || (xkbModMaskIn & xkbModMask) != xkbModMask)
continue;
/* added in libxkbcommon 1.8.0 in the same commit so we have all or none */
#ifndef XKB_VMOD_NAME_ALT
static const auto XKB_VMOD_NAME_ALT = "Alt";
static const auto XKB_VMOD_NAME_LEVEL3 = "LevelThree";
static const auto XKB_VMOD_NAME_LEVEL5 = "LevelFive";
static const auto XKB_VMOD_NAME_META = "Meta";
static const auto XKB_VMOD_NAME_NUM = "NumLock";
static const auto XKB_VMOD_NAME_SCROLL = "ScrollLock";
static const auto XKB_VMOD_NAME_SUPER = "Super";
static const auto XKB_VMOD_NAME_HYPER = "Hyper";
static const auto XKB_MOD_NAME_MOD2 = "Mod2";
static const auto XKB_MOD_NAME_MOD3 = "Mod3";
static const auto XKB_MOD_NAME_MOD5 = "Mod5";
#endif
// From wismill (xkbcommon maintainer):
// Meta is usually encoded like Alt, i.e. to Mod1. In that case, both share the same state.
// Added to that, if KDE interprets Meta as Super (the logo key), then it might explain the mess.